TZStoredParam anomaly

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 766
Joined: 18.11.2018, 17:37
Location: Hungary

TZStoredParam anomaly

Post by aehimself »

I started to experiment with stored procedures. Is there any reason why this code works:

Code: Select all

 ZStoredProc1.Connection := OracleConnection;
 ZStoredProc1.Params.CreateParam(ftLongWord, 'pGlobalID', ptResult);
 ZStoredProc1.StoredProcName := 'GetNextGlobalID';
 ZStoredProc1.Connection.Connect;
 ZStoredProc1.ExecProc;
and this one throws the exception "Cannot retrieve resultset data"?

Code: Select all

 ZStoredProc1.Connection := OracleConnection;
 ZStoredProc1.StoredProcName := 'GetNextGlobalID';
 ZStoredProc1.Params.CreateParam(ftLongWord, 'pGlobalID', ptResult);
 ZStoredProc1.Connection.Connect;
 ZStoredProc1.ExecProc;
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 766
Joined: 18.11.2018, 17:37
Location: Hungary

Re: TZStoredParam anomaly

Post by aehimself »

I have a feeling that this is related to this bugfix.
The below code worked fine in my test application but throws the same "cannot retrieve resultset" exception in my real application.
TZAbstractRODataset.ExecSQL -> TZStoredProc.SetStatementParams says that Params.Count is 9, however I have only one parameter.

Exception is raised in TZAbstractRODataset.ExecSQL -> TZAbstractRODataset.RetrieveParamValues -> TZAbstractCallableStatement.IsNull -> TZAbstractPreparedStatement.IsNull -> TZAbstractPreparedStatement.ParamterIndex2ResultSetIndex. The cycle still sees the 9 parameters, retrieves the first one without issues but throws the exception in the second round... which is expected, as we have only one parameter.

I'll see if I can dig deeper.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 766
Joined: 18.11.2018, 17:37
Location: Hungary

Re: TZStoredParam anomaly

Post by aehimself »

WRONG!!!

To answer my original question:
The setter method of StoredProcName triggers a metadata lookup. This lookup will automatically collect and update the .Params property of the TZStoredProc object. If you add parameters first and then update the procedure name, your previously created parameters will be omitted.

I also issued a pull request to fix the schema / catalog consideration, see here.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
Post Reply