Page 1 of 1
Error while execute Store Procedure
Posted: 07.11.2005, 14:28
by knancys
While I execute my store procedure in second time, result a error.
e.g:
ZStoredProc.ParamByName('IDVENDEDOR').AsInteger := ....
ZStoredProc.ExecProc;
But if i exit the project and return, normal functioning of the SP, what I am not remembering to make?
Posted: 09.11.2005, 09:34
by zippo
What is the error?
SQL?
...
more data, please!
Posted: 09.11.2005, 11:17
by dudeski
Do you create your Stored Procedure on rum time?
If this is case then second time you are creating component you are creating component what already exist.
Pls be more specific (error discription etc.)
Posted: 09.11.2005, 12:22
by knancys
Well, I am not creating the ZStoredProc in run-time.
Executing some tests I evidenced that it does not have errors in Store Procedure.
Executing second time the ZStoredProc, return this erros:
SQL Error: Dynamic SQL Error parameter mismatch for procedure
CALCID_VENDEDORDETAIL. Error Code -902. Unsuccessful execution caused by a system error that precludes
successful execution of subsequent statements The SQL: EXECUTE PROCEDURE CALCID_VENDEDORDETAIL(?,?);.
Press Ok to ignore
Press Cancel to stop the program.
where:
CALCID_VENDEDORDETAIL is name of my Store Procedure and have two parameters, IDVENDEDOR (input) and IDRESULT (Result)
Posted: 09.11.2005, 18:32
by Michael
Hi knancys,
what database are you using? If it is Firebird, then I would suggest to read the "TZStoredProc"-Section of the article "The ZeosLib DBOs 6.1.5 - With Delphi 7 and Firebird 1.5" maybe this could give you a hint to solve the problem.
The idea is to call the StoredProc with an SQL-Statement via TZQuery...
Sometimes TZStoredProc causes bad trouble but we could not fix this behaviour, yet.
Regards.
Posted: 09.11.2005, 19:00
by knancys
I am using Interbase 6 + Lazarus, but I go to try exactly thus
Michael
Posted: 10.11.2005, 12:04
by knancys
Sorry a question, but I am making this:
In ZQuery1.SQL:
execute procedure CALCID_VENDEDORDETAIL :idvendedor
In Unit:
ZQuery1.ParamByName('IDVENDEDOR').AsInteger := StrToInt(Edit1.Text);
ZQuery1.ExecSQL;
When I execute, returns this error:
SQL Error: message length error (encountered 0, expected
Error Code: -901.
Unsuccessful execution cauded by system error that does not preclude successful excecution of subsequent statement The SQL: execute procedure CALCID_VENDEDORDETAIL ?
Add: The Store Procedure have two parameters, one input and other result
Posted: 10.11.2005, 13:08
by knancys
I am obtaining results, reading the Knowledge Base:
An introduction to the basic usage of ZeosLib DBOs and Firebird basics
But my ZConnection is AutoCommit=True and this is my code:
Code: Select all
ZStoredProc.ParamByName('IDVENDEDOR').AsInteger := ZTable.FieldByName('IDVENDEDOR').AsInteger;
ZConnection1.StartTransaction;
Try
ZStoredProc.ExecProc;
except
ZConnection1.Rollback;
end;
ZConnection1.Commit;
However if execute this code two followed times, returns this error:
Invalid operation in AutoCommit mode.
But if set Zconnetion to AutoCommit=False returns this error:
Invalid operation non in AutoCommit mode.
Some suggestion?
Posted: 10.11.2005, 19:37
by tkszeos
Try this code
[syntax="delphi"]
ZStoredProc.ParamByName('IDVENDEDOR').AsInteger := ZTable.FieldByName('IDVENDEDOR').AsInteger;
ZConnection1.StartTransaction;
Try
ZStoredProc.ExecProc;
ZConnection1.Commit;
except
ZConnection1.Rollback;
end;
[/syntax]
Nicola
Posted: 10.11.2005, 20:18
by knancys
tkszeos, Thank you
But I am with my first error:
Executing second time the ZStoredProc, return this erros:
SQL Error: Dynamic SQL Error parameter mismatch for procedure
CALCID_VENDEDORDETAIL. Error Code -902. Unsuccessful execution caused by a system error that precludes
successful execution of subsequent statements The SQL: EXECUTE PROCEDURE CALCID_VENDEDORDETAIL(?,?);.
Posted: 11.11.2005, 00:35
by tkszeos
It verifies the value of the field "IDVENDEDOR" (for example ShowMessage(ZTable.FieldByName ('IDVENDEDOR').AsString)) before is passed as parameter to the stored procedures, perhaps it is null
Nicola
Posted: 21.11.2005, 10:56
by knancys
Sorry a long time
Nicola,
I tested the parameter IDVENDEDOR and is correct, but some suggestion?
Posted: 07.12.2005, 22:18
by zippo
Try to execute tho procedure without parameters - write them directly in the SQL?
Posted: 31.01.2006, 15:43
by Hikari
Michael wrote: The idea is to call the StoredProc with an SQL-Statement via TZQuery...
Sometimes TZStoredProc causes bad trouble but we could not fix this behaviour, yet.
Hi Michael, I'm using TZQuery to call a stored procedure, plz take a look if I'm doing it right:
Code: Select all
void TQuestForm::CompleteQuest(int character, int quest, bool complete){
char sql[200];
sprintf(sql,"execute procedure CompleteQuest(%d,%d,%d)",character,quest,
complete?1:0);
MainForm->ZQueryGeneric->SQL->Text=sql;
MainForm->ZQueryGeneric->Open();
MainForm->ZQueryGeneric->Close();
}
I simplified it a bit. The procedure receives 3 parameters and returns 1, so I build the sql string, set it on SQL property and open & close the TZQuery.
(I'm using BCB6 with Zeos 6.1.5 and Firebird 2.0
)
The objective of this procedure is to change some data on database.
It works as needed, but there's an inconsistency: on my app the data is changed immediately and shown accordingly, but on IBExpert it's not changed
I must close my app to see the changes on IBExpert, and if I kill my app it's never changed on database. I suppose it's being cached on the app and is only commited when the ZConnection is closed.
I have other ZQuery and any change on Data Controls is auto commited.
Do you see anything wrong I'm doing or have any suggestion to solve it?
Tnx ^^
Posted: 25.01.2007, 21:51
by amzeos
Hi all,
in my application the problem in this topic is raised after upgrading from zeos 6.0.5 to 6.6.0-beta.
I use D7 and fb2.0.
My solution is:
procedure TForm1.Button1Click(Sender: TObject);
var
id: integer;
begin
ZStoredProc1.CleanupInstance;
ZStoredProc1.ParamByName('PAR1').AsString := 'T1';
ZStoredProc1.ExecProc;
id := ZStoredProc1.ParamByName('RES1').AsInteger;
end;
Using CleanupInstance is not reccomended but works (see D7 help).
I think there is a bug in TZStoredProc.
By
amzeos