Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Variablename returned from a databaseprocedure ???
Message
From
17/11/2005 02:29:47
Albert Beermann
Piepenbrock Service Gmbh & Cokg
Osnabrück, Germany
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Variablename returned from a databaseprocedure ???
Environment versions
Visual FoxPro:
VFP 9
Database:
MySQL
Miscellaneous
Thread ID:
01069606
Message ID:
01069606
Views:
66
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
Map
View

Click here to load this message in the networking platform