Declare bind variables

Hi All,
I have one application(Java) in which the front end sends a list of values to backend(Oracle). The issue is i dont know how many number of parameters(values) would be there, it depends all on front end. But i want these values in my backend processing and want to use them as bind variables, so that i can build dynamic sqls and make dynamic calls.
Is there any way that i can declare all the values what i get from front end as bind variables so that they would be available for that user session and the backend can directly refer them as a normal variable, without referring to any other object.
Thanks in advance.

Dear,
Thanks for your answer, but the problem here is how to declare those variables ? if i declare them in a store procedure they would be local to that procedure and wont be available as bind variables.No.
When using PL/SQL (static SQL) you will never encounter issues related to bind variables. PL/SQL itself takes care of yourcode and uses bind variables behind the scene.
So, if you declare your variables inside a stored procedure, they will be automatically considered as bind variables. You don't have to care about. This is how PL/SQL (static SQL) works.
The only situation where you have to look carefully to the use of bind variable within PL/SQL is when you use Dynamic sql into stored procedures or functions (this is in fact another reason to avoid using dynamic SQL).
However, you need take care of the application which is calling your stored procedure. This calling application should call your stored procedure using input parameters as bind variables.
Otherwise, the library cache of your shared pool will be full of calls to your stored procedure.
Put it simply,
(a) do what you want inside your PL/SQL strored procedure (static SQL and not Dynamic SQL)
(b) call your stored procedure using bind variables
Hope this helps
Mohamed Houri

Similar Messages

  • How to declare bind variable in package

    hi,
    i have created one package with insert and returning the value in procedure using bind variable.
    -- spec part.
    SET SERVEROUTPUT ON
    VARIABLE id NUMBER
    CREATE OR REPLACE PACKAGE pack_sale AS
    PROCEDURE pro_insert_SOHeader (
    SO_HEADER_ID NUMBER,
    SO_NO VARCHAR2,
    SO_TYPE VARCHAR2,
    SO_APPROVED_FLAG VARCHAR2,
    SO_DATE DATE,
    CUST_HEADER_ID NUMBER);
    END pack_sale;
    -- body part
    CREATE OR REPLACE PACKAGE BODY pack_sale AS
    PROCEDURE pro_insert_SOHeader (
    SO_HEADER_ID NUMBER,
    SO_NO VARCHAR2,
    SO_TYPE VARCHAR2,
    SO_APPROVED_FLAG VARCHAR2,
    SO_DATE DATE,
    CUST_HEADER_ID NUMBER) IS
    BEGIN
    INSERT INTO SO_Header VALUES (SEQ_SOHEADER.NEXTVAL,SO_NO,SO_TYPE,SO_APPROVED_FLAG,SO_DATE,CUST_HEADER_ID)
    RETURNING SEQ_SOHEADER.CURRVAL INTO :id;
    COMMIT;
    END pro_insert_SOHeader;
    END pack_sale;
    I have run this package in sql*plus,it will return the warning message like
    PLS-00049: bad bind variable 'ID'.
    i do not know how to rectify this error
    and how to execute this procedure in sql*plus.
    please help me...

    hi,
    when i was running the body script the error is displayed in
    sql*plus like
    SQL> @"D:\Viji Share\ex_body"
    SP2-0042: unknown command "" - rest of line ignored.
    15 /
    Warning: Package Body created with compilation errors.
    SQL> show error
    Errors for PACKAGE BODY PACK_SALE:
    LINE/COL ERROR
    11/30 PLS-00049: bad bind variable 'ID'

  • Declaring bind variables using decimals

    I'm on Oracle 11.2
    In SQL Developer, I'm having hard time executing a SQL with a bind variable. Below is the test table.
    create table TEST1 (TYP varchar2(3), NUM number(30,18)); 
    insert into TEST1 values ('TTT', 45.15168794137111); 
    commit; 
    Then I execute the below query and it returns no results. Why?
    VARIABLE P1 number; 
    EXEC :P1 := 45.15168794137111; 
    select * from TEST1 where NUM = :P1; 
    The above works in SQL Plus.

    That replaces the SQL before it executes it. It is just like using literals. I wanted to use bind variables for performance testing purposes.
    See the sql developer documentation:
    http://docs.oracle.com/cd/E10405_01/doc/appdev.120/e10406.pdf
    Run Script executes all statements in the Enter SQL Statement box using the Script
    Runner. The SQL statements can include substitution variables (but not bind
    variables) of type VARCHAR2 (although in most cases, VARCHAR2 is
    automatically converted internally to NUMBER if necessary); a pop-up box is
    displayed for entering substitution variable values.
    Notice the 'but not bind variables'

  • Bind variable inside a package

    Can we declare a bind variable inside a package specification?
    CREATE OR REPLACE PACKAGE GET_EMPLOYEEDETAILS
    IS
    PROCEDURE GET_FIRSTNAME(E_ID IN EMPLOYEES.EMPLOYEE_ID%TYPE, F_NAME OUT EMPLOYEES.FIRST_NAME%TYPE);
    VARIABLE O VARCHAR2(20);
    END GET_EMPLOYEEDETAILS ;
    CREATE OR REPLACE PACKAGE BODY GET_EMPLOYEEDETAILS
    IS
    PROCEDURE GET_FIRSTNAME(E_ID IN EMPLOYEES.EMPLOYEE_ID%TYPE, F_NAME OUT EMPLOYEES.FIRST_NAME%TYPE)
    IS
    BEGIN
    SELECT FIRST_NAME INTO F_NAME FROM EMPLOYEES WHERE EMPLOYEE_ID = E_ID;
    DBMS_OUTPUT.PUT_LINE(F_NAME);
    END;
    END GET_EMPLOYEEDETAILS;
    Output:
    ERROR at line 4: PLS-00103: Encountered the symbol "VARCHAR2" when expecting one of the following:
      := . ( @ % ; not null range default character
    The symbol ":=" was substituted for "VARCHAR2" to continue.
    2. IS
    3. PROCEDURE GET_FIRSTNAME(E_ID IN EMPLOYEES.EMPLOYEE_ID%TYPE, F_NAME OUT EMPLOYEES.FIRST_NAME%TYPE);
    4. VARIABLE O VARCHAR2(20);
    5. END GET_EMPLOYEEDETAILS ;
    6. /
    or is there any alternative for bind variables inside an package
    Thanks in advance
    Message was edited by: 1009739

    The "VARIABLE O VARCHAR2(20);" syntax is the way SQLPlus declared bind variables - it is specific to the client. Because PL/SQL packages and procedures are server code that continue past sessions, its only access to the client environment is what the client gives it - it can't go and create a bind variable in the client.
    PL/SQL procedures, functions and packages run from lots of environments, so they cannot access bind variables inside their body - you have to pass any external variables as parameters.
    Anonymous PL/SQL blocks can access bind variables.
    You can declare package public global variables - just leave out that "VARIABLE". E.g.
    CREATE OR REPLACE PACKAGE GET_EMPLOYEEDETAILS
    IS
    PROCEDURE GET_FIRSTNAME(E_ID IN EMP.EMPNO%TYPE, F_NAME OUT EMP.ENAME%TYPE);
    O VARCHAR2(20);
    END GET_EMPLOYEEDETAILS ;
    For local variables in your procedure, just put them between the IS and BEGIN. Using them in SQL inside the PL/SQL automatically uses them as a bind variable.
    create or replace PROCEDURE GET_FIRSTNAME(E_ID IN EMP.EMPNO%TYPE, F_NAME OUT EMP.ENAME%TYPE)
    IS
      O VARCHAR2(20);
      O2 VARCHAR2(21);
    BEGIN
      O := 'FR%';
    SELECT ENAME INTO F_NAME FROM EMP WHERE EMPNO = E_ID and ENAME like O;
    O2 := F_NAME || '2';
    DBMS_OUTPUT.PUT_LINE(F_NAME);
    END;
    O is bound in the query.
    To access bind variables from anonymous PL/SQL, first declare them in the calling environment. In SQL Plus that's
    VARIABLE O VARCHAR2(20);
    In Pro*C it's
    EXEC SQL BEGIN DECLARE SECTION;
      char[21] O
    EXEC SQL END DECLARE SECTION;
    Then reference it in anonymous PL/SQL with a colon as prefix:
    BEGIN
    SELECT FIRST_NAME INTO :O FROM EMPLOYEES WHERE EMPLOYEE_ID = E_ID;
    END;
    This only works for anonymous blocks (starting with BEGIN or DECLARE). As I said, PL/SQL procedures, functions and packages cannot see bind variables from the calling environment

  • Bind Variable popup when no bind variable declared

    I am writing a fairly complex SQL (FYI, I want to keep this all in one step and not split out with multiple sub-selects) and I am getting the bind variable popup and an error message ("The requested URL /apex/wwv_flow.show was not found on this server ") and I am not sure why and could definitely use some help. From what I see there is no issue with the SQL syntax written and when I try to break it down, everything goes well until the point where I write a case statement with an OR and checking for 'BLOCK'.
    The issue comes when using the bolded line.
    I am using "10g Release 2 (10.2)" and querying from the SQL commands area inside it.
    The goal is to identify the area of the court broken down by the x and y dimension, home and away team has different logic to be used and if it is a block there is different logic.
    Your help would be greatly appreciated, and I am leaning towards it is a bug in the SQL Commands section of the tool:
    The full query is below:
    case when E.YEAR IS NOT NULL then
    *(case when x_dimension < 12.5 then 'A' when x_dimension <= 25 then 'B' when x_dimension < 37.5 then 'C' else 'D' end ||*
    case when ((a.action_team=c.awayname3 and A.ACTION_TYPE = 'BLOCK') or (a.action_team=c.homename3 and A.ACTION_TYPE <> 'BLOCK')) then (case when y_dimension < 9.5 then '4' when y_dimension <= 19 then '3' when y_dimension < 28.5 then '2' when y_dimension <= 38 then '1' else '0' end) else (case when y_dimension > 84.5 then '4' when y_dimension >= 75 then '3' when y_dimension < 65.5 then '2' when y_dimension <= 56 then '1' else '0' end) end) else 'NA' end as COURT_LOC
    It would not allow to enter the full SQL but please know that there is no issue with any declaration of the columns.
    Edited by: user10615520 on Feb 29, 2012 10:29 AM
    It seems that it is an issue with the in house SQL client of XE as I downloaded SQL Developer and ran same query there and the result was no issues. Is anyone aware of a bug for something like this?
    Edited by: user10615520 on Feb 29, 2012 10:43 AM

    So I am running Oracle Database Express version 10g. When you login through the default web interface, there is a SQL command line option. When I utilize the SQL below, can't insert whole SQL statement for some reason it won't let me, in that SQL command line I get a pop up window asking about values for bind variables... But as you can see from the code below there is no declaration of a bind variable. I also get the error message from the original post.
    When I use the same query in Oracle SQL Developer, not express (mistake in previous note), the query runs without any issues.
    My question is if anyone is aware of the oracle database express sql command line module having a bug where this is occurring. When I remove the line below from the query it runs fine in the Oracle Database Express command line module.
    Thank you for your help, I hope this is clear.
    case when E.YEAR IS NOT NULL then
    (case when x_dimension < 12.5 then 'A' when x_dimension <= 25 then 'B' when x_dimension < 37.5 then 'C' else 'D' end ||
    case when ((a.action_team=c.awayname3 and A.ACTION_TYPE = 'BLOCK') or (a.action_team=c.homename3 and A.ACTION_TYPE <> 'BLOCK'))
    then
    (case when y_dimension < 9.5 then '4' when y_dimension <= 19 then '3' when y_dimension < 28.5 then '2' when y_dimension <= 38 then '1' else '0' end)
    else
    (case when y_dimension > 84.5 then '4' when y_dimension >= 75 then '3' when y_dimension < 65.5 then '2' when y_dimension <= 56 then '1' else '0' end)
    end) else 'NA' end as COURT_LOC

  • Bind variable not declared - please help

    Hello,
    I have wrote a PL/SQL script to update some order_id's in a table. I have declared all my variables but get an error -- bind variable not declared. Can anyone tell me what the problem might be?
    DECLARE
             last_ship      DATE ;
             last_order     NUMBER;
             last_cust      NUMBER;
    VARIABLE curr_item      NUMBER;
    VARIABLE curr_order     NUMBER;
             aorder_id      CHAR(6);
             aitem_id       CHAR(2);
             acust_id       NUMBER(6);
             aship_date     DATE;
    CURSOR c1 IS
          SELECT 
                  order_id,
                  item_id,
                  ship_date,
                  cust_id
          FROM
                  test_sales
          ORDER BY
                  1,2,3,4,5;
    BEGIN
          SELECT
                  MAX(order_id)
          INTO
                   curr_order
          FROM
                   sales_order;
    OPEN c1;
         LOOP
             FETCH c1 INTO aorder_id, aitem_id, aship_date, acust_id;
             EXIT WHEN c1%NOTFOUND;
               last_cust      := c1.cust_id;          -- Saves the last values to check if processing same order
               last_order     := c1.aorder_id;        --
               last_ship      := c1.aship_date;       --
               IF c1.aorder_id = last_order AND c1.cust_id = last_cust AND c1.ship_date = last_ship THEN
                  curr_item   := curr_item  +1;
                  UPDATE test_sales SET c1.aorder_id = :curr_order;
                  UPDATE test_sales SET c1.aitem_id  = :curr_item;
               ELSE
                  curr_order := curr_order + 1;
                  curr_item  := 1;
                  UPDATE test_sales SET c1.aorder_id =  :curr_order;
                  UPDATE test_sales SET c1.aitem_id  = :curr_item;
               END IF; 
        END LOOP;
    CLOSE c1;
    END;
    /Cheers
    Mike

    check yours code you are direct accesing cusrsor named directly which is not allowed
      1  DECLARE
      2  vemp  emp.empno%TYPE;
      3  vemp1 emp.empno%TYPE;
      4  CURSOR c1 IS SELECT empno FROM emp;
      5  BEGIN
      6   OPEN c1;
      7    LOOP
      8     FETCH c1 INTO vemp;
      9     EXIT WHEN c1%NOTFOUND;
    10     vemp1:=c1.empno;
    11    END LOOP;
    12   CLOSE c1;
    13* END;
    SQL> /
       vemp1:=c1.empno;
    ERROR at line 10:
    ORA-06550: line 10, column 14:
    PLS-00225: subprogram or cursor 'C1' reference is out of scope
    ORA-06550: line 10, column 4:
    PL/SQL: Statement ignored
    SQL> DECLARE
      2  vemp emp.empno%TYPE;
      3  CURSOR c1 IS SELECT empno FROM emp;
      4  BEGIN
      5   OPEN c1;
      6    LOOP
      7     FETCH c1 INTO vemp;
      8     EXIT WHEN c1%NOTFOUND;
      9    END LOOP;
    10   CLOSE c1;
    11  END;
    12  .
    SQL> /
    PL/SQL procedure successfully completed.Yours code
    OPEN c1;
    LOOP
    FETCH c1 INTO aorder_id, aitem_id, aship_date, acust_id;
    EXIT WHEN c1%NOTFOUND;
    last_cust:= c1.cust_id;
    last_order:= c1.aorder_id;
    END LOOP;
    CLOSE c1;
    END;You sholud move it c1.cust_id within fetch statment or
    bind the cursor name with another local cursor variable
    then fetch into this local bind variable and use cursor
    via this variable
    e.g
    DECLARE
    CUSRSOR c1 IS SELECT cust_id,aorderid
        FROM <TABLE>;
    c2      c1%ROWTYPE;
    OPEN c1;
    LOOP
    FETCH c1 INTO c2;
    aorder_id:=c2.aorderid;
    last_cust:= c1.cust_id;
    last_order:= c1.aorder_id;
    END LOOP;
    CLOSE c1;
    END;Khurram

  • Varray of Objects "Bind variable not declared" error.. I don't want a bind variable.

    Hello.
    This program is supposed to pull values from a table using a loop, and in the loop, put the values in objects in a varray.  I'm new to objects and am stumped trying to get this program to run.  When I attempt to run it in SQL*Plus  I get the following feedback:
    Type created.
    Type body created
    SP2-0552: Bind variable "MY_VARRAY_EMP1" not declared.
    I don't think I even need a bind variable.  Any feedback would be appreciated.  Here's the program:
    -- Enable screen I/O
    SET SERVEROUTPUT ON SIZE 1000000
    SET VERIFY OFF
    -- begin object spec
    CREATE OR REPLACE TYPE employee3 AS OBJECT
      ename CHAR (20 char),
      empno NUMBER (4),
      sal NUMBER (10),
      MEMBER FUNCTION get_ename RETURN CHAR, MEMBER PROCEDURE set_ename (SELF IN OUT NOCOPY employee3),
      MEMBER FUNCTION get_empno RETURN NUMBER, MEMBER PROCEDURE set_empno (SELF IN OUT NOCOPY employee3),
      MEMBER FUNCTION get_sal RETURN NUMBER, MEMBER PROCEDURE set_sal (SELF IN OUT NOCOPY employee3)
    -- begin object body
    CREATE OR REPLACE TYPE BODY employee3 AS
      -- gets
      MEMBER FUNCTION get_ename RETURN CHAR IS
      BEGIN
      RETURN self.ename;
      END;
      MEMBER FUNCTION get_empno RETURN NUMBER IS
      BEGIN
      RETURN self.empno;
      END;
      MEMBER FUNCTION get_sal RETURN NUMBER IS
      BEGIN
      RETURN self.ename;
      END;
      -- sets
      MEMBER PROCEDURE set_ename(SELF IN OUT employee3) IS
      BEGIN
      self.ename := ename;
      END;
      MEMBER PROCEDURE set_empno(SELF IN OUT employee3) IS
      BEGIN
      self.empno := empno;
      END;
      MEMBER PROCEDURE set_sal(SELF IN OUT employee3) IS
      BEGIN
      self.sal := sal;
      END;
    END;
    DECLARE
      TYPE emp_varray IS VARRAY(10) OF EMPLOYEE3;
      my_varray_emp1 EMP_VARRAY;
      -- List of EMPNO's in order of appearance in EMP table (for cross-referencing, single-line retrieval)
      TYPE MYCREF_VARRAY IS VARRAY(10) OF NUMBER(4);
      varray_mycref MYCREF_VARRAY := MYCREF_VARRAY(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
      this_object EMPLOYEE3;
      -- make a variable to store one empno
      thisno NUMBER(4);
      -- make a counter
      counter INT;
      -- query variables for the set calls
      q_ename CHAR(20 CHAR);
      q_empno NUMBER(4);
      q_sal NUMBER(10);
      my_result INT;
    BEGIN
      --my_varray_emp1 := EMP_VARRAY(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
      -- Put the first 10 EMPNO's in my cref array
      SELECT empno BULK COLLECT INTO varray_mycref FROM emp WHERE ROWNUM < 11;
      -- Use a loop to retrieve the first 10 objects in the "emp" table and put them in the varray of objects
      q_ename := NULL;
      q_empno := NULL;
      q_sal := NULL;
      my_result := NULL;
      this_object := NULL;
      counter := 1;
      FOR counter IN 1..10 LOOP
      thisno := varray_mycref(counter);
      this_object := my_varray_emp1(counter);
      SELECT ename INTO q_ename FROM emp WHERE empno = thisno;
      my_result := this_object.set_ename(q_ename, NULL);
      SELECT empno INTO q_empno FROM emp WHERE empno = thisno;
      my_result := this_object.set_empno(q_empno, NULL);
      SELECT sal INTO q_sal FROM emp WHERE empno = thisno;
      my_result := this_object.set_sal(q_sal, NULL);
      END LOOP;
      -- Use another loop to display the information in the reverse order.
      FOR counter in REVERSE 1..10 LOOP
      this_object =: my_varray_emp1(counter);
      dbms_output.put_line((this_object.get_ename()) || CHR(9) || (this_object.get_empno()) || CHR(9) || (this_object.get_sal()));
      END LOOP;
    END;

    Cleaning up your code for errors and eliminating unnecessary complexity...
    Add a user-defined constructor which takes all attributes and calls the "setter" procedures in one trip:
    -- Enable screen I/O
    set SERVEROUTPUT on size 1000000
    set VERIFY off
    -- begin object spec
    create or replace type employee3 as object
      ename CHAR (20 char),
      empno NUMBER (4),
      sal NUMBER (10),
    constructor function employee3(
        self    in out nocopy    employee3,
        aEname    in        char,
        aEmpNo    in        integer,
        aSal    in        number
      return self as result,
      member function get_ename return CHAR, member procedure set_ename (SELF in out nocopy employee3, ename in char),
      member function get_empno return NUMBER, member procedure set_empno (SELF in out nocopy employee3, empno in integer),
      member function get_sal return NUMBER, member procedure set_sal (SELF in out nocopy employee3, sal in integer)
    -- begin object body
    create or replace type body employee3 as
      constructor function employee3(
        self    in out nocopy    employee3,
        aEname    in        char,
        aEmpNo    in        integer,
        aSal    in        number
      return self as result
      is
      begin
        self.set_ename(aEname);
        self.set_empno(aEmpNo);
        self.set_sal(aSal);
        return;
      end;
      -- gets
      member function get_ename return CHAR is
      begin
      return self.ename;
      end;
      member function get_empno return NUMBER is
      begin
      return self.empno;
      end;
      member function get_sal return NUMBER is
      begin
      return self.sal;
      end;
      -- sets
      member procedure set_ename(SELF in out employee3, ename in char) is
      begin
      self.ename := ename;
      end;
      member procedure set_empno(SELF in out employee3, empno in integer) is
      begin
      self.empno := empno;
      end;
      member procedure set_sal(SELF in out employee3, sal in integer) is
      begin
      self.sal := sal;
      end;
    end;
    (Since I don't have EMP handy at the moment, create a simple view instead)
    create or replace view emp
    as
    select    'EMP' || to_char(level) ename
    ,    level + 100 empno
    ,    DBMS_RANDOM.VALUE(25000,75000) sal
    from    DUAL
    connect by
        level <= 20
    Get rid of your loop and individual SELECTs, and replace it with a single SELECT BULK COLLECT INTO...
    declare
      type emp_varray is varray(10) of EMPLOYEE3;
      my_varray_emp1 EMP_VARRAY;
      this_object EMPLOYEE3;
    begin
      -- No need for a loop. Use SELECT BULK COLLECT INTO, together with a user-defined constructor call (since the
      -- user-defined constructor overrides the default constructor we need to call it using named-parameter notation):
      select    new employee3(
                aEname    => e.ename,
                aEmpNo    => e.empno,
                aSal    => e.sal
      bulk collect into
            my_varray_emp1
      from        emp e
      where        rownum <= 10;
      -- Use another loop to display the information in the reverse order.
      for counter in reverse 1..10 loop
      this_object := my_varray_emp1(counter);
      dbms_output.put_line((this_object.get_ename()) || chr(9) || to_char(this_object.get_empno()) || chr(9) || to_char(this_object.get_sal()));
      end loop;
    end;
    EMP10        
    110    60110
    EMP9         
    109    67485
    EMP8         
    108    58242
    EMP7         
    107    47597
    EMP6         
    106    58995
    EMP5         
    105    49098
    EMP4         
    104    47406
    EMP3         
    103    67574
    EMP2         
    102    59663
    EMP1         
    101    52929
    PL/SQL procedure successfully completed.
    Gerard

  • How to declare a bind variable with 'date' data type in command prompt?

    how to declare a bind variable with 'date' data type in command prompt?
    sql>variable q date;
    when i execute it show list of datatypes

    Hi,
    As Lokanath said, there are no DATE bind variables.
    You can use a VARCHAR2 bind variable, and convert it to a DATE in your SQL statment.
    If you're using SQL*Plus, consider a substitution variable. It won't be as efficient as a bind variable, but it will be as convenient.
    For example:
    DEFINE  first_entrry_date = "DATE '2010-06-20''
    SELECT   ...
    WHERE   entry_date >= &first_entry_date
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Bind variable not declared

    hi all
    declare jobno number;
    BEGIN
    DBMS_JOB.SUBMIT(:jobno,
    'proc_mvref;',
    SYSDATE, 'SYSDATE + 1');
    commit;
    END;
    when i run this statement,I get the follwing error.
    P2-0552: Bind variable "JOBNO" not declared.
    But I cannot locate the error.
    Thanks in Advance

    variable jobno number
    BEGIN
    DBMS_JOB.SUBMIT(:jobno,
    'proc_mvref;',
    SYSDATE, 'SYSDATE + 1');
    commit;
    END;
    print jobno
    Now it'll work.
    or
    set serveroutput on
    declare jobno number;
    BEGIN
    DBMS_JOB.SUBMIT(jobno, -- note the edit
    'proc_mvref;',
    SYSDATE, 'SYSDATE + 1');
    dbms_output.put_line(jobno);
    commit;
    END;
    This will work too...
    Sybrand Bakker

  • SP2-0552: Bind variable not declared

    Hi,
    I am using below bind values in a sql query.
    declare
    B1 number;
    B2 varchar2(10);
    B3 varchar2(10);
    B4 number;
    B5 date;
    B6 date;
    B7 varchar2(30);
    B8 number;
    B9 number;
    B10 varchar2(9);
    B11 number;
    Begin
    :B1 := 24152;
    :B2 := 'CR_CORP';
    :B3 := 'COST';
    :B4 := 24152;
    B5 := TO_DATE('01/29/12 23:20:34','MM/DD/YY HH24:MI:SS');
    B6 := TO_DATE('02/27/12 21:10:58','MM/DD/YY HH24:MI:SS');
    :B7 := 'BEGIN';
    :B8 := 945142827;
    :B9 := 483695;
    :B10 := 'CR_CORP';
    :B11 := 7;
    End;
    and even tried as below:
    declare
    variable B1 number;
    variable B2 varchar2(30);
    variable B3 varchar2(30);
    variable B4 number;
    B5 date;
    B6 date;
    variable B7 varchar2(30);
    variable B8 number;
    variable B9 number;
    variable B10 varchar2(30);
    variable B11 number;
    Begin
    :B1 := 24152;
    :B2 := 'CR_CORP';
    :B3 := 'COST';
    :B4 := 24152;
    B5 := TO_DATE('01/29/12 23:20:34','MM/DD/YY HH24:MI:SS');
    B6 := TO_DATE('02/27/12 21:10:58','MM/DD/YY HH24:MI:SS');
    :B7 := 'BEGIN';
    :B8 := 945142827;
    :B9 := 483695;
    :B10 := 'CR_CORP';
    :B11 := 7;
    End;
    Resulting in SP2-0552: Bind variable "B7" not declared.
    Kindly help!

    Try this:
    /* Formatted on 14-3-2012 12:02:31 (QP5 v5.163.1008.3004) */
    DECLARE
       B1             NUMBER;
       B2             VARCHAR2 (10);
       B3             VARCHAR2 (10);
       B4             NUMBER;
       B5             DATE;
       B6             DATE;
       B7             VARCHAR2 (30);
       B8             NUMBER;
       B9             NUMBER;
       B10            VARCHAR2 (9);
       B11            NUMBER;
    BEGIN
       B1          := 24152;
       B2          := 'CR_CORP';
       B3          := 'COST';
       B4          := 24152;
       B5          := TO_DATE ('01/29/12 23:20:34', 'MM/DD/YY HH24:MI:SS');
       B6          := TO_DATE ('02/27/12 21:10:58', 'MM/DD/YY HH24:MI:SS');
       B7          := 'BEGIN';
       B8          := 945142827;
       B9          := 483695;
       B10         := 'CR_CORP';
       B11         := 7;
    SELECT                                              /*+ USE_HASH(SUB_DD,BK) */
          DH.ASSET_ID,
           DH.CODE_COMBINATION_ID,
           NULL,
           DECODE (:B3,
                   'COST', CB.ASSET_COST_ACCT,
                   'CIP COST', CB.CIP_COST_ACCT,
                   'RESERVE', CB.DEPRN_RESERVE_ACCT,
                   'REVAL RESERVE', CB.REVAL_RESERVE_ACCT),
           DECODE (
              :B3,
              'RESERVE', DECODE (DD.DEPRN_SOURCE_CODE, 'D', :B7, 'ADDITION'),
              'REVAL RESERVE', DECODE (DD.DEPRN_SOURCE_CODE,
                                       'D', :B7,
                                       'ADDITION'),
              :B7),
           DECODE (:B3,
                   'COST', DD.COST,
                   'CIP COST', DD.COST,
                   'RESERVE', DD.DEPRN_RESERVE,
                   'REVAL RESERVE', DD.REVAL_RESERVE),
           :B11
      FROM FA_DEPRN_DETAIL DD,
           FA_DISTRIBUTION_HISTORY DH,
           FA_ASSET_HISTORY AH,
           FA_CATEGORY_BOOKS CB,
           FA_BOOKS BK,
           (  SELECT ASSET_ID, DISTRIBUTION_ID, MAX (PERIOD_COUNTER) MPC
                FROM FA_DEPRN_DETAIL
               WHERE BOOK_TYPE_CODE = :B2 AND PERIOD_COUNTER <= :B1
            GROUP BY ASSET_ID, DISTRIBUTION_ID) SUB_DD
    WHERE DH.BOOK_TYPE_CODE = :B10
           AND DECODE (DD.DEPRN_SOURCE_CODE, 'D', :B6, :B5) BETWEEN DH.DATE_EFFECTIVE
                                                                AND NVL (
                                                                       DH.DATE_INEFFECTIVE,
                                                                       SYSDATE)
           AND DD.ASSET_ID = DH.ASSET_ID
           AND DD.BOOK_TYPE_CODE = :B2
           AND DD.DISTRIBUTION_ID = DH.DISTRIBUTION_ID
           AND DD.PERIOD_COUNTER <= :B1
           AND DD.ASSET_ID BETWEEN :B9 AND :B8
           AND DECODE (:B3,
                       'CIP COST', DD.DEPRN_SOURCE_CODE,
                       DECODE (:B7, 'BEGIN', DD.DEPRN_SOURCE_CODE, 'D')) =
                  DD.DEPRN_SOURCE_CODE
           AND DD.PERIOD_COUNTER = SUB_DD.MPC
           AND DD.DISTRIBUTION_ID = SUB_DD.DISTRIBUTION_ID
           AND SUB_DD.ASSET_ID = DD.ASSET_ID
           AND AH.ASSET_ID = DD.ASSET_ID
           AND AH.ASSET_TYPE <> 'EXPENSED'
           AND DECODE (DD.DEPRN_SOURCE_CODE, 'D', :B6, :B5) BETWEEN AH.DATE_EFFECTIVE
                                                                AND NVL (
                                                                       AH.DATE_INEFFECTIVE,
                                                                       SYSDATE)
           AND CB.CATEGORY_ID = AH.CATEGORY_ID
           AND CB.BOOK_TYPE_CODE = DD.BOOK_TYPE_CODE
           AND BK.BOOK_TYPE_CODE = CB.BOOK_TYPE_CODE
           AND BK.ASSET_ID = DD.ASSET_ID
           AND DECODE (DD.DEPRN_SOURCE_CODE, 'D', :B6, :B5) BETWEEN BK.DATE_EFFECTIVE
                                                                AND NVL (
                                                                       BK.DATE_INEFFECTIVE,
                                                                       SYSDATE)
           AND NVL (BK.PERIOD_COUNTER_FULLY_RETIRED, :B1 + 1) > :B4
           AND DECODE (
                  :B3,
                  'COST', DECODE (AH.ASSET_TYPE,
                                  'CAPITALIZED', CB.ASSET_COST_ACCT,
                                  NULL),
                  'CIP COST', DECODE (AH.ASSET_TYPE,
                                      'CIP', CB.CIP_COST_ACCT,
                                      NULL),
                  'RESERVE', CB.DEPRN_RESERVE_ACCT,
                  'REVAL RESERVE', CB.REVAL_RESERVE_ACCT)
                  IS NOT NULL;
    END;
    /             HTH,
    Thierry

  • SP2-0552: Bind variable not declared error. Any help please?

    Hi Experts,
    I have a question regarding the error that I am getting: SP2-0552: Bind variable "V_COUNT_TOT_BAL" not declared.
    I have 'out' parameters declared in my procedure and executing the same from sql script as shown below:
    set ver off
    set serverout on
    set linesize 8000
    Declare
    Variable v_count_dtl_bal NUMBER(10);
    Variable v_updat_dtl_bal NUMBER(10);
    Variable v_count_tot_bal NUMBER(10);
    Begin
    execute load_abc.insert_abc_bal(:v_count_dtl_bal,:v_updat_dtl_bal,:v_count_tot_bal);
    End;
    exit;
    So, when this sql script runs it given me the above error. However, all the result looks good and there's no problem with the data or anything else that might be impacted. I suspect this error stems from the code in the sql script above.
    Any idea what am I doing wrong?
    Thanks in advance for any inputs.

    Thanks Frank. I still receive the same error if I follow your example or any of the ones explained above. This is what I am getting and still an error underneath:
    Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
              VARCHAR2 (n CHAR) | NCHAR | NCHAR (n) |
              NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
              BINARY_FLOAT | BINARY_DOUBLE ] ]
    Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
              VARCHAR2 (n CHAR) | NCHAR | NCHAR (n) |
              NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
              BINARY_FLOAT | BINARY_DOUBLE ] ]
    Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
              VARCHAR2 (n CHAR) | NCHAR | NCHAR (n) |
              NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR |
              BINARY_FLOAT | BINARY_DOUBLE ] ]
    SP2-0552: Bind variable "V_COUNT_TOT_BAL" not declared.

  • SP2-0552: Bind variable "SV_STUDENT_ID" not declared.

    I get this error:
    SP2-0552: Bind variable "SV_STUDENT_ID" not declared.
    DECLARE
    sv_student_id NUMBER;
    v_student_id NUMBER := &sv_student_id;
    v_enrolled VARCHAR2(3) := 'NO';
    BEGIN
    DBMS_OUTPUT.PUT_LINE ('Check if the student is enrolled');
    SELECT 'YES'
    INTO v_enrolled
    FROM enrollment
    WHERE student_id = v_student_id;
    DBMS_OUTPUT.PUT_LINE ('The student is enrolled into one course');
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    DBMS_OUTPUT.PUT_LINE ('The student is not enrolled');
    WHEN TO_MANY_ROWS
    THEN
    DBMS_OUTPUT.PUT_LINE ('The student is enrolled to many courses');
    END;

    Define &sv_student_id;
    DECLARE
      v_student_id NUMBER := &sv_student_id;
      v_enrolled VARCHAR2(3) := 'NO';
    BEGIN
      DBMS_OUTPUT.PUT_LINE ('Check if the student is enrolled');
      SELECT 'YES'
        INTO v_enrolled
        FROM enrollment
       WHERE student_id = v_student_id;
      DBMS_OUTPUT.PUT_LINE ('The student is enrolled into one course');
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        DBMS_OUTPUT.PUT_LINE ('The student is not enrolled');
      WHEN TO_MANY_ROWS THEN
        DBMS_OUTPUT.PUT_LINE ('The student is enrolled to many courses');
    END;

  • 10g declare :global variable error (bad bind variable)

    In a 10g form, I tried this code in the pl/sql block and in the spec of a library package
    begin
       :global.config := 'x';
    ...upon compile, I get an error
    "bad bind variable"
    ...encountered the symbol "GLOBAL" when expecting one of the following...It doesn't like :GLOBAL.variablename := 'x';
    What am I doing wrong?
    Thank you.

    globals are allowed in librarys, but in libraries you have to use COPY and NAME_IN to access objects you access via :-logic in forms-modules, e.g. setting the global would be like
    COPY('X', 'GLOBAL.CONFIG');Edited by: aweiden on 29.10.2008 19:33

  • Null check for a bind variable in view criteria

    Hi, Greetings.
    I am using Jdeveloper 11.1.2.0.
    I have a view object, LocationsView, for locations table of the XE database.
    I want to apply a condition, ((:bind_var is null) or (:bind_var is not null and location_id = :bind_var), in this LocationsView.
    That is, I want to apply the condition only if the bind variable value is not null.
    How can I construct this condition using a declarative view criteria?
    Any help and hints on this regard is greatly appreciated.
    Regards,
    Guru K

    Hi,
    Thanks for the update and it is working perfectly fine.
    Now, how can I set the "ignore null values" option as checked if I am constructing the criteria programmatically using view criteria row and view criteria item at runtime.
    Thanks and regards,
    Guru K

  • Can viewObject get a parameter from sessionScope to binding variable?

    hello,
    using Jdev11g ADF Fusion application
    Can viewObject get a parameter from sessionScope and assign into binding variable ? without using executeWithParameter
    Thanks
    greenApple

    A. Safwat,
    As I said before, I was not trying to be offensive, but simply to explain some of the shortcomings of one solution over another. One of the reasons people give such short answers is that many questions (including this one) have been asked and answered many many many times before on the forum. As to my reasons:
    1). Overkill - overkill because you are writing code to do what the framework already provides for you.
    2). Not bind-variable friendly - you are gluing in literals into a SQL statement. That means that Oracle will have to hard parse the query for each new value of the filter clause, yielding to poor performance, particularly in a multiuser environment. It should ideally be done using bind variables.
    3). Insecure (think about what happens if you put "'xyz' or 1=1" into the filterValue there) - not using bind variables is a security hole. Think through what happens if a filter criteria comes through like the one I mentioned.
    4). Inflexible - because you are overriding executeQueryForCollection, this VO becomes inflexible and can only be used in this particular place. Using the declarative approach outlined by Timo is more flexible
    5). Bad (ok, that's my opinion there) - OK, perhaps this was a bit offensive ;)
    Please don't take a critique of a post as offensive, as I assure you it was not intended to be in that spirit. As I mentioned, I greatly appreciate when people point out issues/problems/etc with my ideas, as that is the best way for me to learn. I have in the past written applications that were not bind-variable friendly, and I learned the downsides the hard way (system was horribly non-performant) - I wish someone had reviewed my approach and told me "bad idea" before the application made it into production.
    Respectfully,
    John

Maybe you are looking for

  • Grant number in customer line item report

    Is it possible to bring in the grant number in the customer line item report, fbl5n? I tried expanding the fields in the report, but grant does not seem to be one of them. Please help!!! Thanks, MJ

  • Column Totals of a table region in OAF Page

    Hi,     I developed a custom OAF page with a table region (NOT an Advanced table region). It has several columns and one of them is a flag column of checkbox type and also there is amount column. My requirement is to display totals on the amount colu

  • DVD DRIVER PROOOOOOOOOOOOOOOOOOOOOOOOOOOOOBLEM

    HELLO HP, I have HP pavilion dv6-6c65se THE PROBLEM IS : The DVD driver doesn't read DVDs of 4.7 GB , BUT it read DVDs of 9 GB  & blueray & CDs . PLEASE I NEED HELP>>>>>>>>> Any HELP will be appreciated

  • Play button no longer works

    I installed the 2014 version of CC and since then the play button (space bar) no longer works. Everything else seems to be working fine but I can't play my timeline. I can scrub through the footage but it won't play. Does anyone else have this issue

  • Infosets with mutiple InfoCubes

    I would like some assistance with creating an infoset that contains multiple cubes.  There are four cubes included.  I am able to create, set joins and activate, but if I use listcube to display the data, I get the following error after a long period