Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Interbase Autoincrement Primary Key Problem

7 views
Skip to first unread message

Erik Huber

unread,
May 2, 2000, 3:00:00 AM5/2/00
to
Hello,

I am using C++ Builder 5 and Interbase 5.6
I have a table and a big Problem ;)

CREAT TABLE CUSTOMER
(
CustomerID NOT NULL PRIMARY KEY,
Name VARCHAR(30),
Street VARCHAR(30),
City VARCHAR(30)
)

how can I autoincrement the CustomerID whenever
a new Record is inserted (using a generator&insert trigger or a
generator
in the InsertSQL of the TIBUpdateSQL ) with avoiding the
"EDatabaseerror - CustomerID must have a value"
(which is logical because it is defined NOT NULL - But it must be NOT
NULL
because it is the PRIMARY KEY)

I want to be able to Update and Insert using TIBUpdateSQL and
TIBQuery - and the CustomerID shall autoincrement when a new
Customer is inserted.

It would be real great If someone could help me or point me to
another solution. Do I have a general mistake in my concept?

Thanks

Erik


Martijn Tonies

unread,
May 4, 2000, 3:00:00 AM5/4/00
to
Insert it with a dummy value (eg: 0).

--

Martijn Tonies
Upscene Productions

For InterBase Workbench,
the developer tool for InterBase
http://www.interbaseworkbench.com

For Delphi Components and InterBase tools:
http://www.upscene.com

"Erik Huber" <er...@wwww.at> wrote in message
news:390E2189...@wwww.at...

cai

unread,
May 4, 2000, 3:00:00 AM5/4/00
to
I have the seem problem, I can insert the record in database,
but it would appear two record in my grid, one is the result that I want,
but another record have a null field(Auto increment field), how to fix it
Thinks
Cai


Martijn Tonies <no_spam_m.tonies@_no_spam_upscene.demon.nl> wrote in message
news:8eq81u$sp...@bornews.borland.com...

Martijn Tonies

unread,
May 5, 2000, 3:00:00 AM5/5/00
to
After inserting a new record, you need to close your query and re-open it to
get a new resultset.

Remember, when working with C/S database, you don't have a live view on data
like with dBase or Paradox. You query the database, it gives you a resultset
and that's it... No more, no less. So, if you insert a record (with an
insert statement), you'll _have_ to get the newest resultset from the
server, hence, re-query...

--

Martijn Tonies
Upscene Productions

For InterBase Workbench,
the developer tool for InterBase
http://www.interbaseworkbench.com

For Delphi Components and InterBase tools:
http://www.upscene.com

"cai" <pha...@163.net> wrote in message news:3910e8e7@dnews...

Richard D. Heath

unread,
May 6, 2000, 3:00:00 AM5/6/00
to

Erik Huber <er...@wwww.at> wrote in message news:390E2189...@wwww.at...
> how can I autoincrement the CustomerID whenever
> a new Record is inserted (using a generator&insert trigger or a
> generator
> in the InsertSQL of the TIBUpdateSQL ) with avoiding the
> "EDatabaseerror - CustomerID must have a value"
> (which is logical because it is defined NOT NULL - But it must be NOT
> NULL
> because it is the PRIMARY KEY)
>
>
The problem is with the client program, not the database.

On the client program, select the field that is the primary key and set the
property to "not required". Then you will not have to enter a value. Of
course, the database, itself, will require the primary key to have a value,
but that's what the trigger will handle.

While you are at it, you might as well set the client side property of the
primary key to "read only".

Richard D. Heath

0 new messages