General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Variablename returned from a databaseprocedure ???
Hello Everybody
What is the name of a variable returned from a databaseprocedure ?????
I work with VFP_9, odbc and a maxdb 7.5 database
I have a table autonum where i hold the last id(customerid,adressid...) 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 the new id from autonum
*autonum
l_table = "customers"
l_sqlcmd = "SELECT wert FROM autonum where suchbegriff = ?l_table WITH LOCK EXCLUSIVE "
= SQLEXEC(n_connection,l_sqlcmd)
l_neuwert = wert + 1
l_sqlcmd ="UPDATE autonum set wert=?l_neuwert where suchbegriff = ?l_table"
= SQLEXEC(n_connection,l_sqlcmd)
l_sqlcmd = "commit"
= SQLEXEC(n_connection,l_sqlcmd)
Now i can use l_neuwert as customerid with my insert into customers or for whatever
This technic works but performance is dieing when doing massive inserts (> 50000 records)
I tried to use a dbproc for this !!!????
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(n_connection,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(unknown variable)
Any help welcomed
Best regards
Albert Beermann
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only