If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Get from EXECUTE IMMEDIATE

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-22-11, 19:01
ricci ricci is offline
Registered User
 
Join Date: Sep 2011
Posts: 39
Get from EXECUTE IMMEDIATE

Hi all.

I'm doing a dynmamic query where you can set any table and any field from it, but I've gotta cath a result from the query example:

SET var = (select count(*) from table where field = 9);

To do this i'm doing this:

SET VLV_Tabla= 'CAT_CUENTAS';
SET VLV_Field = 'ID_CUENTA';

SET VLV_Query = ('SELECT COUNT(*) FROM NOM_ESQ.' || VLV_Tabla || ' WHERE ' || VLV_Campo || ' = 9');

EXECUTE IMMEDIATE VLV_Query;
SET VAR = VLV_Query; -- I know this is impossible but is what I need.



As you know whe you use EXECUTE IMMEDIATE you can't write a Select in you query. Does anybody know how could I get the value from the sentence but it has to be dynamic.

Best regards.
Reply With Quote
  #2 (permalink)  
Old 09-22-11, 22:23
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Reply With Quote
  #3 (permalink)  
Old 09-23-11, 16:14
ricci ricci is offline
Registered User
 
Join Date: Sep 2011
Posts: 39
Thanks I'll check it
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On