> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Donnerstag, 3. April 2003 14:54
> To: [EMAIL PROTECTED]
> Subject: Problem with serial columns
> Importance: High
> 
> 
> Hi all,
> i have a problem with serial columns.
> 
> I need to define a few tables in sapdb with key columns with 
> a default serial.
> The data in these tables will be imported from SqlServer 7.0.
> The tables in SqlServer include key columns with a default serial 
> and records having a key value equal to zero (one for each 
> table, of course).
> If I for instance create the sapdb table TABLE1 with this code:
> 
> CREATE TABLE TABLE1(
> ID INTEGER NOT NULL DEFAULT SERIAL(1),
> DESC VARCHAR(50) NULL,
> PRIMARY KEY (ID)
> )
> 
> and I import only the records having ID > zero
> everything works and sapdb recognizes the default serial 
> (records inserted afterwards are managed correctly).
> 
> The problem is I need to insert records having ID=zero too.
> If I first import data in a sapdb table created without a 
> default serial (so that I don't encounter any error while importing)
> and then add the default serial, the records inserted 
> afterwards have a key ID starting from 1 and not the latest 
> value of the ID
> existing in the table TABLE1.
> 
> Is there a way to assign a starting value to a default serial 
> in a certain table?
> Is this value maybe memorized in a system table?
> 
> Please keep in mind I don't want to further define other 
> structures like sequences instead of using a serial column. 
> 
> Can you please help me to solve this problem? 
> Is there any documentation that I may read concerning this problem?

Yes, I can help.
1. Please read the reference manual
http://www.sapdb.org/7.4/htmhelp/d0/7638a1d21c11d2a97400a0c9449261/frameset.htm
There is written:
DEFAULT SERIAL [(<unsigned_integer)]

 Supplies a number generator for positive integers and can only be specified for 
columns of the data type INTEGER, SMALLINT, and FIXED without decimal places (SERIAL).

The first value generated by the generator can be defined by specifying an unsigned 
integer (must be greater than 0). If this definition is missing, 1 is defined as the 
first value. 

If the value 0 is inserted in this column by an INSERT statement, the current number 
generator value is supplied and not the value 0.

Each table may not contain more than one column with the DEFAULT specification DEFAULT 
SERIAL

And now my question:
why do you force the kernel to start with value 1 if you do not want to start with 
this value,
but with another one? Specify another one and it will be used.

2. This SERIAL-value cannot be seen in any systemtable.

Elke
SAP Labs Berlin

_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to