Board index » delphi » Delphi, SQL 6.5, stored procedure problem

Delphi, SQL 6.5, stored procedure problem

I wrote this stored procedure:

CREATE PROCEDURE akt_skarta_rezervace AS

DECLARE upd_rez CURSOR FOR SELECT kod_zbozi, kod_skladu, rezervace FROM
skarta
 WHERE rezervace IS NOT NULL FOR UPDATE OF rezervace
OPEN upd_rez
FETCH NEXT FROM upd_rez
WHILE @@FETCH_STATUS <> -1
BEGIN
 UPDATE skarta SET rezervace = NULL WHERE CURRENT OF upd_rez
 FETCH NEXT FROM upd_rez
END
CLOSE upd_rez
DEALLOCATE upd_rez

UPDATE skarta
SET s.rezervace = r.objednano-r.dodano
FROM skarta s, objpol_rezervovano r
WHERE
  ((s.kod_skladu = 'SM') AND
  (s.kod_zbozi = r.kod_zbozi) AND
   (s.kod_skladu = r.skl_objed))
GO

After run this SP by  ISQL/w  are data in table skarta good.
When I call this SP from Delphi first time the data are wrong, second time
also and third time the data are good. It is possible to repeat it anytime.

Can You help me somebody

Any feedback will be greatly appreciated.

 

Re:Delphi, SQL 6.5, stored procedure problem


Not sure if this is the problem but...

I found that I had setup my ODBC datasource with the save generate stored
procedure for prepared statement.  My stored proc had several different
logic paths based on the parameters passed.  Unless I unprepared the stored
proc, I ended up executing the wrong logic.

Other Threads