Count and datatype of unnamed params
Posted: 26.11.2008, 11:35
Hi,
I need to find out how many parameters a specific SQL statement (SELECT or CALL) has and the datatype of these parameters.
The SQL is generated from an external application, for example: "SELECT * FROM MYTBL WHERE ID = ? AND XYZ = ?;" or procedure calls.
I have to implement an API for this application which provides the following functions:
myapi_prepare(sql);
myapi_param_count();
myapi_type_of_param(index);
myapi_set_param_int(index, data);
myapi_set_param_string(index, data);
myapi_set_param_float(index, data);
..and so on.
myapi_execute();
+ fetch and cursor functions.
These functions must operate on a TZConnection.
At first, I thought about using ZQuery, but there is no prepare() (first introduced in 7.x) nor unnamed-param support nor datatype detection.
So the next idea was to use TZConnection.DbcConnection.PrepareStatement, but how can I get the param count and the types?
Hint: The TZConnection is used with Firebird 2.0 or MSSQL Server.
I've to implement this API in the next few weeks with zeos 6.x, so I can't wait for 7.x
Edit: Oh, and I need the possibility to set a filter like ZQuery.filter. But I think if it is impossible I can create a workaround and check the current record manually.
I need to find out how many parameters a specific SQL statement (SELECT or CALL) has and the datatype of these parameters.
The SQL is generated from an external application, for example: "SELECT * FROM MYTBL WHERE ID = ? AND XYZ = ?;" or procedure calls.
I have to implement an API for this application which provides the following functions:
myapi_prepare(sql);
myapi_param_count();
myapi_type_of_param(index);
myapi_set_param_int(index, data);
myapi_set_param_string(index, data);
myapi_set_param_float(index, data);
..and so on.
myapi_execute();
+ fetch and cursor functions.
These functions must operate on a TZConnection.
At first, I thought about using ZQuery, but there is no prepare() (first introduced in 7.x) nor unnamed-param support nor datatype detection.
So the next idea was to use TZConnection.DbcConnection.PrepareStatement, but how can I get the param count and the types?
Hint: The TZConnection is used with Firebird 2.0 or MSSQL Server.
I've to implement this API in the next few weeks with zeos 6.x, so I can't wait for 7.x
Edit: Oh, and I need the possibility to set a filter like ZQuery.filter. But I think if it is impossible I can create a workaround and check the current record manually.