on 2010 Aug 18 2:22 PM
v 10.0.1.3931
This script demonstrates the problem:
create table stuff(SomeStuff char(10) primary key);
insert into stuff(somestuff) values ('a');
insert into stuff(somestuff) values ('b');
insert into stuff(somestuff) values ('c');
insert into stuff(somestuff) values ('d');
insert into stuff(somestuff) values ('e');
insert into stuff(somestuff) values ('f');
insert into stuff(somestuff) values ('g');
insert into stuff(somestuff) values ('h');
create function Needs2Parameters(a int, b int)
returns int
begin
return a+b
end;
When you run this statement in ISQL:
select somestuff, Needs2Parameters(13) from stuff order by somestuff;
You get a dialog box entitled "Interactive SQL" saying: The following error occured while fetching results: Wrong number of parameters to function 'Needs2Parameters' SQLCODE=-154, ODBC 3 State="42000".
Fair enough, except that you also get a result set looking like this:
somestuff Needs2Parameters(13)
'b' (NULL)
'c', (NULL)
'd', (NULL)
'e', (NULL)
'f', (NULL)
'g', (NULL)
'h', (NULL)
note that the first line is missing. With an ODBC client it's even odder, you don't get an error, and the first line consists of random data from a buffer (it's often recognisable as something you selected recently), then you get the remainder of the result set seen in ISQL.
If the function is a built in one, eg
select somestuff, greater(13) from stuff order by somestuff
Then you get a different dialog box, enttled "ISQL Error", Could not execute statement. Wrong number of parameters ...... In this case you get no result set.
The same behaviour is seen in v9.0.2
Request clarification before answering.
For a 10.0 server, a warning (SQL_SUCCESS_WITH_INFO) occurs in SQLFetch:
[1] [42000] [SAP][ODBC Driver][SQL Anywhere]Wrong number of parameters to function 'Needs2Parameters', result rows=8, error in row=1
In my test ODBC app I use a row status array, something like this...
SQLSetStmtAttr( HStmt, SQL_ATTR_ROW_STATUS_PTR, row_status, 0 );
You see the following results (status, column values).
Row: 1 [SQL_ROW_ERROR] [ 1]: ═══════════b [ 2]: -842150451 Row: 2 [SQL_ROW_SUCCESS] [ 1]: b [ 2]: <NULL> Row: 3 [SQL_ROW_SUCCESS] [ 1]: c [ 2]: <NULL> Row: 4 [SQL_ROW_SUCCESS] [ 1]: d [ 2]: <NULL> Row: 5 [SQL_ROW_SUCCESS] [ 1]: e [ 2]: <NULL> Row: 6 [SQL_ROW_SUCCESS] [ 1]: f [ 2]: <NULL> Row: 7 [SQL_ROW_SUCCESS] [ 1]: g [ 2]: <NULL> Row: 8 [SQL_ROW_SUCCESS] [ 1]: h [ 2]: <NULL>
Looks like the 10.0 server produces all rows of the rowset, with no values set for the first row, and valid column values for somestuff and SQL_NULL_DATA for Needs2Parameters(13) in the remaining rows. SQL_ROW_ERROR indicates that the columns values in the first row should be ignored (nothing was written to memory).
Interesting behavior.
For an 11.0 server, an error (SQL_ERROR) occurs in SQLFetch and no fetching is done.
For a 16.0 server, an error (SQL_ERROR) results in SQLExecDirect and no fetching is done.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
33 | |
21 | |
16 | |
8 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.