Mailing List Archive



Back to the month index Back to the list index

Steve Lawrence (lawst@discoveryweb.com)
Tue, 17 Sep 1996 20:52:56 -0600


From: lawst@discoveryweb.com (Steve Lawrence)
Subject: Re: [mSQL] Auto primary key generator patch
Date: Tue, 17 Sep 1996 20:52:56 -0600
Message-Id: <19960918025620.AAA28456@steve-home.discoveryweb.com>

> Hmmm... The docs say defining a key as a field generates an implicit 'not

> null'. You can't not specify a 'not null' on the key defs.
> Unless of course the patch in question also changes that...

I thought of that at first myself, but since we are passing msql the value
for the field is the word NULL, the patch will see that as a key word and
work it's magic. When I tried to pass the table no data for the primary
key, you would normally instert the NULL value, which means nothing, there
for I recieved an error as a primary key cannot contain NULL. Arrg, this is
hard to explain!

ok. for example:

I have the following table defined called test wich has two fields,

index char(4) primary key,
data char(64),

if I use the following command:

insert into test (index) values ('1001')

the data for that row will look like this

1001,NULL

but if I use the following:

insert into test (data) values ('widgetx01')

I will get an error because I have defined index as my primary key and as
for the above example a NULL will have been tried to be placed into the
row.

NOW, if I apply the update patch with the automagic increment feature, I
should make my insert look like the following:

insert into test (index,data) values ('NULL',widget')

The patch will see the keyword NULL and asssing the next available number
to that row, so a query will show the following for that row.

1,widgetx01

That is where I got the whole thing wrong, because I had assumed that the
program inserting a NULL and my query inserting the word NULL were the same
thing, wich they are not.

Hope this makes sense to you, it does to me! (at least now it does<G>)

--------------------------------------------------------------------------
To remove yourself from the Mini SQL mailing list send a message containing
"unsubscribe" to "unsubscribe" to msql-list-request@bunyip.com. Send a message containing
"info msql-list" to majordomo@bunyip.com for info on monthly archives of
the list. For more help, mail owner-msql-list@bunyip.com NOT the msql-list!