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 > Sybase > Cannot use procedures paramaters dynamically

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-21-11, 07:58
alirulez999 alirulez999 is offline
Registered User
 
Join Date: Jan 2010
Posts: 25
Cannot use procedures paramaters dynamically

I want to gets the values of all the parameters inside the procs.
but want to do this dynamically.
What I am doing over here is that I fetches all the parameters for a particular proc using syscolumns table

for e.g.
declare @sqlstring varchar(255)
select @sqlstring = name
from syscolumns c
where c.id = object_id('TTG_FuturesDeals') and
colid=16

EXEC("SELECT " +@sqlstring)


This is an example for just one parameter.
Unfortunately its throwing me an error: Parameter must be declare.
Any help will be appreciated.
Reply With Quote
  #2 (permalink)  
Old 02-23-11, 11:02
farhy farhy is offline
Registered User
 
Join Date: Aug 2010
Posts: 19
the problem with your code is, that the result
of @sqlstring would be "select uid"
which is not a valid sql statement, you would need
eg select 'uid'

Maybe you try the follwing:

declare @sqlstring varchar(255)
,@sqlstmt varchar (500)



select top 1 @sqlstring = name
from syscolumns c


SET @sqlstmt = 'select '''+@sqlstring +'''' -- as it is a varchar you have to double qute it
print @sqlstmt

EXEC(@sqlstmt)

-- even this will work:
EXEC('select '''+@sqlstring +'''')
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