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.

dynamic select

3 posts in Product Futures Discussion Last posting was on 2002-06-12 17:04:06.0Z
Anna Posted on 2002-06-12 16:52:56.0Z
From: Anna
Date: Wed, 12 Jun 2002 12:52:56 -0400
Newsgroups: sybase.public.ase.product_futures_discussion
Subject: dynamic select
Message-ID: <792A1A65412D18D5005CBC9685256BD6.005CBCB785256BD6@webforums>
Lines: 6
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com!webforums.sybase.com!news
Xref: forums-1-dub sybase.public.ase.product_futures_discussion:454
Article PK: 93624

Can we make select in stored procedures dynamic. I mean column names can
be variable and where clause can be passed as an argument and then added in
the select inside the stored proc. Not sure if this makes sense but I'm
always confronted with the need to extend my where clause dynamically
depending on the filters that the users want to apply and the process is
too complicated to do in dw.


Stefan Karlsson Posted on 2002-06-12 17:04:06.0Z
From: "Stefan Karlsson" <Stefan.Karlsson@Sybase.justsaynotospam.com>
References: <792A1A65412D18D5005CBC9685256BD6.005CBCB785256BD6@webforums>
Subject: Re: dynamic select
Date: Wed, 12 Jun 2002 10:04:06 -0700
Lines: 17
Organization: Sybase, Inc.
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4807.1700
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Message-ID: <q0QdSTjECHA.299@forums.sybase.com>
Newsgroups: sybase.public.ase.product_futures_discussion
NNTP-Posting-Host: 10.22.90.199
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.ase.product_futures_discussion:452
Article PK: 93620

Have you looked at execute ("<string>") ? See
http://download.sybase.com/pdfdocs/asg1250e/refman2.pdf for details.

HTH,

/Stefan

<Anna> wrote in message
news:792A1A65412D18D5005CBC9685256BD6.005CBCB785256BD6@webforums...
> Can we make select in stored procedures dynamic. I mean column names can
> be variable and where clause can be passed as an argument and then added
in
> the select inside the stored proc. Not sure if this makes sense but I'm
> always confronted with the need to extend my where clause dynamically
> depending on the filters that the users want to apply and the process is
> too complicated to do in dw.


Carl Kayser Posted on 2002-06-12 17:01:47.0Z
From: "Carl Kayser" <kayser_c@bls.gov>
References: <792A1A65412D18D5005CBC9685256BD6.005CBCB785256BD6@webforums>
Subject: Re: dynamic select
Date: Wed, 12 Jun 2002 13:01:47 -0400
Lines: 26
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4133.2400
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Message-ID: <pu87LRjECHA.70@forums.sybase.com>
Newsgroups: sybase.public.ase.product_futures_discussion
NNTP-Posting-Host: 146.142.35.25
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.ase.product_futures_discussion:453
Article PK: 93622

If I understand the question correctly, "Sure". The limitation exists with
passing the table/column/where arguments to the stored procedure. Gluing
the stuff together can be done so long as you are on 12.0 or later.

create proc get_a_bunch_of_stuff (@column1 varchar (30),
@column2 varchar (30)
= NULL,
.....
@where_clause varchar
(255)) as
.....
execute ('select ' + @column1 ...... + ' where ' + @where_clause)
go

<Anna> wrote in message
news:792A1A65412D18D5005CBC9685256BD6.005CBCB785256BD6@webforums...
> Can we make select in stored procedures dynamic. I mean column names can
> be variable and where clause can be passed as an argument and then added
in
> the select inside the stored proc. Not sure if this makes sense but I'm
> always confronted with the need to extend my where clause dynamically
> depending on the filters that the users want to apply and the process is
> too complicated to do in dw.