dbTalk Databases Forums  

Problem with EXECUTE IMMEDIATE

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss Problem with EXECUTE IMMEDIATE in the sybase.public.sqlanywhere.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Marcos Cunha Lima
 
Posts: n/a

Default Problem with EXECUTE IMMEDIATE - 09-02-2011 , 08:35 AM






Hi everyone

We are migrating from SQLAnywhere version 7 to version 12 and are
going through a strange problem regarding EXECUTE IMMEDIATE.

I have the following procedure ( I made it simpler than it actually is
just to debug the problem ) that's called from another procedure:

CREATE PROCEDURE FOO()
DECLARE xComandoTeste LONG VARCHAR;

set xComandoTeste = 'SELECT bloqueado FROM SISTEMA';
Message xComandoTeste;
execute immediate WITH RESULT SET ON STRING ( xComandoTeste );
if @@rowcount > 0 then
raiserror 17000 'ERROR'
end if;
END;

The problem is that I always get an error when I execute the EXECUTE
IMMEDIATE statement. More strange is that it doesn't show the error
just go to the last line of the procedure (doesn't execute the if
@@rowcount...) and the application that calls this procedure freezes.
The @@error variable is set to -6.
It works fine in the ISQL and it has been working in version 7.

Does anyone have a clue about this behaviour?

Best regards

Reply With Quote
  #2  
Old   
cjd
 
Posts: n/a

Default Re: Problem with EXECUTE IMMEDIATE - 09-07-2011 , 06:43 AM






On Sep 2, 3:35*pm, Marcos Cunha Lima <mar... (AT) futuranet (DOT) com.br> wrote:
Quote:
Hi everyone

We are migrating from SQLAnywhere version 7 to version 12 and are
going through a strange problem regarding EXECUTE IMMEDIATE.

I have the following procedure ( I made it simpler than it actually is
just to debug the problem ) that's called from another procedure:

CREATE PROCEDURE FOO()
DECLARE xComandoTeste LONG VARCHAR;

*set xComandoTeste = 'SELECT bloqueado FROM SISTEMA';
* * Message xComandoTeste;
* * execute immediate WITH RESULT SET ON STRING ( xComandoTeste );
* * if @@rowcount > 0 then
* * * raiserror 17000 'ERROR'
* * end if;
END;

The problem is that I always get an error when I execute the EXECUTE
IMMEDIATE statement. More strange is that it doesn't show the error
just go to the last line of the procedure (doesn't execute the if
@@rowcount...) and the application that calls this procedure freezes.
The @@error variable is set to -6.
It works fine in the ISQL and it has been working in version 7.

Does anyone have a clue about this behaviour?

Best regards
Marcos,
Perhaps your previous isql had by default = process all result sets.
Make sure that your client ( eg dbisql , etc. ) is able ( set its
option on ) to go through all the result sets . Otherwise it will only
execute up to and including the first result set in your stored proc .
Saludos,
Carlos

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.