Thread: Dynamic SQL Statements
04-28-04, 13:16 #1Registered User
- Join Date
- Nov 2003
Unanswered: Dynamic SQL Statements
I'm trying to write a procedure which accepts several optional variables, including some which are of a table type.
It the generates dynamic sql for each of the variables that are passed and runs the SQL.
In the case of recieving values in the table types, I need to find a way to bind the variables to get a nice simple dynamic query. Example :
procedure my proc (
list type_table (which is one column of a number type)
create the from & where clause dynamically which would include something like the following:
...AND VALUES in (listvalue1, listvalue2, listvalue3)
(listvalue[1,2,3] would be the 3 values inside the "list" table)
I've heard about session temporary tables, is this the best solution?
Hope that explanation is clear (as mud?!)
Any help or suggestions would be great.
04-28-04, 13:21 #2Registered User
Provided Answers: 1
- Join Date
- Aug 2003
- Where the Surf Meets the Turf @Del Mar, CA
My initial reaction is that the proposed 'design' is HORRIBLE & won't scale.
What problem are you really trying to solve?
The only legitimate use of dynamic SQL is for DDL &
should be avoided for any and all DML statements.You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Good judgement comes from experience. Experience comes from bad judgement.