Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Execute immediate and procession a result set

6 posts in General Discussion Last posting was on 2004-09-01 20:16:56.0Z
Mark Mikulecky Posted on 2004-08-26 23:02:16.0Z
Sender: 6946.412e474f.1804289383@sybase.com
From: Mark Mikulecky
Newsgroups: ianywhere.public.general
Subject: Execute immediate and procession a result set
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <412e6d6b.6b7a.1681692777@sybase.com>
X-Original-NNTP-Posting-Host: 10.22.241.42
X-Original-Trace: 26 Aug 2004 16:08:27 -0700, 10.22.241.42
Lines: 28
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 26 Aug 2004 15:52:03 -0700, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 26 Aug 2004 16:02:16 -0700
X-Trace: forums-1-dub 1093561336 10.22.108.75 (26 Aug 2004 16:02:16 -0700)
X-Original-Trace: 26 Aug 2004 16:02:16 -0700, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3441
Article PK: 7354

I created a procedure and I have a dynamic sql statement
that
returns results. I need to be able to loop through those
results.
I'm having trouble finding documentation on how to do it

My normal code non-Execute Immediate
(just the specific portion giving me trouble)

v_id_stream = '';
for forloop as this_loop dynamic scroll cursor for
select employee_id as v_employee_id from employee do
set v_id_stream = v_id_stream || v_employee_id || '/' end
for;

how do i do the above with Excecute immediate?
my guess that does not work is below.

v_sql = 'select employee_id as v_employee_id from
employee';
v_id_stream = '';
for forloop as this_loop dynamic scroll cursor for
execute immediate v_sql;
do
set v_id_stream = v_id_stream || v_employee_id || '/' end
for;

Thanks for any response.


Robert Waywell Posted on 2004-08-27 13:07:55.0Z
From: "Robert Waywell" <nospam_rwaywell@ianywhere.com>
Newsgroups: ianywhere.public.general
References: <412e6d6b.6b7a.1681692777@sybase.com>
Subject: Re: Execute immediate and procession a result set
Lines: 57
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: rwaywell-pc.sybase.com
X-Original-NNTP-Posting-Host: rwaywell-pc.sybase.com
Message-ID: <412f322b$1@forums-1-dub>
Date: 27 Aug 2004 06:07:55 -0700
X-Trace: forums-1-dub 1093612075 10.25.100.118 (27 Aug 2004 06:07:55 -0700)
X-Original-Trace: 27 Aug 2004 06:07:55 -0700, rwaywell-pc.sybase.com
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3443
Article PK: 7347

What version of ASA are you using?

--
-----------------------------------------------
Robert Waywell
Sybase Adaptive Server Anywhere Developer - Version 8
Sybase Certified Professional

Sybase's iAnywhere Solutions

Please respond ONLY to newsgroup

EBF's and Patches: http://downloads.sybase.com
choose SQL Anywhere Studio >> change 'time frame' to all

To Submit Bug Reports:
http://case-express.sybase.com/cx/cx.stm?starturl=casemessage.ssc?CASETYPE=B
ug

SQL Anywhere Studio Supported Platforms and Support Status
http://my.sybase.com/detail?id=1002288

Whitepapers, TechDocs, and bug fixes are all available through the iAnywhere
Developer Community at www.ianywhere.com/developer

<Mark Mikulecky> wrote in message
news:412e6d6b.6b7a.1681692777@sybase.com...
> I created a procedure and I have a dynamic sql statement
> that
> returns results. I need to be able to loop through those
> results.
> I'm having trouble finding documentation on how to do it
>
> My normal code non-Execute Immediate
> (just the specific portion giving me trouble)
>
> v_id_stream = '';
> for forloop as this_loop dynamic scroll cursor for
> select employee_id as v_employee_id from employee do
> set v_id_stream = v_id_stream || v_employee_id || '/' end
> for;
>
> how do i do the above with Excecute immediate?
> my guess that does not work is below.
>
> v_sql = 'select employee_id as v_employee_id from
> employee';
> v_id_stream = '';
> for forloop as this_loop dynamic scroll cursor for
> execute immediate v_sql;
> do
> set v_id_stream = v_id_stream || v_employee_id || '/' end
> for;
>
> Thanks for any response.


Mark Mikulecky Posted on 2004-08-27 14:51:37.0Z
Sender: 50d6.412f4a44.1804289383@sybase.com
From: Mark Mikulecky
Newsgroups: ianywhere.public.general
Subject: Re: Execute immediate and processing a result set
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <412f4a79.50f9.1681692777@sybase.com>
References: <412f322b$1@forums-1-dub>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 27 Aug 2004 07:51:37 -0700
X-Trace: forums-1-dub 1093618297 10.22.241.41 (27 Aug 2004 07:51:37 -0700)
X-Original-Trace: 27 Aug 2004 07:51:37 -0700, 10.22.241.41
Lines: 63
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3446
Article PK: 7351

Version is 8.0.2 (4322)

Thanks

> What version of ASA are you using?
>
> --
> -----------------------------------------------
> Robert Waywell
> Sybase Adaptive Server Anywhere Developer - Version 8
> Sybase Certified Professional
>
> Sybase's iAnywhere Solutions
>
> Please respond ONLY to newsgroup
>
> EBF's and Patches: http://downloads.sybase.com
> choose SQL Anywhere Studio >> change 'time frame' to all
>
> To Submit Bug Reports:
>
http://case-express.sybase.com/cx/cx.stm?starturl=casemessage.ssc?CASETYPE=B
> ug
>
> SQL Anywhere Studio Supported Platforms and Support Status
> http://my.sybase.com/detail?id=1002288
>
> Whitepapers, TechDocs, and bug fixes are all available
> through the iAnywhere Developer Community at
> www.ianywhere.com/developer
>
> <Mark Mikulecky> wrote in message
> news:412e6d6b.6b7a.1681692777@sybase.com...
> > I created a procedure and I have a dynamic sql statement
> > that
> > returns results. I need to be able to loop through those
> > results.
> > I'm having trouble finding documentation on how to do it
> >
> > My normal code non-Execute Immediate
> > (just the specific portion giving me trouble)
> >
> > v_id_stream = '';
> > for forloop as this_loop dynamic scroll cursor for
> > select employee_id as v_employee_id from employee do
> > set v_id_stream = v_id_stream || v_employee_id || '/'
> > end for;
> >
> > how do i do the above with Excecute immediate?
> > my guess that does not work is below.
> >
> > v_sql = 'select employee_id as v_employee_id from
> > employee';
> > v_id_stream = '';
> > for forloop as this_loop dynamic scroll cursor for
> > execute immediate v_sql;
> > do
> > set v_id_stream = v_id_stream || v_employee_id || '/'
> > end for;
> >
> > Thanks for any response.
>
>


Robert Waywell Posted on 2004-08-30 13:36:22.0Z
From: "Robert Waywell" <nospam_rwaywell@ianywhere.com>
Newsgroups: ianywhere.public.general
References: <412f322b$1@forums-1-dub> <412f4a79.50f9.1681692777@sybase.com>
Subject: Re: Execute immediate and processing a result set
Lines: 94
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: rwaywell-pc.sybase.com
X-Original-NNTP-Posting-Host: rwaywell-pc.sybase.com
Message-ID: <41332d56$1@forums-1-dub>
Date: 30 Aug 2004 06:36:22 -0700
X-Trace: forums-1-dub 1093872982 10.25.100.118 (30 Aug 2004 06:36:22 -0700)
X-Original-Trace: 30 Aug 2004 06:36:22 -0700, rwaywell-pc.sybase.com
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3459
Article PK: 7365

One approach is to have the EXECUTE IMMEDIATE do a SELECT ... INTO
#temp_table_name and then you can open a cursor on the temp table.

--
-----------------------------------------------
Robert Waywell
Sybase Adaptive Server Anywhere Developer - Version 8
Sybase Certified Professional

Sybase's iAnywhere Solutions

Please respond ONLY to newsgroup

EBF's and Patches: http://downloads.sybase.com
choose SQL Anywhere Studio >> change 'time frame' to all

To Submit Bug Reports:
http://case-express.sybase.com/cx/cx.stm?starturl=casemessage.ssc?CASETYPE=B
ug

SQL Anywhere Studio Supported Platforms and Support Status
http://my.sybase.com/detail?id=1002288

Whitepapers, TechDocs, and bug fixes are all available through the iAnywhere
Developer Community at www.ianywhere.com/developer

<Mark Mikulecky> wrote in message
news:412f4a79.50f9.1681692777@sybase.com...
> Version is 8.0.2 (4322)
>
> Thanks
>
> > What version of ASA are you using?
> >
> > --
> > -----------------------------------------------
> > Robert Waywell
> > Sybase Adaptive Server Anywhere Developer - Version 8
> > Sybase Certified Professional
> >
> > Sybase's iAnywhere Solutions
> >
> > Please respond ONLY to newsgroup
> >
> > EBF's and Patches: http://downloads.sybase.com
> > choose SQL Anywhere Studio >> change 'time frame' to all
> >
> > To Submit Bug Reports:
> >
>
http://case-express.sybase.com/cx/cx.stm?starturl=casemessage.ssc?CASETYPE=B
> > ug
> >
> > SQL Anywhere Studio Supported Platforms and Support Status
> > http://my.sybase.com/detail?id=1002288
> >
> > Whitepapers, TechDocs, and bug fixes are all available
> > through the iAnywhere Developer Community at
> > www.ianywhere.com/developer
> >
> > <Mark Mikulecky> wrote in message
> > news:412e6d6b.6b7a.1681692777@sybase.com...
> > > I created a procedure and I have a dynamic sql statement
> > > that
> > > returns results. I need to be able to loop through those
> > > results.
> > > I'm having trouble finding documentation on how to do it
> > >
> > > My normal code non-Execute Immediate
> > > (just the specific portion giving me trouble)
> > >
> > > v_id_stream = '';
> > > for forloop as this_loop dynamic scroll cursor for
> > > select employee_id as v_employee_id from employee do
> > > set v_id_stream = v_id_stream || v_employee_id || '/'
> > > end for;
> > >
> > > how do i do the above with Excecute immediate?
> > > my guess that does not work is below.
> > >
> > > v_sql = 'select employee_id as v_employee_id from
> > > employee';
> > > v_id_stream = '';
> > > for forloop as this_loop dynamic scroll cursor for
> > > execute immediate v_sql;
> > > do
> > > set v_id_stream = v_id_stream || v_employee_id || '/'
> > > end for;
> > >
> > > Thanks for any response.
> >
> >


"Bruce Hay" <h_a_y Posted on 2004-09-01 20:16:56.0Z
From: "Bruce Hay" <h_a_y@i~a~n~y~w~h~e~r~e.com>
Newsgroups: ianywhere.public.general
References: <412e6d6b.6b7a.1681692777@sybase.com>
Subject: Re: Execute immediate and procession a result set
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: hay-t30.sybase.com
X-Original-NNTP-Posting-Host: hay-t30.sybase.com
Message-ID: <41362e38$1@forums-1-dub>
Date: 1 Sep 2004 13:16:56 -0700
X-Trace: forums-1-dub 1094069816 10.25.99.98 (1 Sep 2004 13:16:56 -0700)
X-Original-Trace: 1 Sep 2004 13:16:56 -0700, hay-t30.sybase.com
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:3478
Article PK: 7384

Another solution is:
select list(employee_id,'/') into v_id_stream from employee

<Mark Mikulecky> wrote in message
news:412e6d6b.6b7a.1681692777@sybase.com...
> I created a procedure and I have a dynamic sql statement
> that
> returns results. I need to be able to loop through those
> results.
> I'm having trouble finding documentation on how to do it
>
> My normal code non-Execute Immediate
> (just the specific portion giving me trouble)
>
> v_id_stream = '';
> for forloop as this_loop dynamic scroll cursor for
> select employee_id as v_employee_id from employee do
> set v_id_stream = v_id_stream || v_employee_id || '/' end
> for;
>
> how do i do the above with Excecute immediate?
> my guess that does not work is below.
>
> v_sql = 'select employee_id as v_employee_id from
> employee';
> v_id_stream = '';
> for forloop as this_loop dynamic scroll cursor for
> execute immediate v_sql;
> do
> set v_id_stream = v_id_stream || v_employee_id || '/' end
> for;
>
> Thanks for any response.