cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hello,

I've noticed strange behavior using Interactive SQL. I've made a sample script to reproduce the issue. Firstly, we have to create a table and a function that updates that table:

CREATE TABLE IF NOT EXISTS _tmp_t (
    t_id INTEGER PRIMARY KEY DEFAULT AUTOINCREMENT,
    t_time TIMESTAMP
);

CREATE OR REPLACE FUNCTION _sp_update_tmp_t()
RETURNS INTEGER
NOT DETERMINISTIC
BEGIN
    UPDATE _tmp_t SET t_time = CURRENT TIMESTAMP;
    RETURN 1;
END;

Then insert one record:

INSERT INTO _tmp_t (t_time) VALUES (CURRENT TIMESTAMP);
COMMIT;

Then check and remember the newly inserted value:

SELECT * FROM _tmp_t;

Next, try to update the value by calling the function that we created above:

SELECT _sp_update_tmp_t();
COMMIT;

Surprisingly (at least, to me), the value is still the same. But if I try to call the function without a COMMIT and then COMMIT separately, the value changes as expected. Also, the value changes if I remove the semicolon after the function call (before the COMMIT):

SELECT _sp_update_tmp_t()
COMMIT;

Can such behavior be explained somehow or is it a bug?

Server (and client): SA16 latest EBF (1691), the same behavior with SA12 and SA11 (not latest EBFs). Platform: Windows.

Thanks.

View Entire Topic
Former Member

That seems to be an issue of materialization . . .

I'm betting you are running DBISQL configured to not return multiple result sets, and not to show each result set (if running as a batch). When DBISQL runs that way it

  1. prepares the query using the function,
  2. describes the statement
  3. opens and closes a cursor
  4. and drops the statement

it just fine! BUT Never fetches from it.

Without that fetch, the first row does not materialize and that can result in no call to the function. No call, no updates ... or other side-effects.

So if this is your case, you can configure Tools >> Options >> SQL Anywhere >> Results Processing to "Show results from each statment" and "Show all results" ... and then it should behave the way you are probably expecting.

Let us know if that changes the behaviour issue in your setting.

0 Likes

Yes, I'm running DBISQL with default (at least for our platforms) settings (Show results from the last statement and Show only the first result set). When I change them to the values you said, the behavior becomes as expected - different times are being showed (the function call DOES work).

VolkerBarth
Contributor
0 Likes

Well, that's why I still prefer dbisqlc for such tests - DBISQL seems too smart sometimes, i.e. too different from normal database client applications:)