Results 1 to 2 of 2

Thread: Bind Variables

  1. #1
    Join Date
    Aug 2003
    Posts
    1

    Bind Variables

    What is an Oracle Bind Variable , how they are used in database as well as from Middle tier apps. Advantages and disadvantages of Bind Variables.

    Thank You

  2. #2
    Join Date
    Mar 2003
    Posts
    468
    basically a bind variable is a holding position for a value you want to introduce in a where clause for a SQL statement.

    instead of in your code having something like:
    EXECUTE IMMEDIATE 'SELECT FROM emp WHERE empno = ' || TO_CHAR(emp_id);

    you can have
    EXECUTE IMMEDIATE 'SELECT FROM emp WHERE empno = :num' USING emp_id;
    where emp_id is a variable.

    in the first example the select statement is hard-coded with the emp_id and is parsed everytime a new emp_id is given.

    in the second example there is only one parse for the sql statement (if it hasn't been aged out of memory) and therefore the time to execute is quicker.

    the only disadvantage to bind variables is that they can sometimes have a different access path then the hard-coded value sql statment which may cause problems.

Posting Permissions

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