Bind Variable In Case Statement Produces Error ORA-01036

When running the following command using ODP.Net 10.1.0.301 I recieve error 1036. Statement runs fine within SQL+ and Toad.
Dim SQL As String = "SELECT CASE WHEN EXISTS(SELECT part_nbr FROM item_master WHERE part_nbr=:part_number) THEN 1 ELSE 0 END AS RECORD_EXISTS FROM Dual"
Dim OraConnection As New OracleConnection(connectstring)
Dim OraCommand As New OracleCommand(SQL, OraConnection)
OraCommand.Parameters.Add("part_number", OracleDbType.Varchar2).Value = PartNumber
Dim Obj as Object=OraCommand.ExecuteScalar

Hi Michael,
I was able to get your code to work on my system by changing the SQL statement as follows:
SELECT (CASE WHEN EXISTS(SELECT part_nbr FROM item_master WHERE part_nbr=:part_number) THEN 1 ELSE 0 END) AS RECORD_EXISTS FROM Dual
I simply enclosed the case statement in opening and closing parenthesis...
Hope that helps,
- Mark

Similar Messages

  • Creating view containing case statements received error ORA-22992

    We have a create view referencing table through dblink. The select statement in the create view has case statements, when running the Select statement alone, results are return. However, when executing the create view, it returns:
    SQL Error: ORA-22992: cannot use LOB locators selected from remote tables
    22992. 00000 - "cannot use LOB locators selected from remote tables"
    *Cause:    A remote LOB column cannot be referenced.
    *Action:   Remove references to LOBs in remote tables.
    One of the source table has LOB column but not in the select statement. The strange thing is when removing the case statement from the select, create view works fine. Can anybody tell me what caused the error and how to fix it?
    Create View Snippet:
    CREATE OR REPLACE VIEW "ABC"."XYZ" (....
    AS SELECT
    CASE
    WHEN A.OUTAGE =1
    THEN 'Y'
    ELSE 'N'
    END AS OUTAGE,
    FROM
    TABLEA@XXXX A
    LEFT JOIN TABLEB@XXXX B
    ON
    A.LOC =B.LO
    AND A.SITE =B.SITE
    WHERE
    A.CLASS ='CUSTOMER'
    AND A.PLUSSISGIS =1;

    What is your 4 digit Oracle version?
    Try rewriting the query to not use ANSI SQL92 joins. I found a link where this solved a problem similar to yours.
    DBLink problem ORA-22992
    >
    But, look at this curious thing: I re-write the query as follows:
    SELECT A.ID, A.ID_REF, A.EVENDATE, B.DESCRIPTION
    FROM A@ORCL A, B@ORCL B
    WHERE A.ID_REF = B.ID_REF;
    and it works fine... It seems like Oracle don't like the ANSI SQL92...
    >
    Several similar links by googling: 'SQL Error: ORA-22992'
    http://www.dbuggr.com/smallwei/solution-error-ora-22992-lob-locators-selected-remote-tabl/
    >
    Fixing ORA-22992 “cannot use LOB locators selected from remote tables” error
    You have migrated your Oracle 9i database to 10g and a distributed statement which worked fine in 9i now is getting error ORA-22992 “cannot use LOB locators selected from remote tables”. Even though the related remote table(s) does not contain any LOB column datatype.
    FIX:
    There is a bug on 9i,10g, and 11g that is related to this error. It is being fixed in 11.2. It can also be backported for previous 9i, 10g and 11g releases under the latest patchsets.
    You may also do a workaround as follow:
    Modify the affected SQL by adding the TO_CHAR function. For example:
    -- Original SQL:
    SELECT NVL2('a', 'b','c' ) FROM dual@remote_db;
    -- Modified SQL:
    SELECT TO_CHAR(NVL2('a','b','c')) FROM dual@remote_db;
    >
    See if that helps.

  • Bind Variable in SELECT statement and get the value  in PL/SQL block

    Hi All,
    I would like  pass bind variable in SELECT statement and get the value of the column in Dynamic SQL
    Please seee below
    I want to get the below value
    Expected result:
    select  distinct empno ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    100, HR
    select  distinct ename ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    TEST, HR
    select  distinct loc ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    NYC, HR
    Using the below block I am getting column names only not the value of the column. I need to pass that value(TEST,NYC..) into l_col_val variable
    Please suggest
    ----- TABLE LIST
    CREATE TABLE EMP(
    EMPNO NUMBER,
    ENAME VARCHAR2(255),
    DEPT VARCHAR2(255),
    LOC    VARCHAR2(255)
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (100,'TEST','HR','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (200,'TEST1','IT','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (300,'TEST2','MR','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (400,'TEST3','HR','DTR');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (500,'TEST4','HR','DAL');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (600,'TEST5','IT','ATL');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (700,'TEST6','IT','BOS');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (800,'TEST7','HR','NYC');
    COMMIT;
    CREATE TABLE COLUMNAMES(
    COLUMNAME VARCHAR2(255)
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('EMPNO');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('ENAME');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('DEPT');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('LOC');
    COMMIT;
    CREATE TABLE DEPT(
    DEPT VARCHAR2(255),
    DNAME VARCHAR2(255)
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('HR','HUMAN RESOURCE');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('MR','MARKETING');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
    COMMIT;
    PL/SQL BLOCK
    DECLARE
      TYPE EMPCurTyp  IS REF CURSOR;
      v_EMP_cursor    EMPCurTyp;
      l_col_val           EMP.ENAME%type;
      l_ENAME_val       EMP.ENAME%type;
    l_col_ddl varchar2(4000);
    l_col_name varchar2(60);
    l_tab_name varchar2(60);
    l_empno number ;
    b_l_col_name VARCHAR2(255);
    b_l_empno NUMBER;
    begin
    for rec00 in (
    select EMPNO aa from  EMP
    loop
    l_empno := rec00.aa;
    for rec in (select COLUMNAME as column_name  from  columnames
    loop
    l_col_name := rec.column_name;
    begin
      l_col_val :=null;
       l_col_ddl := 'select  distinct :b_l_col_name ,pr.dept ' ||'  from emp pr, dept ps where   ps.dept like ''%IT'' '||' and pr.empno =:b_l_empno';
       dbms_output.put_line('DDL ...'||l_col_ddl);
       OPEN v_EMP_cursor FOR l_col_ddl USING l_col_name, l_empno;
    LOOP
        l_col_val :=null;
        FETCH v_EMP_cursor INTO l_col_val,l_ename_val;
        EXIT WHEN v_EMP_cursor%NOTFOUND;
          dbms_output.put_line('l_col_name='||l_col_name ||'  empno ='||l_empno);
       END LOOP;
    CLOSE v_EMP_cursor;
    END;
    END LOOP;
    END LOOP;
    END;

    user1758353 wrote:
    Thanks Billy, Would you be able to suggest any other faster method to load the data into table. Thanks,
    As Mark responded - it all depends on the actual data to load, structure and source/origin. On my busiest database, I am loading on average 30,000 rows every second from data in external files.
    However, the data structures are just that - structured. Logical.
    Having a data structure with 100's of fields (columns in a SQL table), raise all kinds of questions about how sane that structure is, and what impact it will have on a physical data model implementation.
    There is a gross misunderstanding by many when it comes to performance and scalability. The prime factor that determines performance is not how well you code, what tools/language you use, the h/w your c ode runs on, or anything like that. The prime factor that determines perform is the design of the data model - as it determines the complexity/ease to use the data model, and the amount of I/O (the slowest of all db operations) needed to effectively use the data model.

  • Bind Variables in SQL Statement

    can someone tell me if there is a way to find out what the bind variables values are in an sql statement extracted from any of the v$sql or v$sqlarea type tables ?
    sql example:
    update DTree set OriginOwnerID=:A
    where OriginOwnerID=:B and OriginDataID=:C
    Thanks
    Jim

    Hi damorgan
    i see two ot of the three:
    SQL> desc gv$sql_bind_capture
    ERROR:
    ORA-04043: object gv$sql_bind_capture does not exist
    i just trying to see what bind variable values would be associated with the sql when i extract the sql from v$sql and if that is even possible
    Thanks
    Jim

  • ADF jdev10: SQL TRUNC with bind variable in sql statement in VO

    Hi,
    In VO in where clause:
    TRUNC(ServiceRequest.REQUEST_DATE) > :MyDate works fine!
    But TRUNC(ServiceRequest.REQUEST_DATE) > TRUNC(:MyDate) doesn't work!
    "SQL Query Error Message: ORA-00932: inconsistient datatypes: expected DATE got NUMBER"
    How to use TRUNC function for a bind variable?

    Basementjack,
    Any of these solutions that you are doing have possible performance implications in the database side, as you are applying a function to a database column; this is generally going to preclude the use of an index.
    Assuming that you are trying to find service requests that were before the date that is being passed in in the bind variable, and assuming that both the bind variable and service request date can have time components, you could try:
    ServiceRequest.REQUEST_DATE <= TO_DATE(trunc(:MyDate) - 1/86400)Does this do what you want?
    John

  • SQL Expression Field - Combine Declared Variable With Case Statement

    Hello All, I have been using Crystal & Business Objects for a few months now and have figured out quite a bit on my own. This is the first real time I have struggled with something and while I could do this as a Formula Field I would like to know how to do this as a SQL Expression. Basically I want to create a SQL Expression that uses a CASE statement but I wanted to make the code a little more efficient and employ a variable to hold a string and then use the variable in the CASE statement. The expression editor accepts the CASE statement OK but I don't know how to declare the variable. Please assist with the syntax?
    This is what I have:
    CASE
       WHEN u201CDatabaseu201D.u201DFieldu201D = u2018Hu2019 THEN u2018Hedgeu2019
       WHEN u201CDatabaseu201D.u201DFieldu201D = u2018Pu2019 THEN u2018PVIu2019
       ELSE u2018Noneu2019
    END
    This is what I want:
    DECLARE strVar AS VARCHAR(25)
    strVar =  u201CDatabaseu201D.u201DFieldu201D
    CASE
       WHEN strVar = u2018Hu2019 THEN u2018Hedgeu2019
       WHEN strVar = u2018Pu2019 THEN u2018PVIu2019
       ELSE u2018Noneu2019
    END

    Hi Todd,
    Please use the following for loop; your problem will be solved.
    Local StringVar str := "";
    Local NumberVar strLen := Length ({Database.Field});
    Local NumberVar i;
    For i := 1 To strLen Do
           if {Database.Field} <i> = "H" then str := "Hedge"
            else if {Database.Field} <i> = "P" then str := "PVI"
            else str := "None"; exit for
    str
    Let me know once done!
    Thank you,
    Ashok

  • External table and error: ORA-01036: illegal variable name/number

    using the following script I get the referenced error:
    create table dol_sch_c_part2
    (DLN NUMBER(14) ,
    PAGE_ID VARCHAR2(20),
    PAGE_SEQ VARCHAR2(20),
    PAGE_ROW_NUM VARCHAR2(20),
    ROW_NUM VARCHAR2(20),
    IMAGE_FORM_ID VARCHAR2(20),
    PROVIDER_TERM_01_NAME VARCHAR2(35),
    PROVIDER_TERM_01_EIN VARCHAR2(9) ,
    PROVIDER_TERM_01_POSITION VARCHAR2(25),
    PROVIDER_TERM_01_STR_ADDRESS VARCHAR2(35),
    PROVIDER_TERM_01_CITY VARCHAR2(20),
    PROVIDER_TERM_01_STATE VARCHAR2(2),
    PROVIDER_TERM_01_ZIP_CODE VARCHAR2(9),
    PROVIDER_TERM_01_PHONE_NUM VARCHAR2(10),
    PROVIDER_TERM_01_TEXT VARCHAR2(250)
    ORGANIZATION EXTERNAL
    ( type oracle_loader
    default directory data_dir
    access parameters
    RECORDS FIXED 510
    FIELDS
    DLN(1:14) char(14),
    PAGE_ID(15:34) char(20) NULLIF PAGE_ID=BLANKS,
    PAGE_SEQ(35:54) char(20) NULLIF PAGE_SEQ=BLANKS,
    PAGE_ROW_NUM(55:74) char(20) NULLIF PAGE_ROW_NUM=BLANKS,
    ROW_NUM(75:94) char(20) NULLIF ROW_NUM=BLANKS,
    IMAGE_FORM_ID(95:114) char(20) NULLIF IMAGE_FORM_ID=BLANKS,
    PROVIDER_TERM_01_NAME(115:149) char(35) NULLIF PROVIDER_TERM_01_NAME=BLANKS,
    PROVIDER_TERM_01_EIN(150:158) char(9) NULLIF PROVIDER_TERM_01_EIN=BLANKS,
    PROVIDER_TERM_01_POSITION(159:183) char(25) NULLIF PROVIDER_TERM_01_POSITION=BLANKS,
    PROVIDER_TERM_01_STR_ADDRESS(184:218) char(35) NULLIF PROVIDER_TERM_01_STR_ADDRESS=BLANKS,
    PROVIDER_TERM_01_CITY(219:238) char(20) NULLIF PROVIDER_TERM_01_CITY=BLANKS,
    PROVIDER_TERM_01_STATE(239:240) char(2) NULLIF PROVIDER_TERM_01_STATE=BLANKS,
    PROVIDER_TERM_01_ZIP_CODE(241:249) char(9) NULLIF PROVIDER_TERM_01_ZIP_CODE=BLANKS,
    PROVIDER_TERM_01_PHONE_NUM(250:259) char(10) NULLIF PROVIDER_TERM_01_PHONE_NUM=BLANKS,
    PROVIDER_TERM_01_TEXT(260:509) char(250) NULLIF PROVIDER_TERM_01_TEXT=BLANKS
    location ('f_dol_sch_c_part2.txt')
    I've tried it with and without the char(*) in the fields section - no change
    thanks

    *** SCRIPT START : Session:GLEN_SELF@RAMBO(8) 8/31/2006 12:16:48 PM ***
    Processing ...
    create or replace directory data_dir as 'c:\dol\'
    create table dol_sch_c_part2
    (DLN NUMBER(14) ,
    PAGE_ID VARCHAR2(20),
    PAGE_SEQ VARCHAR2(20),
    PAGE_ROW_NUM VARCHAR2(20),
    ROW_NUM VARCHAR2(20),
    IMAGE_FORM_ID VARCHAR2(20),
    PROVIDER_TERM_01_NAME VARCHAR2(35),
    PROVIDER_TERM_01_EIN VARCHAR2(9),
    PROVIDER_TERM_01_POSITION VARCHAR2(25),
    PROVIDER_TERM_01_STR_ADDRESS VARCHAR2(35),
    PROVIDER_TERM_01_CITY VARCHAR2(20),
    PROVIDER_TERM_01_STATE VARCHAR2(2),
    PROVIDER_TERM_01_ZIP_CODE VARCHAR2(9),
    PROVIDER_TERM_01_PHONE_NUM VARCHAR2(10),
    PROVIDER_TERM_01_TEXT VARCHAR2(250)
    ORGANIZATION EXTERNAL
    ( type oracle_loader
    default directory data_dir
    logfile 'ext_tab.log'
    access parameters
    RECORDS FIXED 510
    FIELDS
    DLN(1:14),
    PAGE_ID(15:34),
    PAGE_SEQ(35:54),
    PAGE_ROW_NUM(55:74),
    ROW_NUM(75:94),
    IMAGE_FORM_ID(95:114),
    PROVIDER_TERM_01_NAME(115:149),
    PROVIDER_TERM_01_EIN(150:158),
    PROVIDER_TERM_01_POSITION(159:183),
    PROVIDER_TERM_01_STR_ADDRESS(184:218),
    PROVIDER_TERM_01_CITY(219:238),
    PROVIDER_TERM_01_STATE(239:240),
    PROVIDER_TERM_01_ZIP_CODE(241:249),
    PROVIDER_TERM_01_PHONE_NUM(250:259),
    PROVIDER_TERM_01_TEXT(260:509)
    location ('f_dol_sch_c_part2.txt')
    create or replace directory data_dir as 'c:\dol\'
    ORA-01036: illegal variable name/number
    *** Script stopped due to error ***
    *** SCRIPT END : Session:GLEN_SELF@RAMBO(8) 8/31/2006 12:16:49 PM ***

  • Using bind variables with sql statements

    We connect from a VB 6.0 program via OO4O to an Oracle 8.1.7 database, using bind variables in connection with select statements. Running ok, but performance again by using bind vars not as good as expected!
    When looking into the table v$sqlarea, we were able to detect the reason. We expected that our program submits the sql statement with bind vars, Oracle parses this once, and with each select statement again, we do not have a reparse. But: It seems that with each new session Oracle reparses the sql statement, that is, Oracle is not able to memorize or cache bind vars and statements. Even more worrying, this kind of behaviour was visible with each new dynaset, but the same database/session.
    Is there anybody our there with an idea of what is happening here?
    Code snippet:
    Dim OraSession As OracleInProcServer.OraSessionClass
    Dim OraDatabase As OracleInProcServer.OraDatabase
    Set OraSession = CreateObject("OracleInProcServer.XOraSession")
    Set OraDatabase = OraSession.OpenDatabase(my database", "my connect", 0&)
    OraDatabase.Parameters.Add "my_bind", 0, ORAPARM_INPUT
    OraDatabase.Parameters("my_bind").DynasetOption = ORADYN_NOCACHE
    OraDatabase.Parameters("my_bind").serverType = ORATYPE_NUMBER ' Bind Var Type
    Dim RS As OracleInProcServer.OraDynaset
    strSQLstatement= "Select * from my_table where igz= [my_bind] "
    Set RS = OraDatabase.CreateDynaset(strSQLstatement, &H4)
    OraDatabase.Parameters("my_bind").Value = myValue
    RS.Refresh
    Cheers and thanks a lot :)
    Michael Sonntag

    We connect from a VB 6.0 program via OO4O to an Oracle 8.1.7 database, using bind variables in connection with select statements. Running ok, but performance again by using bind vars not as good as expected!
    When looking into the table v$sqlarea, we were able to detect the reason. We expected that our program submits the sql statement with bind vars, Oracle parses this once, and with each select statement again, we do not have a reparse. But: It seems that with each new session Oracle reparses the sql statement, that is, Oracle is not able to memorize or cache bind vars and statements. Even more worrying, this kind of behaviour was visible with each new dynaset, but the same database/session.
    Is there anybody our there with an idea of what is happening here?
    Code snippet:
    Dim OraSession As OracleInProcServer.OraSessionClass
    Dim OraDatabase As OracleInProcServer.OraDatabase
    Set OraSession = CreateObject("OracleInProcServer.XOraSession")
    Set OraDatabase = OraSession.OpenDatabase(my database", "my connect", 0&)
    OraDatabase.Parameters.Add "my_bind", 0, ORAPARM_INPUT
    OraDatabase.Parameters("my_bind").DynasetOption = ORADYN_NOCACHE
    OraDatabase.Parameters("my_bind").serverType = ORATYPE_NUMBER ' Bind Var Type
    Dim RS As OracleInProcServer.OraDynaset
    strSQLstatement= "Select * from my_table where igz= [my_bind] "
    Set RS = OraDatabase.CreateDynaset(strSQLstatement, &H4)
    OraDatabase.Parameters("my_bind").Value = myValue
    RS.Refresh
    Cheers and thanks a lot :)
    Michael Sonntag

  • Using "as" in DUAL statement produces error

    Hi,
    SELECT 'abcefghijklm' AS str FROM DUAL WHERE str IN ('a','e','i','o','u');
    This produces an error message - "STR": invalid identifier
    Is such a comparison using a field name invented using "as" always invalid - is there no way around it?
    What I am trying to do is to count the number of vowels in a sentence, there may be a better approach of course, if anyone knows one...?

    What I am trying to do is to count the number of vowels in a sentence
    SQL> select word_char,count(*) from (SELECT substr(str,ROWNUM,1) AS word_char
      2  FROM (SELECT 'abcefghijklmabcefghijklmno' as str FROM DUAL) CONNECT BY LEVEL <= length(str))
      3  where word_char IN ('a','e','i','o','u') group by word_char order by word_char;
    W   COUNT(*)
    a          2
    e          2
    i          2
    o          1
    SQL>
    SQL> select length(str) - length(replace(translate(lower(str),'aeiou',' '),' ','')) cnt
      2  from (SELECT 'abcefghijklmabcefghijklm' as str FROM DUAL);
           CNT
             6
    SQL>
    SQL>

  • Query Errors:  ORA-01036: illegal variable name/number

    Hi All,
    When I run a query against two tables within our data warehouse I am getting an IO Exception. Due to company restrictions I can't quickly increase my IO Limit So what I have done is written a query that cycles through all of the large tables partitions and extracts the data.
    The problem I get is that when I run this query in Toad. It thinks my :MI, :SS are variables and wont run this. Does anyone know what I can do to resolve this issue?
    create table completion_log
      action_complate_dt        date,
      table_name                   varchar2(1000),
      partition_number            varchar2(1000)
    nologging
    compress ;
    create table  STORE_DATA_HERE
      field_1                varchar2(1000),
      field_2                date,
      field_3                varchar2(1000)
    nologging
    compress ;
    commit;
    begin
       for ptn in (select partition_name p from all_tab_partitions t where table_name='REALLY_LARGE_TABLE')
       loop
          execute immediate q'^
          insert /*+ APPEND */ into STORE_DATA_HERE
            SELECT  field_1,
                    field_2,
                    field_3      
              FROM  REALLY_LARGE_TABLE partition (^'||ptn.p||q'^)
             WHERE  field_3 IN (  'XXXX',  'YYYY')
                    AND data_date BETWEEN TO_DATE('07/12/2011 00:00:00', 'DD/MM/YYYY HH24:MI:SS')
                            AND TO_DATE('08/12/2011 23:59:59', 'DD/MM/YYYY HH24:MI:SS')
          ^';
         insert into completion_log values (sysdate,'STORE_DATA_HERE',ptn.p);
         commit;
       end loop;
    end;

    In your case it is quite easy...
    just remove the collons from the format and the literal...and off you go
    begin
       for ptn in (select partition_name p from all_tab_partitions t where table_name='REALLY_LARGE_TABLE')
       loop
          execute immediate q'^
          insert /*+ APPEND */ into STORE_DATA_HERE
            SELECT  field_1,
                    field_2,
                    field_3      
              FROM  REALLY_LARGE_TABLE partition (^'||ptn.p||q'^)
             WHERE  field_3 IN (  'XXXX',  'YYYY')
                    AND data_date BETWEEN TO_DATE('07/12/2011 000000', 'DD/MM/YYYY HH24MISS')
                            AND TO_DATE('08/12/2011 235959', 'DD/MM/YYYY HH24MISS')
          ^';
         insert into completion_log values (sysdate,'STORE_DATA_HERE',ptn.p);
         commit;
       end loop;
    end;

  • ORA-06537 OUT bind variable bound to an IN position

    Sir,
    we have migrated our database from oracle 9i to 10g (Release 10.1.0.2.0)..
    but while executing a procedure we are getting the following error
    ORA-06537:OUT bind variable bound to an IN position
    this same procedure is not throwing any error wen we connect the 9i database
    we are giving two parameters for this procedure
    in that second one is an IN OUT Parameter
    another procedure which use the same parameters working properly in 10g and 9i.
    we are using PowerBuilder 10 as front end
    plz help me to get ride of this prob...

    You get that error even in 9i if the parameters to the procedure calls are not bound correctly. Check the powerbuilder application to make sure it is binding the parameter types correctly.
    SQL> create or replace procedure proc(p_in IN NUMBER, p_out IN OUT NUMBER) is
      2  begin
      3      null ;
      4  end ;
      5  /
    Procedure created.
    SQL> declare
      2    l_var1 NUMBER ;
      3    l_var2 NUMBER ;
      4  begin
      5    execute immediate 'begin proc(:in, :out) ; end ;' using OUT l_var1, OUT l_var2 ;
      6  end ;
      7  /
    declare
    ERROR at line 1:
    ORA-06537: OUT bind variable bound to an IN position
    ORA-06512: at line 5
    SQL> declare
      2    l_var1 NUMBER ;
      3    l_var2 NUMBER ;
      4  begin
      5    execute immediate 'begin proc(:in, :out) ; end ;' using IN l_var1, OUT l_var2 ;
      6  end ;
      7  /
    declare
    ERROR at line 1:
    ORA-06537: OUT bind variable bound to an IN position
    ORA-06512: at line 5
    SQL> declare
      2    l_var1 NUMBER ;
      3    l_var2 NUMBER ;
      4  begin
      5    execute immediate 'begin proc(:in, :out) ; end ;' using IN l_var1, IN OUT l_var2 ;
      6  end ;
      7  /
    PL/SQL procedure successfully completed.
    SQL> disconnect
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.3.0 - Production
    SQL>

  • Error bind variable with "like %" clause ?

    Hello everybody;
    I would like to know how to do a like clause to bind variables, with this code i obtain 'ORA-00933: SQL command not properly ended' error
    v_query:= 'UPDATE ' || collection(i) ||' SET REF_PLAN=:quatre_champ WHERE FAM_SIM like ''%'':prem_champ''%'' AND PRISE_V1P like ''%'':deux_champ''%'' AND BROCHE_V1P like ''%:trois_champ%''';
                                  EXECUTE IMMEDIATE v_query USING quatre_champ,prem_champ,deux_champ,trois_champ;Maybe my " ' " are in a bad positions ?
    Thanks for your help, regards.

    Hi,
    try this
    v_query :=
             'UPDATE '
          || collection (i)
          || ' SET REF_PLAN =:quatre_champ WHERE FAM_SIM like'|| '''%:prem_champ%'''
          || ' AND PRISE_V1P like' || ''' %:deux_champ%'''
          || ' AND BROCHE_V1P like'||''' %:trois_champ%;'''
    Of course not tested
    Any efforts to give sample data and help us recreated the problem will be appreciated.
    Cheers!!!
    Bhushan

  • Bind Variables...Urgent

    Thanks!
    I build a SQL statement, PARSE and Execute...
    Begin :l_result := Test(pa01=>':pa01',pa02=>':pa02'); End;
    I am binding ':pa01', ':pa02'
    When I try to Bind variables, it throws error "ORA-01036 illegal variable name/number".
    Do I need to install any patch - current version Forms [32 Bit] Version 6.0.8.17.1 (Production)

    Placeholders (:name) are bound by position in EXECUTE IMMEDIATE SQL statement. Hence Oracle does not consider multiple :p_comp_id in your statement to be the same thing. You would need to repeatedly bind them for each occurrence, or use an approach (DBMS_SQL.BIND_VARIABLE or EXECUTE IMMEDIATE PL/SQL block) which binds by name or position / name.
    In the case of the above example you would have a USING clause similar to the below (Note that I am unable to test this).
    EXECUTE IMMEDIATE sql_statement
       USING p_comp_id, p_comp_id, p_site_id,
          p_site_id, p_task_type, p_comp_id,
          p_po_no, p_ebiz_sku_no, p_sku_status,
          p_lp, p_batch_no, p_comp_id;

  • Case statement in 9i/8i

    I want to be able to run a select conditionally. I have gotten this far.
    SQL> select
    2 (case
    3 when (select count(*) from all_objects
    4 where owner = 'SYS' and object_name = 'DBA_REGISTRY') >= 1
    5 then
    6 ( select rpad(substr(comp_name,1,50),50,' ')||' '||rpad(status,15,' ')||' '||substr(version,1,10) from dba_registry)
    7 else
    8 ( select 'dba_registry does not exist.' from dual)
    9 end)
    10 from dual;
    ( select rpad(substr(comp_name,1,50),50,' ')||' '||rpad(status,15,' ')||' '||substr(version,1,10) from dba_registry)
    ERROR at line 6:
    ORA-00942: table or view does not exist
    The 'dba_registry' does not exist in 8i but does in 9i.
    When it is run in 9i the error becomes:
    ORA-1427 Singe-row subquery returns more than one row.
    Basically I want to check for existance of an object and perform some action (not to difficult in PL/SQL using execute immediate - unless the action is to select and return multiple rows) using code that will execute on both 8i & 9i databases.
    Any pointers please?

    Env = 9i
    undefine c
    set serveroutput on size 100000
    connect / as sysdba
    grant select on dba_registry to ops$oracle;
    grant select on dba_objects to ops$oracle;
    connect /
    create or replace package vs_types
    as
    type cursorType is ref cursor;
    end;
    show errors
    create or replace procedure vs_getdata ( p_cursor in out vs_types.cursorType)
    is
    findresult number;
    dba_registry1 varchar2(20);
    begin
    dba_registry1:='dba_registry';
    select count(*) into findresult from dba_objects where owner = 'SYS' and object_name = 'DBA_REGISTRY';
    dbms_output.put_line('findresult='||findresult);
    dbms_output.put_line('dba_registry1='||dba_registry1);
    if findresult > 0
    then
    open p_cursor for
    select rpad(substr(comp_name,1,50),50,' ')||' '||rpad(status,15,' ')||' '||substr(version,1,10) from dba_registry;
    else
    open p_cursor for
    select 'Dba_registry does not exist in 8i.' from dual;
    end if;
    end;
    show errors
    variable c refcursor
    exec vs_getdata(:c)
    print c
    drop package vs_types;
    drop procedure vs_getdata;
    ~
    ~
    ~
    ~
    ~
    "x3a.sql" 37 lines, 989 characters
    SQL> @x3a
    Connected.
    Grant succeeded.
    Grant succeeded.
    Connected.
    Package created.
    No errors.
    Procedure created.
    No errors.
    PL/SQL procedure successfully completed.
    RPAD(SUBSTR(COMP_NAME,1,50),50,'')||''||RPAD(STATUS,15,'')||''||SUBSTR(VERSIO
    Oracle9i Catalog Views VALID 9.2.0.4.0
    Oracle9i Packages and Types VALID 9.2.0.4.0
    Package dropped.
    Procedure dropped.
    SQL> exit
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
    JServer Release 9.2.0.4.0 - Production
    change env to 8i
    ==============
    ora@misdev01:~/vins 149 % sqlplus /
    SQL*Plus: Release 8.1.7.0.0 - Production on Fri Feb 4 18:37:09 2005
    (c) Copyright 2000 Oracle Corporation. All rights reserved.
    Connected to:
    Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
    With the Partitioning option
    JServer Release 8.1.7.4.0 - 64bit Production
    SQL> @x3a
    Connected.
    grant select on dba_registry to ops$oracle     <(i dont care if this errors in 8i)
    ERROR at line 1:
    ORA-00942: table or view does not exist
    Grant succeeded.
    Connected.
    Package created.
    No errors.
    Warning: Procedure created with compilation errors.
    Errors for PROCEDURE VS_GETDATA:
    LINE/COL ERROR
    13/2 PL/SQL: SQL Statement ignored
    13/103 PLS-00201: identifier 'DBA_REGISTRY' must be declared
    BEGIN vs_getdata(:c); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00905: object OPS$ORACLE.VS_GETDATA is invalid
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ERROR:
    ORA-24338: statement handle not executed
    SP2-0625: Error printing variable "c"
    Package dropped.
    Procedure dropped.
    If the select from dba_registry can be put inside a 'execute immediate' , 8i will ignore it during the compile and it runs ok, BUT
    I cannot fathom how to get a 'execute immediate' to return the data into p_cursor in 9i.
    Maybe something like:
    execute immediate('open p_cursor for select rpad(substr(comp_name,1,50),50,'' '')||'' ''||rpad(status,15,'' '')||'' ''||substr(version,1,10) from dba_registry');
    Please help.

  • PL SQL using bind variables

    I am very much new to PL/SQL to pardon my neivte.
    I would like to have some PL/SQL code that uses
    bind variables for insert statements and than issue
    commit's after a specific number of inserts.
    For example.
    desc xxx.taba
    a number
    b varchar2(20)
    I want to do someting like this:
    declare
    l_start number default dbms_utility.get_time;
    create or replace procedure insert_xxx(commit in number)
    begin
    for i in 1 .. 1000
    loop
    :a:=i;
    :b:=dbms_random.string('P', 20);
    intert into xxx :a :b;
    if i/mod=(number passed into to proc)
    commit
    end loop;
    dbms_output.put_line
    (round((dbms_utility.get_time-l_start)/100, 2) ||
    ' Seconds...' );
    end;
    end;
    Can somebody help me out with the correct syntax
    as I know it's incorrect.

    A few remarks
    - procedures don't have hidden variables defined in the outside world, as procedures are black boxes, which communicate only with the outside world
    using the actual parameter list
    - procedures don't commit. The caller should always commit!!!
    - procedures don't commit every <n> records. A commit finalizes a logical unit of work, not a technical one.
    If I would have been your supervisor and you would have presented this code, I would have fired you on the spot.
    Committing inside a loop also increases the likelihood of ora-1555 errors.
    So: remove the current parameter
    a and b should be formal parameters of the procedure
    Inside the procedure it should read
    insert into xxx values (a, b)
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for

  • Cfhttp and setting the content-type for a request

    Hi, I am trying to set the content-type for a cfhttp request like this (on coldfusion 9): <cfhttp redirect="no" method="get" timeout="120" url="http://10.0.0.1/test2.cfm">     <cfhttpparam type="HEADER" name="Content-Type" value="application/json; ch

  • How to limit threads in a Java QuickSort algorithm.

    With the following piece of code, I quickly run into OutOfMemory exceptions, since the code starts creating Threads exponentially. However, after waiting for a long time (for all the exception texts to print out, obviously making it slower than runni

  • Flash Player crash dumps

    since i installed flash player 11, my computer keeps crashing, going to memory dump at random times. the only way around this (other than remaining in safe mode) is to re-download flash player in safe mode and it allows the computer to come back to (

  • Raise exception with parameters

    Hi, Does anyone know how to hook into raising (predefined) exceptions with parameters? In a distributed environment I have to write my integrity constraints in triggers. For example, upon deleting, I throw an ORA-02292 myself if a child record exists

  • Extensions Manager CC will not update - (Language files missing)

    Ok I have been round and round with this issue.  Clearly the error is stating I am missing or have deleted language files, so... I reinstalled Mavericks...No luck same error, then (just for fun) I installed Yosemite...same error, and back to square o