Author: Ed Leafe
Posted: 2004-01-08 at 08:36:16
Quote: >>Actually this is the code I have still under construction:
<code>
LOCAL llRetVal, loLastRecord, lnConHnd, liID, lnNextId
llRetVal = DODEFAULT()
lnConnHnd =
SQLSTRINGCONNECT("DSN=C99_VSO3Data_FireBird;DRIVER=OdbcJdbc;DBNAME=D:\Shared\C99\Data\VSO3.FDB;UID=SYSDBA;PWD=masterkey")
= SQLEXEC(lnConnHnd , [SELECT
gen_id(GEN_MSALESREPS_ID,1) AS lnNextId from
rdb$VSO3])
liID = lnNextId
wait window str(liID) + str(lnNextId)
RETURN llRetVal</code>
So in essence I am replacing the default for the view, is end of
beforenew() good enough. I have called the dodefault() and studying
the inherited code I assumed that the record is append blank somewhere
down the line, thus my decision.
Oh, so you're using remote data. Normally the remote database has its
own method of key generation, such as autoincrement fields in MySQL.
In those cases, you don't generate the ID locally; you simply commit
the new record without a value in the ID field, and then call the
database server function that returns the ID of the last record that
was inserted. You can then replace the iID field of the local record
with that value.
I see from your DSN that you are using Firebird as your database. I
don't have any experience with that product, so I'll leave it to
others to fill in the specifics as to how to best do this with
Firebird.