Error while execute Store Procedure

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
knancys
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 07.11.2005, 14:18
Location: Ribeirao PReto/SP
Contact:

Error while execute Store Procedure

Post 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?
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

What is the error?
SQL?
...
more data, please!
dudeski
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 04.11.2005, 01:09
Location: Skopje
Contact:

Post 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.)
knancys
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 07.11.2005, 14:18
Location: Ribeirao PReto/SP
Contact:

Post 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)
Michael
ZeosLib's Handyman :o)
ZeosLib's Handyman :o)
Posts: 189
Joined: 15.08.2005, 16:08
Location: Wehrheim
Contact:

Post 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.
:prog2: Use the source, dude!

[align=right]..::.. ZeosLib on SourceForge ..::..[/align]
knancys
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 07.11.2005, 14:18
Location: Ribeirao PReto/SP
Contact:

Post by knancys »

I am using Interbase 6 + Lazarus, but I go to try exactly thus
knancys
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 07.11.2005, 14:18
Location: Ribeirao PReto/SP
Contact:

Michael

Post 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 8) 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
knancys
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 07.11.2005, 14:18
Location: Ribeirao PReto/SP
Contact:

Post 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?
User avatar
tkszeos
Junior Boarder
Junior Boarder
Posts: 35
Joined: 26.08.2005, 21:45

Post 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
knancys
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 07.11.2005, 14:18
Location: Ribeirao PReto/SP
Contact:

Post 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(?,?);.
User avatar
tkszeos
Junior Boarder
Junior Boarder
Posts: 35
Joined: 26.08.2005, 21:45

Post 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
knancys
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 07.11.2005, 14:18
Location: Ribeirao PReto/SP
Contact:

Post by knancys »

Sorry a long time
Nicola,

I tested the parameter IDVENDEDOR and is correct, but some suggestion?
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

Try to execute tho procedure without parameters - write them directly in the SQL?
Hikari
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 30.01.2006, 12:39
Contact:

Post 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. :cry:

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 ^^
amzeos
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 19.10.2005, 11:33

Post 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
Post Reply