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;

Similar Messages

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

  • Bind variable "LOOP" not declared.

    Hi,
    I am very new to Pl/SQL.My job needs me to migrate MySQL database to Oracle(that I did successfully) but the procedures in the MySQL could not be migrated to Oracle,So have to create them manually.
    While creating procedure,Am getting these errors
    Error(4,1): PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior The symbol "begin" was substituted for "DECLARE" to continue.
    Error(5,1): PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior
    CREATE OR REPLACE PROCEDURE PROCEDURE1 AS
    BEGIN
    Declare v_date date;
    Declare v_particulars varchar(50);
    Declare v_quantity float default 0;
    Declare v_item integer default 0;
    Declare v_vendor integer default 0;
    Declare v_flag integer default 1;
    Declare v_supplier_id integer default null;
    Declare v_unit integer default 0;
    Declare v_srno integer default 0;
    Declare op_date date;
    declare op_bal float default 0;
    Declare temp_v_from_date date;
    Declare temp_v_to_date date;
    Declare done integer default 0;
    Declare cur1 cursor for  (select  sibs.opening_balance_date,'Opening Balance',sibs.item_id,
    sum(sibs.opening_balance_qty), '1'from store_item_batch_stock sibs  where sibs.opening_balance_date is not null
    and sibs.department_id = v_depart  and  sibs.item_id = v_item_id group by sibs.item_id);
    Declare cur2 cursor for  (select sgm.grn_date, concat('Receipt',' - (',sgm.grn_no,')'), sgt.item_id,
    sum(NVL((case d.formula when 1   then ((sgt.received_qty + sgt.free_qty) * sgt.mdq_value) / d.conversion_factor1
    else (sgt.received_qty + sgt.free_qty) end),0)), '2',sgm.supplier_id,sgm.unit_id from store_grn_m sgm,
    store_grn_t sgt, mas_store_item c, mas_store_item_conversion d
    where sgm.grn_date between v_from_date and v_to_date and  sgm.department_id = v_depart
    and   sgt.item_id = c.item_id  and   c.item_conversion_id = d.item_conversion_id  and   sgt.grn_master_id = sgm.grn_master_id
    and   sgt.item_id = v_item_id group by sgm.grn_master_id         );
    Declare cur3 cursor for (select sim.issue_date,concat('Issue',concat(' -(',concat(sim.issue_no,')'))), sit.item_issued,
    sum(NVL(sit.qty_issued,0)), '3'  from store_issue_m sim, store_issue_t sit
    where sim.issue_date between v_from_date and v_to_date and   sim.department_id = v_depart
    and   sit.issue_m_id = sim.id  and   sim.issue_type = 'i' and   sit.item_issued = v_item_id
    and   sit.issued = 'y' group by sim.id         );
    Declare cur4 cursor for (select sgrm.return_date, 'Vendor Return', sgrt.item_id,
    sum(NVL(sgrt.return_qty,0)), '3' from store_grn_return_m sgrm,store_grn_return_t sgrt
    where sgrm.return_date between v_from_date and v_to_date      and   sgrm.department_id = v_depart
    and   sgrt.grn_return_id = sgrm.grn_return_id  and   sgrt.item_id = v_item_id  group by  sgrm.grn_return_id         );
    Declare cur5 cursor for (select sadm.adjustment_date, 'Adjustment',sadt.item_id,
    sum(NVL(sadt.adjust_qty,0)), '2'                  from store_adjustment_m  sadm,
    store_adjustment_t  sadt where sadm.adjustment_date between v_from_date and v_to_date
    and   sadm.department_id = v_depart  and   sadt.adjust_id = sadm.id  and   sadt.item_id = v_item_id
    and   sadt.adjust_qty != 0 group by sadm.id                  );
    Declare cur6 cursor for (select sim.issue_date,'Receipt (Internal)', sit.item_issued,
    sum(NVL(sit.qty_issued,0)), '2' from store_issue_m sim, store_issue_t sit
    where sim.issue_date between v_from_date and v_to_date      and   sim.to_store = v_depart
    and   sit.issue_m_id = sim.id   and   sim.issue_type = 'i'   and   sit.item_issued = v_item_id
    and   sit.issued = 'y' group by sim.id         );
    declare cur7 cursor for (select siam.adjustment_date, 'Adjustment',siat.item_id,
    sum(NVL(siat.adjusted_qty,0)), '2'                  from store_item_adjustment_m  siam,
    store_item_adjustment_t  siat where siam.adjustment_date between v_from_date and v_to_date
    and   siam.adjustment_login_dept = v_depart  and   siat.item_adjustment_m_id = siam.item_adjustment_id
    and   siat.item_id = v_item_id and   siat.adjusted_qty != 0 group by siam.item_adjustment_id
    Declare oldcur1 cursor for  (select sgm.grn_date, 'Receipt', sgt.item_id,
    sum(NVL((case when d.formula =1  then ((sgt.received_qty + sgt.free_qty) * sgt.mdq_value) / d.conversion_factor1
    else (sgt.received_qty + sgt.free_qty) end),0)), '2'                  from store_grn_m sgm,
    store_grn_t sgt, mas_store_item c, mas_store_item_conversion d
    where sgm.grn_date between '2009-03-31' and (v_from_date -1)
    and   sgm.department_id = v_depart  and   sgt.item_id = c.item_id  and   c.item_conversion_id = d.item_conversion_id
    and   sgt.grn_master_id = sgm.grn_master_id  and   sgt.item_id = v_item_id  group by sgm.grn_master_id  );
    Declare oldcur2 cursor for (select sim.issue_date,'Issue', sit.item_issued,
    sum(NVL(sit.qty_issued,0)), '3' from store_issue_m sim, store_issue_t sit
    where sim.issue_date between '2009-03-31' and (v_from_date -1)
    and   sim.department_id = v_depart  and   sit.issue_m_id = sim.id  and   sim.issue_type = 'i'
    and   sit.item_issued = v_item_id   and   sit.issued = 'y' group by sim.id         );
    Declare oldcur3 cursor for (select sgrm.return_date, 'Return', sgrt.item_id, sum(NVL(sgrt.return_qty,0)), '2'
    from store_grn_return_m sgrm, store_grn_return_t sgrt
    where sgrm.return_date between '2009-03-31' and (v_from_date -1)
    and   sgrm.department_id = v_depart   and   sgrt.grn_return_id = sgrm.grn_return_id   and   sgrt.item_id = v_item_id group by sgrm.grn_return_id );
    Declare oldcur4 cursor for (select sadm.adjustment_date, 'Adjustment',sadt.item_id,
    sum(NVL(sadt.adjust_qty,0)), '2'  from store_adjustment_m  sadm, store_adjustment_t  sadt
    where sadm.adjustment_date between '2009-03-31' and (v_from_date -1)  and   sadm.department_id = v_depart
    and   sadt.adjust_id = sadm.id   and   sadt.item_id = v_item_id  and   sadt.adjust_qty != 0 group by sadm.id );
    Declare oldcur5 cursor for (select sim.issue_date,'RCPT', sit.item_issued, sum(NVL(sit.qty_issued,0)), '3' from store_issue_m sim,
    store_issue_t sit where sim.issue_date between '2009-03-31' and (v_from_date -1)  and   sim.to_store = v_depart
    and   sit.issue_m_id = sim.id   and   sit.item_issued = v_item_id   and   sit.issued = 'y' group by sim.id );
    declare oldcur7 cursor for (select siam.adjustment_date, 'Adjustment',siat.item_id,
    sum(NVL(siat.adjusted_qty,0)), '2'                  from store_item_adjustment_m  siam,
    store_item_adjustment_t  siat where siam.adjustment_date between '2009-03-31' and (v_from_date -1)
    and   siam.adjustment_login_dept = v_depart  and   siat.item_adjustment_m_id = siam.item_adjustment_id  and   siat.item_id = v_item_id
    and   siat.adjusted_qty != 0 group by siam.item_adjustment_id
    Declare closingStockUpdateCursor cursor for(select sno,date,qty,flag from ledger where dept_id = v_depart  and item_id = v_item_id
    and flag!=0 order by date  );
    Declare continue handler for not found set done =1;
    delete from ledger where item_id = v_item_id and dept_id = v_depart;
    Open cur1;
    item_loop:loop
    Fetch cur1 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    if not (v_date > v_from_date) then
    set op_bal = v_quantity;
    set op_date = v_date;
    End if;
    End loop item_loop;
    Close cur1;
    set  done = 0;
    Open oldcur1;
    item_loop:loop
    Fetch oldcur1 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    set op_bal = op_bal + v_quantity;
    End loop item_loop;
    Close oldcur1;
    set  done = 0;
    Open oldcur2;
    item_loop:loop
    Fetch oldcur2 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    set op_bal = op_bal - v_quantity;
    End loop item_loop;
    Close oldcur2;
    set  done = 0;
    Open oldcur3;
    item_loop:loop
    Fetch oldcur3 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then   Leave item_loop;
    End if;   set op_bal = op_bal + v_quantity;
    End loop item_loop;
    Close oldcur3;
    set  done = 0;
    Open oldcur4;
    item_loop:loop
    Fetch oldcur4 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    if op_date != v_date then
    set op_bal = op_bal + v_quantity;
    End if;
    End loop item_loop;
    Close oldcur4;
    set  done = 0;
    Open oldcur5;
    item_loop:loop
    Fetch oldcur5 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then   Leave item_loop;
    End if;
    set op_bal = op_bal + v_quantity;
    End loop item_loop;
    Close oldcur5;
    set  done = 0;
    Open oldcur7;
    item_loop:loop
    Fetch oldcur7 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then   Leave item_loop;
    End if;
    set op_bal = op_bal + v_quantity;
    End loop item_loop;
    Close oldcur7;
    set  done = 0;
    insert into ledger(date, particulars,qty,item_id,dept_id,flag,closing_stock)   values(v_from_date,'Opening Balance', op_bal, v_item_id,v_depart,'0',op_bal);
    Open cur2;
    item_loop:loop
    Fetch cur2 into v_date, v_particulars, v_item, v_quantity, v_flag, v_supplier_id, v_unit;
    If done =1 then
    Leave item_loop;
    End if;
    insert into ledger(date, particulars,qty,item_id,flag,dept_id,vendor_id,closing_stock,unit_id)   values(v_date,v_particulars, v_quantity, v_item,v_flag,v_depart,v_supplier_id,0,v_unit);
    End loop item_loop;
    Close cur2;
    set  done = 0;
    Open cur3;
    item_loop:loop
    Fetch cur3 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    insert into ledger(date, particulars,qty,item_id,flag,dept_id,closing_stock)   values(v_date,v_particulars,v_quantity, v_item,v_flag,v_depart,0);
    End loop item_loop;
    Close cur3;
    set  done = 0;
    Open cur4;
    item_loop:loop
    Fetch cur4 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    insert into ledger(date, particulars,qty,item_id,flag,dept_id,closing_stock)   values(v_date,v_particulars,v_quantity, v_item,v_flag,v_depart,0);
    End loop item_loop;
    Close cur4;
    set  done = 0;
    Open cur5;
    item_loop:loop
    Fetch cur5 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then   Leave item_loop;
    End if;
    insert into ledger(date, particulars,qty,item_id,flag,dept_id,closing_stock)   values(v_date,v_particulars, v_quantity, v_item,v_flag,v_depart,0);
    End loop item_loop;
    Close cur5;
    set  done = 0;
    Open cur6;
    item_loop:loop
    Fetch cur6 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    insert into ledger(date, particulars,qty,item_id,flag,dept_id,closing_stock)   values(v_date,v_particulars, v_quantity, v_item,v_flag,v_depart,0);
    End loop item_loop;
    Close cur6;
    set  done = 0;
    Open cur7;
    item_loop:loop
    Fetch cur7 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    insert into ledger(date, particulars,qty,item_id,flag,dept_id,closing_stock)   values(v_date,v_particulars, v_quantity, v_item,v_flag,v_depart,0);
    End loop item_loop;
    Close cur7;
    set  done = 0;
    Open closingStockUpdateCursor;
    item_loop:loop
    Fetch closingStockUpdateCursor into v_srno,v_date, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    if v_flag = 2 then
    set op_bal = op_bal + v_quantity;
    else
    set op_bal = op_bal - v_quantity;
    end if;
    update ledger set closing_stock = op_bal where sno = v_srno;
    End loop item_loop;
    Close closingStockUpdateCursor;
    set  done = 0;
    END
      NULL;
    END PROCEDURE1;
    /Please help where I am getting wrong

    Another comment.
    If two products are identical in features, there is nothing much to differentiate one from the other. And this is important as the differences between products are what drives the buyer's decision as to which one is the best.
    There are major differences between Oracle and mySQL. Some of them core and fundamental differences. And this is what makes one product "better" than the other - and drives the decision on whether to use Oracle or mySQL.
    Oracle makes a poor mySQL. It does the Oracle thing very well. So it does not make sense to take a design and code that works for mySQL, plonk it down on Oracle, and think that Oracle's differences will now make this design and code work and perform "better".
    Everything but. As Oracle does a poor mySQL imitation, the end result of that will be a system that performs worse than what it did on mySQL.
    To make use of that which makes Oracle "better" than mySQL, requires the application to be redesigned and code refactored.
    So IMO, what you/your company are doing, is bound for failure. You will pay more money for a more sophisticated and very able RDBMS product - that is unable to reach its potential as you are asking it to pretend to be mySQL and to do that, better than mySQL. That is an epic fail.

  • About ora-01006 :bind variable does not exist

    Hi all of you,i have this dynamic sql :
    DECLARE
    v_query clob;
    cpt number;
    begin
    v_query:='
    SELECT
    count(TBA.ANT_ID)
      FROM
    WHERE TBA.ANT_FUT_ID = TFT.FUT_ID
           AND TBA.ANT_KATEGORIE_CODE_ID = TAKCL.ANT_KATEGORIE_CODE_ID(+)
           AND TBA.ANT_KFZ_REIHEN_ID = TKR.KFZ_REIHEN_ID(+)
           AND TBA.ANT_ID = F1.ANT_ANT_ID(+)
           AND TBA.ANT_ID = F2.ANT_ANT_ID(+)
           AND TBA.ANT_ID = F3.ANT_ANT_ID(+)
           AND TBA.ANT_ID = ERS.ers_bdk(+)
           AND TBA.ANT_ID = F1_2.ANT_ANT_ID(+)
           AND TBA.ANT_ID = F2_3.ANT_ANT_ID(+)
           AND TBA.ANT_ID = MFU.MFU_ANT_ID(+)
           AND MFU.MFU_NIETGEOMETRIE_ID = NG.NG_ID(+)
           AND MFU.MFU_MATRIZEN_BEICHNUNG_ID = MZB.MZB_ID(+)
        -- Suchkriterien: --
        --Ersteller
        AND  DECODE( ERS.ers_id, NULL, ''%'', ERS.ers_name ) LIKE DECODE('':1'',NULL,''%'','''')||''''|| :1 ||''''||DECODE('':1'',NULL,''%'','''')
         --Fahrzeug
        AND  DECODE( TKR.NAME, NULL, ''%'', TKR.NAME ) LIKE DECODE('':2'',NULL,''%'','''')||''''|| :2 ||''''|| DECODE('':2'',NULL,''%'','''')
         --BDK
        AND  DECODE( fuege_db.bdk_nummer( TBA.ANT_ID,''.'' ), NULL, ''%%'',
       fuege_db.bdk_nummer( TBA.ANT_ID,''.'' ) )   LIKE ''%''||:3||''%''
        --Technologie
        AND  TBA.ANT_FUT_ID LIKE DECODE('':4'',NULL,''%'','''')||''''|| :4 ||''''||DECODE('':4'',NULL,''%'','''')
         --Art
        AND ((TBA.ANT_WFP_ID is null and 1=DECODE('':5'',NULL,1,1,1) ) or (TBA.ANT_WFP_ID is not null and 2=DECODE('':5'',NULL,2,2,2)))
        --VTA
        AND TBA.ANT_VTA = decode('':6'',1,1,TBA.ANT_VTA)  ';
    execute immediate v_query
    into cpt USING
    'Dominik Hussmann',
    'AU736_Q7_SUV' ,
    'WPS Stahl',
    '0';  
    end ;
    In the execution,i have this error :ora-01006 :bind variable does not exist, after analyzing,i have found that the problem is with parameters :5 and :6 ,i don't understand they have the same syntax
    as bind variables 1,2,3 and 4.
    Than you for any suggestion.

    I hope you do realise that there are 13 bind-variables in your sql, not 6?
    Variables are bound by position. You cannot use the same bind variable twice, they will be 2 distinct bind variables.
    For example, you use :1 three times, so you need to provide three arguments, in this case three times the same value.

  • I am getting this error message "ORA-01006: bind variable does not exist.

    My code works fine like this:
    DECLARE
    v_JOBTYPE varchar2(8);
    v_STATUS varchar2(8);
    v_FAILURE varchar2(8);
    v_CAUSE varchar2(8);
    v_ACTION varchar2(8);
    BEGIN
    SELECT EVT_STATUS, EVT_FAILURE, EVT_CAUSE, EVT_ACTION, EVT_JOBTYPE
    INTO v_STATUS, v_FAILURE, v_CAUSE, v_ACTION, v_JOBTYPE
    FROM R5EVENTS WHERE ROWID = :ROWID;
    IF NVL(v_STATUS, 'X') = 'C' AND NVL(v_JOBTYPE , 'X') IN ('BRKD','UNPLBRKD','FILTRA', 'LUB', 'FAC') AND (v_FAILURE IS NULL OR v_CAUSE IS NULL OR v_ACTION IS NULL) THEN
    RAISE_APPLICATION_ERROR( -20001, 'FAILURE, CAUSE AND ACTION FIELDS MUST BE POPULATED');
    END IF;
    END;
    But I want to change the code to include a record (ACT_TRADE) from another table(R5ACTIVITIES). I am getting this error message "ORA-01006: bind variable does not exist - POST-UPDATE 200Before Binding". Any help would be appreciated.
    DECLARE
    v_STATUS varchar2(8);
    v_FAILURE varchar2(8);
    v_CAUSE varchar2(8);
    v_ACTION varchar2(8);
    V_CODE varchar2(8);
    V_EVENT varchar2(8);
    V_TRADE varchar2(8);
    BEGIN
    SELECT R5EVENTS.EVT_STATUS, R5EVENTS.EVT_FAILURE, R5EVENTS.EVT_CAUSE, R5EVENTS.EVT_ACTION, R5EVENTS.EVT_CODE, R5ACTIVITIES.ACT_EVENT, R5ACTIVITIES.ACT_TRADE
    INTO v_STATUS, v_FAILURE, v_CAUSE, v_ACTION, V_CODE, V_EVENT, V_TRADE
    FROM R5EVENTS, R5ACTIVITIES WHERE V_CODE = :V_EVENT;
    IF NVL(v_STATUS, 'X') = 'C' AND NVL(v_TRADE , 'X') IN ('MTM','MTL','MTMGT', 'FTM', 'FTL', 'FTMGT', 'R5') AND (v_FAILURE IS NULL OR v_CAUSE IS NULL OR v_ACTION IS NULL) THEN
    RAISE_APPLICATION_ERROR( -20001, 'FAILURE, CAUSE AND ACTION FIELDS MUST BE POPULATED');
    END IF;
    END;

    Thank you for your responses. Your feedback was helpful. This is what I ended up doing for a solution:
    DECLARE
    v_JOBTYPE varchar2(8);
    v_STATUS varchar2(8);
    v_FAILURE varchar2(8);
    v_CAUSE varchar2(8);
    v_ACTION varchar2(8);
    v_GROUP varchar2(30);
    BEGIN
    SELECT EVT_STATUS, EVT_FAILURE, EVT_CAUSE, EVT_ACTION, EVT_JOBTYPE, USR_GROUP
    INTO v_STATUS, v_FAILURE, v_CAUSE, v_ACTION, v_JOBTYPE, v_GROUP
    FROM R5EVENTS, R5USERS WHERE R5EVENTS.ROWID = :ROWID
    AND USR_CODE = O7SESS.CUR_USER;
    IF NVL(v_STATUS, 'X') = 'C' AND NVL(V_GROUP,'X') IN ('MTM','MTL','MTMGT','FTL','FTMGTS','PLANNER','DISPATCH','PMCOOR','R5') AND (v_FAILURE IS NULL OR v_CAUSE IS NULL OR v_ACTION IS NULL) THEN
    RAISE_APPLICATION_ERROR( -20001, 'FAILURE, CAUSE AND ACTION FIELDS MUST BE POPULATED');
    END IF;
    END;

  • ORA-01006:bind variable does not exist for the QUERY

    Dear All,
    Please help on below query :
    DECLARE
    P_ROTATION_NO GCH_VSL_REGN.ROTATION_NO%TYPE :=21;
    P_VESL_NO GCH_VSL_MASTER.VESL_NO%TYPE := NULL;
    P_VESL_NAME GCH_VSL_MASTER.VESL_NAME%TYPE:= NULL;
    P_FROM_REG_DATE GCH_VSL_MASTER.CREATED_DATE%TYPE:= NULL;
    P_TO_REG_DATE GCH_VSL_MASTER.CREATED_DATE%TYPE:= NULL;
    P_FROM_ARRIVAL_DATE GCH_VSL_REGN.ARRIVAL_DATE%TYPE:= NULL;
    P_TO_ARRIVAL_DATE GCH_VSL_REGN.ARRIVAL_DATE%TYPE:= NULL;
    P_CLOSE_TYPE GCH_VSL_CLOSE_DTLS.CLOSE_TYPE%TYPE:= NULL;
    P_RESULT_LIST SYS_REFCURSOR;
    P_TOTAL_LENGTH NUMBER;
    P_ERROR_MESSAGE VARCHAR2(1000);
    lv_sql1 VARCHAR2(5000);
    lv_sql2 VARCHAR2(5000);
    lv_whereClause VARCHAR2(5000);
    pv_text VARCHAR2(1000);
    BEGIN
    pv_text := NULL;
    lv_whereClause := ' WHERE GVM.VESL_MASTER_NUM = GVR.VESL_MASTER_NUM
    AND GVR.ROTATION_NO = GVCH.ROTATION_NO
    AND GVCH.CLOSE_HDR_ID = GVCD.CLOSE_HDR_ID(+)
    AND (:P_ROTATION_NO IS NULL OR
    (:P_ROTATION_NO IS NOT NULL AND
    GVR.ROTATION_NO LIKE % :P_ROTATION_NO %))
    AND GVM.IS_VALID = 1';
    lv_sql1 := 'SELECT COUNT(gvr.rotation_no)
    FROM gch_vsl_close_hdr gvch,
    gch_vsl_master gvm,
    gch_vsl_regn gvr,
    gch_vsl_close_dtls gvcd'||lv_whereClause;
    dbms_output.put_line (lv_sql1);
    EXECUTE IMMEDIATE lv_sql1 INTO :P_TOTAL_LENGTH
    USING P_ROTATION_NO;
    END;
    I am getting below error when running the above query
    ORA-01006:     bind variable does not exist

    why (date datatype assumed for variables with names containing DATE)
    PROCEDURE XVY(P_ROTATION_NO IN GCH_VSL_REGN.ROTATION_NO%TYPE,
                  P_VESL_NO IN GCH_VSL_MASTER.VESL_NO%TYPE,
                  P_VESL_NAME IN GCH_VSL_MASTER.VESL_NAME%TYPE,
                  P_CM_REGN_NO IN GCH_VSL_REGN.CM_REGN_NO%TYPE,
                  P_FINAL_CLOSE_STA IN GCH_VSL_CLOSE_HDR.FINAL_CLOSE_STA%TYPE,
                  P_FROM_REG_DATE IN GCH_VSL_MASTER.Created_Date%TYPE,
                  P_TO_REG_DATE IN GCH_VSL_MASTER.CREATED_DATE%TYPE,
                  P_FROM_ARRIVAL_DATE IN GCH_VSL_REGN.ARRIVAL_DATE%TYPE,
                  P_TO_ARRIVAL_DATE IN GCH_VSL_REGN.ARRIVAL_DATE%TYPE,
                  P_RESULT_LIST OUT SYS_REFCURSOR,
                  P_TOTAL_LENGTH OUT NUMBER,
                  P_ERROR_MESSAGE OUT VARCHAR2
                 ) AS
      lv_sql1        VARCHAR2(4000);
      lv_sql2        VARCHAR2(4000);
      lv_whereClause VARCHAR2(4000);
    BEGIN
    --  pv_text := NULL;
      lv_whereClause := ' WHERE gvm.vesl_master_num = gvr.vesl_master_num '||
                          ' AND GVR.ROTATION_NO(+) = GVCH.ROTATION_NO '||
                          ' AND (:P_ROTATION_NO IS NULL '||
                          '  OR  (:P_ROTATION_NO IS NOT NULL '||
                          ' AND   gvch.rotation_no LIKE ''%'' || :P_ROTATION_NO || ''%'' ' ||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_CM_REGN_NO IS NULL '||
                          '  OR  (:P_CM_REGN_NO IS NOT NULL '||
                          ' AND   gvr.cm_regn_no LIKE ''%'' || :P_CM_REGN_NO || ''%'' '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_VESL_NAME IS NULL '||
                          '  OR  (:P_VESL_NAME IS NOT NULL '||
                          ' AND   gvm.vesl_name LIKE ''%'' || :P_VESL_NAME || ''%'' '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_VESL_NO IS NULL '||
                          '  OR  (:P_VESL_NO IS NOT NULL '||
                          ' AND   GVM.vesl_no LIKE ''%'' || :P_VESL_NO || ''%'' '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_FINAL_CLOSE_STA IS NULL '||
                          '  OR  (:P_FINAL_CLOSE_STA IS NOT NULL '||
                          ' AND   gvch.imp_close_sta LIKE ''%'' || :P_FINAL_CLOSE_STA || ''%'' '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_FROM_REG_DATE IS NULL '||
                          '  OR  (:P_FROM_REG_DATE IS NOT NULL '||
                          ' AND   gvch.created_date >= :P_FROM_REG_DATE '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_TO_REG_DATE IS NULL '||
                          '  OR  (:P_TO_REG_DATE IS NOT NULL '||
                          ' AND   gvch.created_date <= :P_TO_REG_DATE '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_FROM_ARRIVAL_DATE IS NULL '||
                          '  OR  (:P_FROM_ARRIVAL_DATE IS NOT NULL '||
                          ' AND   gvch.arrival_date >= :P_P_FROM_ARRIVAL_DATE '||
                          '      ) '||
                          '     ) '||
                          ' AND (:P_TO_ARRIVAL_DATE IS NULL '||
                          '  OR  (:P_TO_ARRIVAL_DATE IS NOT NULL '||
                          ' AND   gvch.arrival_date <= :P_TO_ARRIVAL_DATE '||
                          '      ) '||
                          '     ) '||
                          ' AND gvm.is_valid = 10 ';
      lv_sql1 := 'SELECT COUNT(gvr.rotation_no) '||
                 '  FROM xvz gvch, '||
                 '       zxsc gvm, '||
                 '       dsae gvr, '||
                 '       vvsd gvcd '|| lv_whereClause;
      lv_sql2 := ' SELECT gvch.close_hdr_id, '||
                 '        gvch.rotation_no, '||
                 '        gvr.cm_regn_no, '||
                 '        gvm.vesl_no, '||
                 '        gvm.vesl_name, '||
                 '        gvch.final_close_sta, '||
                 '        gvr.arrival_date, '||
                 '        gvch.close_date, '||
                 '        gvr.created_date '||
                 '   FROM xvz gvch, '||
                 '        zxsc gvm, '||
                 '        dsze gvr '|| lv_whereClause || 'ORDER BY gvch.rotation_no';
      EXECUTE IMMEDIATE lv_sql1 INTO P_TOTAL_LENGTH
                  USING P_ROTATION_NO,P_ROTATION_NO,P_ROTATION_NO,
                        P_CM_REGN_NO,P_CM_REGN_NO,P_CM_REGN_NO,
                        P_VESL_NAME,P_VESL_NAME,P_VESL_NAME,
                        P_VESL_NO,P_VESL_NO,P_VESL_NO,
                        P_FINAL_CLOSE_STA,P_FINAL_CLOSE_STA,P_FINAL_CLOSE_STA,
                        P_FROM_REG_DATE,P_FROM_REG_DATE,P_FROM_REG_DATE,
                        P_TO_REG_DATE,P_TO_REG_DATE,P_TO_REG_DATE,
                        P_FROM_ARRIVAL_DATE,P_FROM_ARRIVAL_DATE,P_FROM_ARRIVAL_DATE,
                        P_TO_ARRIVAL_DATE,P_TO_ARRIVAL_DATE,P_TO_ARRIVAL_DATE;
      OPEN P_RESULT_LIST
       FOR lv_sql2 USING P_ROTATION_NO,P_ROTATION_NO,P_ROTATION_NO,
                         P_CM_REGN_NO,P_CM_REGN_NO,P_CM_REGN_NO,
                         P_VESL_NAME,P_VESL_NAME,P_VESL_NAME,
                         P_VESL_NO,P_VESL_NO,P_VESL_NO,
                         P_FINAL_CLOSE_STA,P_FINAL_CLOSE_STA,P_FINAL_CLOSE_STA,
                         P_FROM_REG_DATE,P_FROM_REG_DATE,P_FROM_REG_DATE,
                         P_TO_REG_DATE,P_TO_REG_DATE,P_TO_REG_DATE,
                         P_FROM_ARRIVAL_DATE,P_FROM_ARRIVAL_DATE,P_FROM_ARRIVAL_DATE,
                         P_TO_ARRIVAL_DATE,P_TO_ARRIVAL_DATE,P_TO_ARRIVAL_DATE;
    END;instead of (the where clauses should be equivalent)
    PROCEDURE XVY(P_ROTATION_NO IN GCH_VSL_REGN.ROTATION_NO%TYPE,
                  P_VESL_NO IN GCH_VSL_MASTER.VESL_NO%TYPE,
                  P_VESL_NAME IN GCH_VSL_MASTER.VESL_NAME%TYPE,
                  P_CM_REGN_NO IN GCH_VSL_REGN.CM_REGN_NO%TYPE,
                  P_FINAL_CLOSE_STA IN GCH_VSL_CLOSE_HDR.FINAL_CLOSE_STA%TYPE,
                  P_FROM_REG_DATE IN GCH_VSL_MASTER.Created_Date%TYPE,
                  P_TO_REG_DATE IN GCH_VSL_MASTER.CREATED_DATE%TYPE,
                  P_FROM_ARRIVAL_DATE IN GCH_VSL_REGN.ARRIVAL_DATE%TYPE,
                  P_TO_ARRIVAL_DATE IN GCH_VSL_REGN.ARRIVAL_DATE%TYPE,
                  P_RESULT_LIST OUT SYS_REFCURSOR,
                  P_TOTAL_LENGTH OUT NUMBER,
                  P_ERROR_MESSAGE OUT VARCHAR2
                 ) AS
      lv_sql1        VARCHAR2(4000);
      lv_sql2        VARCHAR2(4000);
      lv_whereClause VARCHAR2(4000);
    BEGIN
      SELECT COUNT(gvr.rotation_no)
        INTO P_TOTAL_LENGTH
        FROM xvz gvch,
             zxsc gvm,
             dsae gvr,
             vvsd gvcd
       WHERE gvm.vesl_master_num = gvr.vesl_master_num
         AND GVR.ROTATION_NO(+) = GVCH.ROTATION_NO
         AND (P_ROTATION_NO IS NULL
          OR  (P_ROTATION_NO IS NOT NULL
         AND   gvch.rotation_no LIKE '%' || P_ROTATION_NO || '%'
         AND (P_CM_REGN_NO IS NULL
          OR  (P_CM_REGN_NO IS NOT NULL
         AND   gvr.cm_regn_no LIKE '%' || P_CM_REGN_NO || '%'
         AND (P_VESL_NAME IS NULL
          OR  (P_VESL_NAME IS NOT NULL
         AND   gvm.vesl_name LIKE '%' || P_VESL_NAME || '%'
         AND (P_VESL_NO IS NULL
          OR  (P_VESL_NO IS NOT NULL
         AND   GVM.vesl_no LIKE '%' || P_VESL_NO || '%'
         AND (P_FINAL_CLOSE_STA IS NULL
          OR  (P_FINAL_CLOSE_STA IS NOT NULL
         AND   gvch.imp_close_sta LIKE '%' || P_FINAL_CLOSE_STA || '%'
         AND (P_FROM_REG_DATE IS NULL
          OR  (P_FROM_REG_DATE IS NOT NULL
         AND   gvch.created_date >= P_FROM_REG_DATE
         AND (P_TO_REG_DATE IS NULL
          OR  (P_TO_REG_DATE IS NOT NULL
         AND   gvch.created_date <= P_TO_REG_DATE
         AND (P_FROM_ARRIVAL_DATE IS NULL
          OR  (P_FROM_ARRIVAL_DATE IS NOT NULL
         AND   gvch.arrival_date >= P_P_FROM_ARRIVAL_DATE
         AND (P_TO_ARRIVAL_DATE IS NULL
          OR  (P_TO_ARRIVAL_DATE IS NOT NULL
         AND   gvch.arrival_date <= P_TO_ARRIVAL_DATE
         AND gvm.is_valid = 10;
      OPEN P_RESULT_LIST
       FOR SELECT gvch.close_hdr_id, 
                  gvch.rotation_no, 
                  gvr.cm_regn_no, 
                  gvm.vesl_no, 
                  gvm.vesl_name, 
                  gvch.final_close_sta, 
                  gvr.arrival_date, 
                  gvch.close_date, 
                  gvr.created_date 
             FROM xvz gvch, 
                  zxsc gvm, 
                  dsze gvr
            WHERE gvm.vesl_master_num = gvr.vesl_master_num
              AND GVR.ROTATION_NO(+) = GVCH.ROTATION_NO
              AND gvch.rotation_no LIKE '%' || nvl(P_ROTATION_NO,gvch.rotation_no) || '%'
              AND gvr.cm_regn_no LIKE '%' || nvl(P_CM_REGN_NO,gvr.cm_regn_no) || '%'
              AND gvm.vesl_name LIKE '%' || nvl(P_VESL_NAME,gvm.vesl_name) || '%'
              AND gvm.vesl_no LIKE '%' || nvl(P_VESL_NO,gvm.vesl_no) || '%'
              AND gvch.imp_close_sta LIKE '%' || nvl(P_FINAL_CLOSE_STA,gvch.imp_close_sta) || '%'
              AND gvch.created_date BETWEEN nvl(P_FROM_REG_DATE,gvch.created_date) AND nvl(P_TO_REG_DATE,gvch.created_date)
              AND gvch.arrival_date BETWEEN nvl(P_FROM_ARRIVAL_DATE,gvch.arrival_date) AND nvl(P_TO_ARRIVAL_DATE,gvch.arrival_date)
              AND gvm.is_valid = 10;
            ORDER BY gvch.rotation_no;
    END;Regards
    Etbin
    Edited by: Etbin on 8.4.2012 14:37
    In order not to waste your time in the future:
    Don't execute dynamic SQL until it works !!!
    Write out what you managed to put together using dbms_output.
    Paste that into the SQL window of your client tool (SQL Developer ...)
    Convert parameters to bind variables (replace p_ with :p_)
    Try to run it.
    If errors are thrown correct them, adjust the procedure/function set up to write your dynamic SQL accordingly
    Repeat the cycle until no errors are thrown
    Comment out the dbms_output. ... line
    Uncomment the execute immediate ... line

  • Bind variable is not defined

    Hi, it is my first attempt to modify a rdf file.
    I run into a problem while trying to add an additional user parameter in an existing rdf file. While I am successful in adding a new FREQUENCY user parameter and I am able to update the form to show this new parameter, I am not able to run the report.
    I have updated the SQL query in the report editor, under data view to use this new parameter :FREQUENCY. (select ... from table where frequency= :FREQUENCY) There was no error here.
    Whenever I run the report, I will always get an error saying:
              "REP-0730: The following bind variable is not defined: "(nothing behind this                                                             error message)
    The program will have a memory error and it exits itself.
    I had tried many methods trying to solve this problem to no avail.
    I am using Oracle 9i Reports Builder 9.0.2.0.3.
    I would appreciate any help given on this matter.
    Thank you :)
    Message was edited by:
    Leion

    In Object Navigator Under Layout ->User parameters are you able to see your bind variable FREQUENCY?

  • How to find out if a SQL is using a bind variable or not?

    In order to make a SQL use consistent execution plan, I want to create a profile for a SQL. But I need to know if a SQL is using bind variable or not to create a profile for all the same SQLs except the literal value. How can I do that?
    Thanks in advance

    You can tell if an SQL statement uses a bind variable by looking at the SQL statement.
    If you look in the program that submits the SQL statement you can see how it constructs, prepares, and executes the statement.
    If you are just looking at the SQL in the shared pool then depending on how the statement is written and the setting of database parameters like cursor sharing then it can be more difficult but if you see a constant (actual value) that is a constant. A bind variable would appear as a name in the where clause where that name does not exist any of the tables referenced in the query. Note it is technically possible to create pl/sql variables with the same name as columns in the query but that is poor coding and leads to issues.
    Note - To Oracle two versions of the otherwise same query where one has a constant and the other has a bind variable are not the same query and often produce different plans. This is a common error made by developers new to Oracle when using explain plan. To explain a query that uses bind variables place a ":" in front of the variable name in the SQL submitted to explain plan.
    HTH -- Mark D Powell --

  • Bind variable does not exist...

    Hi,
    I have an Access UI which is calling an Oracle package. The package has a simple command:
    INSERT INTO Table1 SELECT * from Table2
    The above query runs fine in Oracle directly, but when I run it through the package, I get the error "Bind variable does not exist". What does that mean? The query does not have any parameters. Similar queries running thgough the package that insert into other tables work fine.
    Something with structure of Table2 (this is a new table)?
    Thanks.
    Edited by: markk2 on Jan 12, 2009 9:59 PM
    Edited by: markk2 on Jan 12, 2009 10:10 PM

    I am not sure what's package you were talking about. Is it a package designed in Access?
    Access to Oracle is using ODBC, some of the SQL syntax specific to Oracle may not work. You might also check how table1 and table2 defined in Access. Are they all linked Oracle tables or one of them is Access table?
    Do you have any Oracle error message like ORA-xxxx ?

  • Bind variables are not used in select statement

    Hello all of you,
    I have two parameters in Report 6i.
    1) Department
    2) Section
    There are many section in a single department. Both parameters are selected from list. The list for department name is as follows -
    select deptname from department_master order by deptname
    It works very well. The value is stored in :p_dept_name.
    I want to display section of selected department only using following code :-
    select sectname from section_master a, department_master b where a.deptcode = b.deptcode and b.deptname = :p_dept_name
    The value is stored in :p_sect_name.
    But it does not work. bind variables are not allowed in select statement, then how can I do this???
    Please suggest me.
    Thanx,
    Regards,

    Vikas,
    the forum is full of threads about that.
    Dependent Parameters in Reports are possible out-of-the-box in Reports.
    If you're running your report on the web, have a look at Metalink Note:185951.1
    Regards
    Rainer

  • Update_Task results in ORA-01006: bind variable does not exist - bug?

    Hi,
    I have successfuly created projects/tasks, and updated projects. However, when I tried to call pa_project_pub.update_task, I get an error
    U(nexpected):
    PROCEDURE_NAME update_one_task
    PKG_NAME PA_PROJECT_PVT
    FND FND_AS_UNEXPECTED_ERROR
    ERROR_TEXT ORA-01006: bind variable does not exist
    As far as I can see, this must be a bug, because the API must have created an excecute immediate/dbms_sql statement with at least one extra bind variable (i.e. execute '... :a, :b' using a, b, c)
    I've tried with different combinations of arguments to the API, all resulting in the same error:
    The id's and data are taken from a an already created project/task in my apps-instance:
    pa_project_pub.update_task(
    p_api_version_number => 1.0
    ,p_commit => xxpa_opop2pa_interface_utils.g_FALSE
    ,p_msg_count => l_msg_count
    ,p_msg_data => l_msg_data
    ,p_return_status => l_return_status
    ,p_pm_product_code => l_pm_product_code
    ,p_pm_project_reference => '100394'
    ,p_pm_task_reference => 'add_task_1.0'
    -- ,p_ref_task_id => ''
    ,p_task_number => 4
    -- ,p_pa_task_id => '19079'
    ,p_task_name => 'add_task_1.0'
    ,p_long_task_name => 'p_task_name'
    ,p_task_start_date => p_start_date
    ,p_task_completion_date => p_completion_date
    ,p_task_description => 'update-task:'||p_description
    ,p_out_pm_task_reference => l_out_pm_task_reference
    ,p_out_pa_task_id => p_task_id_out
    Am I missing anything, or this really must be a bug in the API?
    Does anyone have any other idea?
    I have looked at the API implementation, and found a use of dbms_sql, a long code constructing a statement then binding variables in if-then clauses.
    Regards,
    ps: ->
    system info
    Database Server
    RDBMS : 11.1.0.6.0
    Oracle Applications : 12.0.6
    System Date : 11-MAY-2009 10:41:50
    Forms Server
    Current Form
    Form Application : Application Object Library
    Form Name : FNDPOMPO
    Form Version : 12.0.2
    Form Last Modified : $Date: 2006/03/23 13:54 $
    Forms
    APPSTAND : 12.0.6.12000000.3
    FNDPOMPO : 12.0.2
    FNDSCSGN : 12.0.14.12000000.3
    Form Menus
    FNDMENU : 12.0.2
    Forms PL/SQL
    APPCORE : 12.0.21.12000000.13
    CUSTOM : 12.0.0
    FNDSQF : 12.0.3
    GHR : 12.0.22.12000000.26
    GLOBE : 12.0.62.12000000.13
    GMS : 12.0.42.12000000.11
    IGILUTIL2 : 12.0.24.12000000.3
    IGILUTIL : 12.0.1.12000000.3
    OPM : 12.0.7.12000000.2
    PQH_GEN : 12.0.7
    PSA : 12.0.17
    PSAC : 12.0.4.12000000.2
    PSB : 12.0.2
    VERT1 : 12.0.0
    VERT2 : 12.0.0
    VERT3 : 12.0.0
    VERT4 : 12.0.0
    VERT5 : 12.0.0
    VERT : 12.0.0
    **********************

    Hello,
    This issue is fixed in the bug 4692368. So you can get a patch from Oracle.
    Hope this helps !
    Thanks,
    Sathish
    www.projectsaccounting.com

  • Error: Bind Variable Does not Exist

    Hello,
    I am getting a bind error, Although I have only one bind variable, the debug output shows three bind parameters exist. Please let me know why this happens ?
    04/08/11 17:02:50 [5341] SELECT Property.PID, Property.CID, Property.REO, Property.MLS, Property.ADDRESS, Property.CITY, Property.STATE, Property.ZIP, Property.FAX, Property.TEL, Property.STYLE, Property.NROOMS, Property.NBEDS, Property.NBATHS, Property.SQFT, Property.AGE, Property.LPRICE, Property.LDATE, Property.EXPDATE, Property.FCDATE, Property.REDEMPTIONDATE, Property.MORTGAUGER, Property.FNAME, Property.FID, Property.BPOVALUE, Property.BPODATE, Property.WDATE, Property.TRASHOUT, Property.LAWNCARE, Property.REKEYED, Property.VACANCYSTATUS, Property.LOCKBOX, Property.PROPSTATUS, Property.LAGENT, Property.ENTRY, Property.USERID, Property.CONTACTID, Property.TAXID, Property.COBORR, Property.BORCONTACT FROM PROPERTY Property WHERE (Property.USERID = :1)
    04/08/11 17:02:50 [5342] Bind params for ViewObject: PropertyView1
    04/08/11 17:02:50 [5343] Binding param 1: 10097
    04/08/11 17:02:50 [5344] Binding param 2: 10097
    04/08/11 17:02:50 [5345] Binding param 3: 10097
    04/08/11 17:02:50 [5346] ViewObject: PropertyView1 close single-use prepared statements
    04/08/11 17:02:50 [5347] QueryCollection.executeQuery failed...
    04/08/11 17:02:50 [5348] java.sql.SQLException: ORA-01006: bind variable does not exist

    setWhereClauseParams must have been called on this VO to set more than required number of parameters. Could you check for that possibility?

  • Bind variable does not exist after processFormRequest

    Hello. I recieve the following stacktrace after doing a forward page immediately:
    pageContext.forwardImmediately("CAOADownload.jsp?transactionid=" + pageContext.getTransactionId() + "&retainAM=N",
    null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT,
    null,
    null,
    false,
    OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
    java.sql.SQLException: ORA-01006: bind variable does not exist
    The error is happening because of this line in the where clause:
    WHERE (PO_LINE_ID = :1)
    After the page forward it obviously looses what PO_LINE_ID contained. Is there a way to completely load the page from the JSP? Or a way to reload the VO in the processFormAction?
    Thanks, Graeme.

    Graeme.,
    Y don't u pass a page parameter say XXX with the value of line id when you redirect to same page? In that case u can execute query of the VO with the value of XXX, in process request, when u redirect to same page.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Java.sql.SQLException: ORA-01006: bind variable does not exist

    The java code is given below...
    /*UPDATE D9T652_DISBRSMNT_PRMTR
                        SET
                             Stmnt_Page_Wgt_Ozs = wtStatementStockSheet,
                        Chk_Page_Wgt_Ozs = wtCheckStockSheet,
                        Flat_Envelope_Wgt_Ozs = wtFlatEnv,
                        Half_Fold_Envelope_Wgt_Ozs = wtHalfFoldEnv,
                        Last_Chngd_By = TRIM(userId),
                        Last_Chngd_Dt = sysdate
                        WHERE
                             Ins_Sys_Id = Ins_Sys_Id_Constant_For_Compass AND
                             Last_Chngd_Dt = SELECT MAX(Last_Chngd_Dt)
              FROM D9T652_DISBRSMNT_PRMTR
              WHERE Ins_Sys_Id = Ins_Sys_Id_Constant_For_Compass
    updateDbPmtr= new StringBuffer(" UPDATE ")
    .append(SqlConst.PARAM)
    .append(" SET ")
    .append(SqlConst.PARAM).append(".").append(SqlConst.PARAM_DSBRSMNT_PRMTR_ID).append(" = 100, ")
    .append(SqlConst.PARAM).append(".").append(SqlConst.PARAM_MIN_DSBRSMNT_AMT).append(" = ? ").append(",")
    .append(SqlConst.PARAM).append(".").append(SqlConst.PARAM_OVRRD_MIN_DSBRSMNT_DT).append(" = ").append(currentTimeStamp).append(",")
    .append(SqlConst.PARAM).append(".").append(SqlConst.PARAM_SPCL_HNDLG_AMT).append(" = ? ").append(", ")
    .append(SqlConst.PARAM).append(".").append(SqlConst.PARAM_STMNT_DT).append(" = ").append(currentTimeStamp).append(" , ")
    .append(SqlConst.PARAM).append(".").append(SqlConst.PARAM_LAST_CHNGD_BY).append(" ='?' ").append(" , ")
    .append(SqlConst.PARAM).append(".").append(SqlConst.PARAM_LAST_CHNGD_DT).append(" = ").append(currentTimeStamp)
    .append(" WHERE ")
    .append(SqlConst.PARAM).append(".").append(SqlConst.PARAM_INS_SYS_ID).append(" = ? ")
    .append(" AND ")
    .append(SqlConst.PARAM).append(".").append(SqlConst.PARAM_LAST_CHNGD_DT)
    .append(" = ")
    .append(" ( SELECT ")
    .append(" MAX( ").append(SqlConst.PARAM_LAST_CHNGD_DT).append(" ) ")
    .append(" FROM ").append(SqlConst.PARAM)
    .append(" WHERE ")
    .append(SqlConst.PARAM_INS_SYS_ID).append(" = ? )").toString();
    conn = SqlUtil.getConnection();
    conn.setAutoCommit(false);     
    prepStmtDsbrsmntPmtr = conn.prepareStatement(updateDbPmtr);                     
    prepStmtStckWght      = conn.prepareStatement(updateStkWght);
                        String minDsbrsmntAmount     = parametersListForm.getParametersForm().getMinDisbursementAmt();
                        String specialHndlAmount     = parametersListForm.getParametersForm().getSpecialHandlingAmt();
                        String statementDt               = parametersListForm.getParametersForm().getStatementDate();
                        String overrideCycleDt          = parametersListForm.getParametersForm().getOverrideCycleDate();
                        String lastMdfdBy               = parametersListForm.getParametersForm().getLastModifiedBy();
                        String lastMdfdDt               = parametersListForm.getParametersForm().getLastModifiedDate();
                        String wtStmtStkSheet          = parametersListForm.getParametersForm().getWtStatementStockSheet();
                        String wtHlfFoldEnvelope     = parametersListForm.getParametersForm().getWtHalfFoldEnv();
                        String wtFltEnvelope          = parametersListForm.getParametersForm().getWtFlatEnv();
                        String wtChkStkSheet          = parametersListForm.getParametersForm().getWtCheckStockSheet();
    prepStmtDsbrsmntPmtr.setLong(1,Integer.parseInt(minDsbrsmntAmount));
    prepStmtDsbrsmntPmtr.setLong(2, Long.parseLong(specialHndlAmount));
    prepStmtDsbrsmntPmtr.setString(3,lastMdfdBy);
    prepStmtDsbrsmntPmtr.setLong(4,1);
    prepStmtDsbrsmntPmtr.setLong(5,1);
    int rUpdtInParam = prepStmtDsbrsmntPmtr.executeUpdate();
    ========================================================================
    I am getting following errors...
    [8/6/04 19:17:14:286 GMT+05:30] 19192340 SystemErr R java.sql.SQLException: ORA-01006: bind variable does not exist
    [8/6/04 19:17:14:302 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:314)
    [8/6/04 19:17:14:317 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:117)
    [8/6/04 19:17:14:349 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:306)
    [8/6/04 19:17:14:364 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:43)
    [8/6/04 19:17:14:380 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:41)
    [8/6/04 19:17:14:411 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:941)
    [8/6/04 19:17:14:427 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:662)
    [8/6/04 19:17:14:442 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:214)
    [8/6/04 19:17:14:474 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:135)
    [8/6/04 19:17:14:489 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:227)
    [8/6/04 19:17:14:505 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:72)
    [8/6/04 19:17:14:536 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:190)
    [8/6/04 19:17:14:552 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:406)
    [8/6/04 19:17:14:567 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:57)
    [8/6/04 19:17:14:583 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:461)
    [8/6/04 19:17:14:614 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:414)
    [8/6/04 19:17:14:630 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:614)
    [8/6/04 19:17:14:661 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:57)
    [8/6/04 19:17:14:677 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:461)
    [8/6/04 19:17:14:692 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:414)
    [8/6/04 19:17:14:708 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:614)
    [8/6/04 19:17:14:739 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:414)
    [8/6/04 19:17:14:755 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:614)
    [8/6/04 19:17:14:770 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:414)
    [8/6/04 19:17:14:802 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:614)
    [8/6/04 19:17:14:817 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:414)
    [8/6/04 19:17:14:833 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:614)
    [8/6/04 19:17:14:864 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:190)
    [8/6/04 19:17:14:880 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:406)
    [8/6/04 19:17:14:896 GMT+05:30] 19192340 SystemErr R      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:614)
    ========================================================================
    Database Table:-
    Desc D9T651_DSBRSMNT_PRMTR:
    Name Null? Type
    DSBRSMNT_PRMTR_ID NOT NULL NUMBER(38)
    INS_SYS_ID NUMBER(38)
    MIN_DSBRSMNT_AMT NUMBER(15,2)
    OVRRD_MIN_DSBRSMNT_DT DATE
    SPCL_HNDLG_AMT NUMBER(15,2)
    STMNT_DT DATE
    CRTD_BY VARCHAR2(30)
    CRTD_DT DATE
    LAST_CHNGD_BY VARCHAR2(30)
    LAST_CHNGD_DT DATE

    What exactly are you trying to do? If you're trying to run an update statement, it's simpler if you do this:
    PreparedStatement pstmt = null;
    Connection conn = ?????;
    String updateStr = "UPDATE D9T652_DISBRSMNT_PRMTR " +
    "SET " +
    "Stmnt_Page_Wgt_Ozs = ?, " +
    "Chk_Page_Wgt_Ozs = ?, " +
    "Flat_Envelope_Wgt_Ozs = ?, " +
    "Half_Fold_Envelope_Wgt_Ozs = ?, " +
    "Last_Chngd_By = TRIM(?), " +
    "Last_Chngd_Dt = ? " +
    "WHERE " +
    "Ins_Sys_Id = Ins_Sys_Id_Constant_For_Compass AND " +
    "Last_Chngd_Dt = (SELECT MAX(Last_Chngd_Dt) " +
    "FROM D9T652_DISBRSMNT_PRMTR " +
    "WHERE Ins_Sys_Id = Ins_Sys_Id_Constant_For_Compass) "
    From the String constructed above, the first ? mark will be bind to 1, second to 2..... etc and you can set the appropriate types.
    pstmt = conn.prepareStatement(updateStr);
    pstmt.setString(1, request.getParameter("formValue1")); // this is assuming you want to store string value in DB field
    pstmt.setInt(2, Integer.parseInt(request.getParameter("formValue2"))); // this is assuming you want to store int value in DB field
    pstmt.setTimestamp(3, new java.sql.Timestamp(new java.util.Date().getTime())); // this is assuming you want to store current time in DB Date field
    ..... etc
    ..... etc
    ...... etc
    int rows = pstmt.executeUpdate();
    Hope this helps!!

Maybe you are looking for

  • I have a MacBook Air, Late 2010 and would like to make complete copy of, what is best method?

    I have a MacBook Air, Late 2010, and would like to make a complete copy of everything on it. Unsure sure of best external device to purchase or if possible? Can you assist? Thanks

  • Is the Preview Window always an accurate representation?

    CS3. Two issues: 1. 1920x1080 menu with 1920x1080 motion background(mpeg file). The menu file has an outline as well as drop shadow effect created in Photoshop. However, in the preview window, the outline and drop shadow look different(see example).

  • Where do I find iPod updater download???

    Can anyone help please? iTunes tells me I can't copy music to my iPod anymore until I download the latest iPod updater. I can't find it on this page: http://www.apple.com/ipod/download/. Page doesn't seem to be downloading properly and can't find a '

  • Solaris/JVM/JNI crashes

    Hello, I am experiencing periodic crashes in an application while using Solaris 2.8 and JVM 1.3.0. The application is invoking multi-threaded java code from C++ and the conflict causing the crashes seems to be in how the threads are being handled. Is

  • Worked in 1.2 and 1.3 but strange problem in 1.4

    While connecting to https url through web browser with 1.2 and 1.3 java plugin every thing seems to work perfectly. But I get these errors with 1.4 plugin. I get the error while doing these steps are happening 1) type the https url on the browser and