Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Sybase > Re: How to get ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 2484 of 2515
Post > Topic >>

Re: How to get around a stored procedure returning a datasset that runs a ?dynamic sql which changes the number (and names of) columns

by Luc <dba_azvub@[EMAIL PROTECTED] > Jun 4, 2008 at 11:15 AM

Is this ASA syntax ?




eahofer4groupposting@[EMAIL PROTECTED]
 wrote:
> Given the following sql:-
> 
> create procedure sp2 (in @[EMAIL PROTECTED]
 integer)
> begin
>  declare @[EMAIL PROTECTED]
 varchar(100);
>  if @[EMAIL PROTECTED]
 = 1 then
>    set @[EMAIL PROTECTED]
 = 'select 1 as a '
>  else
>    set @[EMAIL PROTECTED]
 = 'select 2 as b, 3 as c '  //ATTEMPT 1
>    //ATTEMPT 2 set @[EMAIL PROTECTED]
 = 'select 4 as b'
>  end if;
>  execute immediate with results on @[EMAIL PROTECTED]
> end
> 
> On execution, one gets the following results:-
> call sp(1) //works, get column labelled "a" and 1
> call sp(2) //fails
> 
> Revise the sql, commenting out ATTEMPT 1 and enabling ATTEMPT2
> call sp(1) // works
> call sp(2) // works, BUT the column name is "a" not b.
> 
> Now, what I'm wanting to do is change the result set...  I know that
> if I have some sort of trigger to call a different result set, I can
> have 2 different results - but the column titles still don't change.
> 
> I've tried this in SP and TRANSACT dialects; I've tried putting the
> values into a temp result set; I've tried deleting the #temp table ...
> 
> How do I get this to work so that I can vary the number of columns and
> their labels?
 




 2 Posts in Topic:
How to get around a stored procedure returning a datasset that r
eahofer4groupposting@[EMA  2008-06-03 03:36:27 
Re: How to get around a stored procedure returning a datasset th
Luc <dba_azvub@[EMAIL   2008-06-04 11:15:35 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Aug 21 21:52:12 CDT 2008.