Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Posts
    13

    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 (
    text varchar;
    number integer;
    list type_table (which is one column of a number type)

    <snip>

    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.
    Thanks

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •