Hello Everybody
I work with odbc and a maxdb 7.5 database
I have a table where i hold the last id for all my tables
suchbegriff char(20) = tablename
wert fixed(10,0) = last id
...
...
When inserting a new record into table customers i first get a new
recordid
*autonum
l_suchbefriff = "customers"
l_sqlcmd = "SELECT wert FROM autonum where suchbegriff = ?l_suchbegriff
WITH LOCK EXCLUSIVE "
= SQLEXEC(p_verbindungsnr,l_sqlcmd)
l_neuwert = wert + 1
l_sqlcmd ="UPDATE autonum set wert=?l_neuwert where suchbegriff =
?l_suchbegriff"
= SQLEXEC(p_verbindungsnr,l_sqlcmd)
l_sqlcmd = "commit"
= SQLEXEC(p_verbindungsnr,l_sqlcmd)
Now i can use l_neuwert as recordid with my insert or for whatever
I tried to use a dbproc for this !!!????
(My first MAXDB dbproc !!! Newbee !! Just mutating an example !!)
****
CREATE DBPROC dbproc_autonum (IN suchbegriff CHAR(30),OUT neuerwert
FIXED(10,0))
AS VAR neuwert fixed(10,0);
DECLARE dbproccursor CURSOR FOR
select wert FROM "BWPROGI"."AUTONUM" WHERE upper(suchbegriff) =
upper(:suchbegriff) ;
WHILE $rc = 0 DO BEGIN
FETCH dbproccursor INTO :neuwert;
END;
SET neuerwert = neuwert + 1;
close dbproccursor;
update "BWPROGI"."AUTONUM" set wert = wert + 1 WHERE upper(suchbegriff)
= upper(:suchbegriff);
****
I think, there must be a smarter way to do this but nevertheless.....;-)
>From SQL-Studio everything works as expected:
call dbproc_autonum('CUSTOMERS',:neuerwert) with commit
shows out(1)
471118 = the next id
In my application i do
l_cmd = "call dbproc_autonum('CUSTOMERS',:neuerwert) with commit"
=sqlexec(p_verbindungsnr,l_cmd)
no error
But what is the name of the returned variable in my application ???????
i tried l_neuwert = neuerwert
l_neuwert = out(1)
l_neuwert = out
without success
Any help welcomed
Best regards
Albert Beermann
'''''
'''''''''
(0 0)
+---------oOO-----------(_)------------------------------+
| Tel: 0541/5841-868 |
| Fax: 0541/5841-869 |
| Mail: mailto:[EMAIL PROTECTED] |
| Internet: http://www.piepenbrock.de <http://www.piepenbrock.de/>
|
+--------------------------------------oOO----------------+
|__|__|
|| ||
ooO Ooo