Using bind variables with dynamic SELECT INTO clause in PL/SQL

前端 未结 5 1381
深忆病人
深忆病人 2020-12-01 02:30

I have a question regarding where bind variables can be used in a dynamic SQL statement in PL/SQL.

For example, I know that this is valid:

CREATE OR          


        
5条回答
  •  星月不相逢
    2020-12-01 03:31

    Bind variable can be used in Oracle SQL query with "in" clause.

    Works in 10g; I don't know about other versions.

    Bind variable is varchar up to 4000 characters.

    Example: Bind variable containing comma-separated list of values, e.g.

    :bindvar = 1,2,3,4,5

    select * from mytable
      where myfield in
        (
          SELECT regexp_substr(:bindvar,'[^,]+', 1, level) items
          FROM dual
          CONNECT BY regexp_substr(:bindvar, '[^,]+', 1, level) is not null
        );
    

    (Same info as I posted here: How do you specify IN clause in a dynamic query using a variable? )

提交回复
热议问题