What I want to do is this: (Currently using Client DataSets) User is paging
through records, user decides to add new customer ID to customer table, user
hits new button on DBNav bar, Grid clears (ready to accept info) User
doesn't need to manually enter customer ID interbase or Delphi will do it
auto-magically.
Any suggestions?
Sorry for so many similar question, I am coming from a MySQL/Postgresql
background. As you may know, auto-increments are not a big issue there. (not
meant to be a troll)
I would suggest you do to that:
Method #1
1- Create a generator in IB.
2- Create a storec proc that will return the next value of the generator.
3- On the OnNewRecord event (I don't know if ClientDataSet have this event.
If not, find an event that's similar), do a query will return the stored
proc value.
4- Put that returned value into the field.
Method #2
1- On the OnNewRecord event, do this query: Select Max(ID) as MAX_ID from
table.
2- Then, increment the number;
iMax := sql.FieldByName('MAX_ID').asInteger+1;
3- Put the iMax value into the field.
HTH
VB
--
IBExpert - The most Expert for InterBase --- http://www.ibexpert.com
HK Software - Holger Klemt - Huntestrasse 15 - D-26135 Oldenburg
Telefon Telefax +49 700 IBEXPERT (42397378) www.h-k.de
Schulungen - Projektunterstützung - Delphi - InterBase - AS/400
"Vincent Bergeron" <in...@vincentbergeron.com> schrieb im Newsbeitrag
news:3c79cd59$1_1@dnews...
Hi,
> Method #1
> 1- Create a generator in IB.
This is multi-user safe.
> Method #2
> 1- On the OnNewRecord event, do this query: Select Max(ID) as MAX_ID from
> table.
This is NOT multi-user safe.
J
> It takes a lot of time on getting the result, because no index
> is used with max()
MAX will use a DESCENDING index, if available.
> and it is not sure, that you will be the only
> one in the network, who gets the last result.
Quite correct. This is the real problem.
-Craig
--
Craig Stuntz (TeamB) · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase WebLog: http://delphi.weblogs.com
InterBase PLANalyzer (Free IB optimization tool):
http://delphi.weblogs.com/IBPLANalyzer
Jim
"Vincent Bergeron" <in...@vincentbergeron.com> wrote in message
news:3c79cd59$1_1@dnews...
Jim Wharton wrote:
>
> Created a new generator that supposedly autoincrements. When I try to
> inssert a new record, it just tells me I can't leave that fiel null. I want
> the database to place that value there.
You need to set the TField's Required to false for that field. The error
message is a client side check that stops even bothering the DB if the required
fields are not set on the client. If you plan on settign them on the server you
need to tell the client to not check those fields.
>
> Jim
>
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
This sad little lizard told me that he was a brontosaurus on his mother's
side. I did not laugh; people who boast of ancestry often have little else
to sustain them. Humoring them costs nothing and ads to happiness in
a world in which happiness is in short supply. (RAH)