function GenID2012($seq='adodbseq',$start=1)
	{

		/*
		 * First time in create an array of sequence names that we
		 * can use in later requests to see if the sequence exists
		 * the overhead is creating a list of sequences every time
		 * we need access to at least 1. If we really care about
		 * performance, we could maybe flag a 'nocheck' class variable
		 */
		if (!$this->sequences){
			$sql = "SELECT name FROM sys.sequences";
			$this->sequences = $this->GetCol($sql);
		}
		if (!is_array($this->sequences)
		|| is_array($this->sequences) && !in_array($seq,$this->sequences)){
			$this->CreateSequence2012($seq, $start);

		}
		$num = $this->GetOne("SELECT NEXT VALUE FOR $seq");
		return $num;
	}
function GenID2012($seq='adodbseq',$start=1)
	{

		/*
		 * First time in create an array of sequence names that we
		 * can use in later requests to see if the sequence exists
		 * the overhead is creating a list of sequences every time
		 * we need access to at least 1. If we really care about
		 * performance, we could maybe flag a 'nocheck' class variable
		 */
		if (!$this->sequences){
			$sql = "SELECT name FROM sys.sequences";
			$this->sequences = $this->GetCol($sql);
		}
		if (!is_array($this->sequences)
		|| is_array($this->sequences) && !in_array($seq,$this->sequences)){
			$this->CreateSequence2012($seq, $start);

		}
		$num = $this->GetOne("SELECT NEXT VALUE FOR $seq");
		return $num;
	}
function GenID2012 ( $ seq = 'adodbseq' , $ start = 1 ) { /*
		 * First time in create an array of sequence names that we
		 * can use in later requests to see if the sequence exists
		 * the overhead is creating a list of sequences every time
		 * we need access to at least 1. If we really care about
		 * performance, we could maybe flag a 'nocheck' class variable
		 */ if ( ! $ this -> sequences ) { $ sql = "SELECT name FROM sys.sequences" ; $ this -> sequences = $ this -> GetCol ( $ sql ) ; } if ( ! is_array ( $ this -> sequences ) || is_array ( $ this -> sequences ) && ! in_array ( $ seq , $ this -> sequences ) ) { $ this -> CreateSequence2012 ( $ seq , $ start ) ; } $ num = $ this -> GetOne ( "SELECT NEXT VALUE FOR $seq" ) ; return $ num ; }
Only available to Server 2012 and up
Cannot do this the normal adodb way by trapping an error if the
sequence does not exist because sql server will auto create a
sequence with the starting number of -9223372036854775808
Only available to Server 2012 and up Cannot do this the normal adodb way by trapping an error if the sequence does not exist because sql server will auto create a sequence with the starting number of - 9223372036854775808