There is an empty database:
With a simple procedure in there:
Then there is a simple PowerBuilder application created using application template:
And this is where the fun begins: if I start the database and first time run the program, I get the following error after OPEN command:
Then if I restart the program, i.e. reconnect to the database, error no longer occurs. And I get no errors on every next connection, only the first time after starting the database.
I am using the following software:
There is no error using SQL Anywhere 11 ar 12, I tried older build 1691 for version 16 and got the same problem. I also tried declaring same cursor in SQL Interactive, could not reproduce the same error. Also if I change host variables in PowerBuilder application with static values like this:
I get no error, but if at least one procedures argument is a variable, I get the error on first connection.
I investigated this issue today and have a fix for the problem (it's been there since the initial release of 16.0).
answered 15 Aug '14, 16:33
I get the same symptom with the following PB 11.5 application open event script using a SQL Anywhere 22.214.171.1243 database. As you indicate, it fails when the script is run immediately after the database is started...
then it works ok on subsequent executions...
It behaves the same when run from the PB IDE and as a deployed executable (test.exe).
I don't think the pbodb115.ini file is involved here, but I attached the copy I am using (and haven't changed in a hundred years :)
Integer a = 2, b = 2, c SQLCA.DBMS = 'ODB' SQLCA.DBParm & = "ConnectString='Driver=SQL Anywhere 16;" & + "UID=dba; PWD=sql; DBN=ddd16; ENG=ddd16'," & + "ConnectOption='SQL_DRIVER_CONNECT,SQL_DRIVER_NOPROMPT'" CONNECT USING SQLCA; IF SQLCA.SQLCODE <> 0 THEN MessageBox ( 'Error', & 'CONNECT failed in open:' & + '~r~nSQLCode = ' & + String ( SQLCA.SQLCode ) & + '~r~nSQLDBCode = ' & + String ( SQLCA.SQLDBCode ) & + '~r~n' & + SQLCA.SQLErrText ) RETURN END IF MessageBox ( 'CONNECT', 'OK' ); //CREATE OR REPLACE PROCEDURE dba.sp_test(in @a integer, in @b integer) //BEGIN // select @a + @b as c; //END; DECLARE c_test CURSOR FOR SELECT c FROM sp_test(:a, :b); IF SQLCA.SQLCode <> 0 THEN MessageBox('DB Error', SQLCA.SQLErrText) OPEN c_test; IF SQLCA.SQLCode <> 0 THEN MessageBox('DB Error', SQLCA.SQLErrText) FETCH c_test INTO :c; IF SQLCA.SQLCode <> 0 THEN MessageBox('DB Error', SQLCA.SQLErrText) ELSE MessageBox('Success!', string(a) + ' + ' + string(b) + ' = ' + string(c)) END IF CLOSE c_test; IF SQLCA.SQLCode <> 0 THEN MessageBox('DB Error', SQLCA.SQLErrText) MessageBox ( 'test', 'all done' );