ORA-24333 on Select Statement

Last night I attempted to roll a Crystal Reports .NET project to my production web server. This app has 3 new Crystal Reports. The Reports are all based upon the same Oracle Views on the same Oracle Database. Two of the reports work while the third report returns an ORA-24333 error. The exact reports and .NET code, connecting to the same Oracle database work fine in Preview mode and when published to my development IIS web server. The ONLY thing that is different is that the report is now being run on the production IIS web server. (But it is still the same Oracle Database we are connecting to in all environments.)
Here is the Command used for the Crystal Report that fails. Sorry it is so long. Basically, it is 4 Select statements joined together with Unions. Stuff in {} are parameters that are passed to it.
SELECT A.Custno as Custno, C.CUST_NAME as Cust_Name, D.CONTACT_NAME as Contact_Name, A.FISCALPRD as FiscalPrd, A.PROJECTNAME as ProjectName, A.INVOICENO as InvoiceNO, A.INVDATE, A.PAYDATE, A.ORDERNO as OrderNo, A.TOTALAMT as TotalAmt, A.ELIGIBLEAMT as EligibleAmt, A.SALESPOINTERD as SalesPointErd, 0 as FORFEIT, 0 as BONUSPOINTERD, 0 as PAYPTSEARNED, P.POINTPERCD as POINTPERCD, case when A.PAYDATE is null and A.INVDATE>SYSDATE-30 then round(P.POINTPERCD*A.ELIGIBLEAMT/100,0) else 0 end as PAYPTSELIG, case when A.PAYDATE is null and A.INVDATE>SYSDATE-30 then TO_CHAR(A.INVDATE+30,'MM/DD/YYYY') else '' end as PAYBYforPAYPTS
FROM VW_TRIPPOINTS A
left join VW_POINTS P on A.COMPANY=P.COMPANY and substr(A.FISCALPRD,1,4)=to_char(P.FISCALYEAR) and P.CODE='P'
join VW_CUSTOMERS C on (C.COMPANY=A.COMPANY or A.custno='313243') and C.CUST_NUMB=A.custno
join VW_SALESMEN D on C.DIST_MGR=D.CONTACT_NUMBER
where A.POINTCODE='S' and A.COMPANY='30' and A.ELIGIBLEAMT<>0 and A.custno='{?@Cust_ID}' and A.FISCALPRD>={?@BegPeriod} and A.FISCALPRD<={?@EndPeriod}
Union --Bonus Points
SELECT A.Custno as Custno, C.CUST_NAME as Cust_Name, D.CONTACT_NAME as Contact_Name, A.FISCALPRD as FiscalPrd, A.Notes as ProjectName, Cast((Row_Number() over (Order By CustNo, OrderNo, InvoiceNo, IDKey)) as varchar(10)) as InvoiceNO, A.INVDATE, Null as PAYDATE, Cast((Row_Number() over (Order By IDKey)) as varchar(10)) as ORDERNO, Coalesce(A.TOTALAMT,0) as TotalAmt, Coalesce(A.ELIGIBLEAMT,0) as EligibleAmt, Coalesce(A.SALESPOINTERD,0) as SalesPointErd, 0 as FORFEIT, A.BONUSPOINTERD as BonusPointErd, 0 as PAYPTSEARNED, 0 as POINTPERCD, 0 as PAYPTSELIG, '' as PAYBYforPAYPTS
FROM VW_TRIPPOINTS A
join VW_CUSTOMERS C on (C.COMPANY=A.COMPANY or A.custno='313243') and C.CUST_NUMB=A.custno
join VW_SALESMEN D on C.DIST_MGR=D.CONTACT_NUMBER
where A.POINTCODE='B' and A.COMPANY='30' and A.custno='{?@Cust_ID}' and A.FISCALPRD>={?@BegPeriod} and A.FISCALPRD<={?@EndPeriod}
Union --Pay Points
SELECT A.Custno as Custno, C.CUST_NAME as Cust_Name, D.CONTACT_NAME as Contact_Name, A.FISCALPRD as FiscalPrd, A.PROJECTNAME as ProjectName, A.INVOICENO as InvoiceNO, A.INVDATE, A.PAYDATE, A.ORDERNO as OrderNo, 0 as TotalAmt, 0 as EligibleAmt, 0 as SALESPOINTERD, 0 as FORFEIT, 0 as BONUSPOINTERD, coalesce(A.PAYPOINTERD,0) as PAYPTSEARNED, 0 as POINTPERCD, 0 as PAYPTSELIG, '' as PAYBYforPAYPTS
FROM VW_TRIPPOINTS A
join VW_CUSTOMERS C on (C.COMPANY=A.COMPANY or A.custno='313243') and C.CUST_NUMB=A.custno
join VW_SALESMEN D on C.DIST_MGR=D.CONTACT_NUMBER
where (A.POINTCODE='P' or A.POINTCODE='C') and A.COMPANY='30' and A.PAYPOINTERD<>0 and A.custno='{?@Cust_ID}' and A.FISCALPRD>={?@BegPeriod} and A.FISCALPRD<={?@EndPeriod}
Union --Sales Points Forfeited
SELECT A.Custno as Custno, C.CUST_NAME as Cust_Name, D.CONTACT_NAME as Contact_Name, A.FISCALPRD as FiscalPrd, A.PROJECTNAME as ProjectName, A.INVOICENO as InvoiceNO, A.INVDATE, A.PAYDATE, A.ORDERNO as OrderNo, 0 as TotalAmt, 0 as EligibleAmt, 0 as SalesPointErd, Coalesce(A.SalesPointErd,0) as FORFEIT, 0 as BONUSPOINTERD, 0 as PAYPTSEARNED, 0 as POINTPERCD, 0 as PAYPTSELIG, '' as PAYBYforPAYPTS
FROM VW_TRIPPOINTS A
join VW_CUSTOMERS C on (C.COMPANY=A.COMPANY or A.custno='313243') and C.CUST_NUMB=A.custno
join VW_SALESMEN D on C.DIST_MGR=D.CONTACT_NUMBER
where A.POINTCODE='R' and A.COMPANY='30' and A.SalesPointErd<>0 and A.custno='{?@Cust_ID}' and A.FISCALPRD>={?@BegPeriod} and A.FISCALPRD<={?@EndPeriod}
order by custno, OrderNo, InvoiceNo

Because we don't all have the Oracle error numbers and messages memorized:
ORA-24333: zero iteration count
Cause: An iteration count of zero was specified for the statement
Action: Specify the number of times this statement must be executed

Similar Messages

  • ORA-01401 in SELECT statement !

    Hi all,
    We are facing a Strange problem.
    Oracle Database 10.2.0.1 on Fedora Core6
    AL32UTF8 Charset, NLS_LENGTH_SEMANTICS = CHAR
    In a particular select statement, the database gives out ORA-01401 error:
    ORA-01401: inserted value too large for column
    Here is the select statement:
    SELECT   a.loc_nbr AS loc_nbr, a.loc_type_code AS loc_type_code,
             TO_CHAR (a.loc_eff_dt, 'yyyy-mm-dd') AS loc_eff_dt,
             TO_CHAR (a.loc_end_dt, 'yyyy-mm-dd') AS loc_end_dt,
             a.loc_nm AS loc_nm, a.loc_city AS loc_city,
             a.loc_st_prov AS loc_st_prov, b.acct_loc_nbr AS acct_loc_nbr,
             c.noofres AS routes
        FROM loc a,
             (SELECT   c.acct_loc_nbr AS acct_loc_nbr,
                       a.loc_sys_nbr AS loc_sys_nbr_loc
                  FROM loc a, loc_attr c
                 WHERE a.loc_ctry_code = '040'
                   AND a.loc_co_code = '001'
                   AND a.loc_type_code LIKE '03%'
                   AND a.loc_eff_dt <= TO_DATE ('2008-02-22', 'yyyy-mm-dd')
                   AND a.loc_end_dt >= TO_DATE ('2008-02-22', 'yyyy-mm-dd')
                   AND a.loc_nm > '%'
                   AND LPAD (a.loc_nbr, 38, '0') LIKE '%'
                   AND a.loc_short_nm LIKE '%'
                   AND a.loc_city LIKE '%'
                   AND NVL (a.loc_st_prov, '     ') LIKE '%'
                   AND c.loc_ctry_code = a.loc_ctry_code
                   AND c.loc_co_code = a.loc_co_code
                   AND c.loc_nbr = a.loc_nbr
                   AND c.loc_type_code = a.loc_type_code
                   AND c.loc_attr_eff_dt <= a.loc_eff_dt
                   AND c.loc_attr_end_dt >= a.loc_eff_dt
              ORDER BY a.loc_nbr) b,
             (SELECT   COUNT (b.loc_nbr) AS noofres,
                       a.loc_sys_nbr AS loc_sys_nbr_rt
                  FROM loc a, rt_loc_assgn b
                 WHERE a.loc_ctry_code = '040'
                   AND a.loc_co_code = '001'
                   AND a.loc_type_code LIKE '03%'
                   AND a.loc_eff_dt <= TO_DATE ('2008-02-22', 'yyyy-mm-dd')
                   AND a.loc_end_dt >= TO_DATE ('2008-02-22', 'yyyy-mm-dd')
                   AND a.loc_nm > '%'
                   AND LPAD (a.loc_nbr, 38, '0') LIKE '%'
                   AND a.loc_short_nm LIKE '%'
                   AND a.loc_city LIKE '%'
                   AND NVL (a.loc_st_prov, '     ') LIKE '%'
                   AND b.ctry_code = a.loc_ctry_code
                   AND b.co_code = a.loc_co_code
                   AND b.loc_nbr = a.loc_nbr
                   AND (   a.loc_eff_dt BETWEEN b.rt_loc_eff_dt AND b.rt_loc_end_dt
                        OR a.loc_end_dt BETWEEN b.rt_loc_eff_dt AND b.rt_loc_end_dt
                   AND b.loc_svc_type_code = 'S'
              GROUP BY a.loc_sys_nbr) c
       WHERE a.loc_sys_nbr = b.loc_sys_nbr_loc(+)
         AND a.loc_sys_nbr = c.loc_sys_nbr_rt(+)
         AND a.loc_ctry_code = '040'
         AND a.loc_co_code = '001'
         AND a.loc_type_code LIKE '03%'
         AND a.loc_eff_dt <= TO_DATE ('2008-02-22', 'yyyy-mm-dd')
         AND a.loc_end_dt >= TO_DATE ('2008-02-22', 'yyyy-mm-dd')
         AND a.loc_nm > '%'
         AND LPAD (a.loc_nbr, 38, '0') LIKE '%'
         AND a.loc_short_nm LIKE '%'
         AND a.loc_city LIKE '%'
         AND NVL (a.loc_st_prov, '     ') LIKE '%'
    ORDER BY a.loc_nmWorkarounds:
    - If we comment ORDER BY clause, the query works fine
    - On line 49, if we surround loc_sys_nbr with TRIM() function, the query works fine
    - On line 60, if we use NVL (a.loc_st_prov, '' ) LIKE '%', the query works fine
    All these fields are CHAR() datatype.
    Any idea what is happening here?
    Thanks in advance :)

    Thanks Satish,
    We are hit by the bug 5874989 relating to impdp tool.

  • Snapshot too old ORA-01555 from select statement (discoverer)??

    Hi All
    Am I loosing the plot .. but we have a select statement run from discoverer which is causing the famous snapshot too old error.
    My understanding is that undo is generated from select/insert/update.
    So why is the following discoverer Select statement causing the error?
    from alert
    ORA-01555 caused by SQL statement below (SQL ID: gk0wxgqmx66sh, Query Duration=3866 sec, SCN: 0x001e.089cf3f9):
    SELECT  ( ROUND(( TO_DATE(SYSDATE)-o101038.HIRE_DATE )/365,2) ) as
      "  bla bla
    ORDER BY o101020.SUB_ORGANIZATION_NAME ASC
    Thanks in Advance

    simon.9999 wrote:
    Hi All
    Am I loosing the plot .. but we have a select statement run from discoverer which is causing the famous snapshot too old error.
    My understanding is that undo is generated from select/insert/update.
    So why is the following discoverer Select statement causing the error?
    from alert
    ORA-01555 caused by SQL statement below (SQL ID: gk0wxgqmx66sh, Query Duration=3866 sec, SCN: 0x001e.089cf3f9):
    SELECT  ( ROUND(( TO_DATE(SYSDATE)-o101038.HIRE_DATE )/365,2) ) as
      "  bla bla
    ORDER BY o101020.SUB_ORGANIZATION_NAME ASC
    Thanks in Advance
    The SELECT statement is the victim.
    Some session is doing DML against the same table against which the SELECT occurs & is likely doing COMMIT inside a LOOP.

  • Getting an ORA-24333 error while parsing a non SELECT statement ...

    Hi,
    I'm new to this forum and I've search through the entire forum to see if my problem was already solved, but at first sight it doesn't ?
    So I hope that someone can help me one this : I'm facing a strange problem with the OCI 8i. I've encapsulated any OCI call into a set of C++ classes. Everything works fine apart for one point : whenever I try to parse a NON "select" statement, I get the ORA-24333 error.
    Basically, the code follow the current schema (only "important" states are written here) :
    -> Opening an Oracle Session
    -> Receving de statement.
    -> Analyse it with a call to OCIStmtPrepare() with OCI_NTV_SYNTAX set.
    -> Calling OCIBindByName() to associate each variable with a data.
    -> Calling OCIStmtExecute() with OCI_DESCRIBE_ONLY set in order to retrieve the current list of INPUT/OUTPUT columns.
    And this is where the problem arise.
    With a statement like : "SELECT MyPackage.MyFunction(:v1) FROM DUAL"
    Everthing works fine. I can bind the INPUT/OUTPUT ":v1" variable.
    But with a statement like : "BEGIN MYFUNTION(:v1); END;"
    I get the ORA-24333 error after the call to OCIStmtExecute().
    I get this error only when I set OCI_DESCRIBE_ONLY. If I call OCIStmtExecute() with OCI_DEFAULT, the OCI execute the statement. This is fine but it's not what I want. I cannot change the statement received (by design), so they should be proceeded as received.
    What I'm looking for is a way to successfully perform the OCIStmtExecute() with OCI_DESCRIBE_ONLY set in order to get the list of variables columns related to the current statement.
    Any help would be greatly apprecitated here. Thanks !
    Here are my current configurations.
    -> Windows 2000 SP5 OCI 8i / VC++ 6.0
    -> Macintosh OS X 10.3.4 / Code Warrior 8.3
    (The code produce exactly the same results/troubles on both plateforms.)
    Thanks in advance for your respons.

    Hi,
    I'm new to this forum and I've search through the entire forum to see if my problem was already solved, but at first sight it doesn't ?
    So I hope that someone can help me one this : I'm facing a strange problem with the OCI 8i. I've encapsulated any OCI call into a set of C++ classes. Everything works fine apart for one point : whenever I try to parse a NON "select" statement, I get the ORA-24333 error.
    Basically, the code follow the current schema (only "important" states are written here) :
    -> Opening an Oracle Session
    -> Receving de statement.
    -> Analyse it with a call to OCIStmtPrepare() with OCI_NTV_SYNTAX set.
    -> Calling OCIBindByName() to associate each variable with a data.
    -> Calling OCIStmtExecute() with OCI_DESCRIBE_ONLY set in order to retrieve the current list of INPUT/OUTPUT columns.
    And this is where the problem arise.
    With a statement like : "SELECT MyPackage.MyFunction(:v1) FROM DUAL"
    Everthing works fine. I can bind the INPUT/OUTPUT ":v1" variable.
    But with a statement like : "BEGIN MYFUNTION(:v1); END;"
    I get the ORA-24333 error after the call to OCIStmtExecute().
    I get this error only when I set OCI_DESCRIBE_ONLY. If I call OCIStmtExecute() with OCI_DEFAULT, the OCI execute the statement. This is fine but it's not what I want. I cannot change the statement received (by design), so they should be proceeded as received.
    What I'm looking for is a way to successfully perform the OCIStmtExecute() with OCI_DESCRIBE_ONLY set in order to get the list of variables columns related to the current statement.
    Any help would be greatly apprecitated here. Thanks !
    Here are my current configurations.
    -> Windows 2000 SP5 OCI 8i / VC++ 6.0
    -> Macintosh OS X 10.3.4 / Code Warrior 8.3
    (The code produce exactly the same results/troubles on both plateforms.)
    Thanks in advance for your respons.

  • Sub-selects in forms causing ora-24333

    We are running in a new 11g environment and are receiving an ora-24333 from forms with sub-selects. The same form works in 10g and the sql statement, itself, works in sqlplus. The following is an example of code
    exec_sql.parse(oracle_handle, oracle_cursor,
    'update vendor a
    set (status, vendor_type) =
    (select decode(rec_sttus,'||''' '''||','||'''ACTIVE'''||',
    '||'''I'''||','||'''INACTIVE'''||',
    '||'''D'''||','||'''DELETE'''||',
    '||'''F'''||','||'''FOREIGN'''||',
    '||'''N'''||','||'''RENUMBERED'''||',
    '||'''K'''||','||'''KEEPER'''||',
    rec_sttus),
    vndr_type
    from prch_vndr b
    where a.vendor_no = b.vndr_num)
    where vendor_no in
    (select vndr_num
    from prch_vndr)');
    t_temp := exec_sql.execute(oracle_handle, oracle_cursor);
    exec_sql.parse(oracle_handle, oracle_cursor, 'commit');
    t_temp := exec_sql.execute(oracle_handle, oracle_cursor);
    Any ideas where we might have a configuration setting missing or what has changed with 11g forms of which we are unaware?
    Edited by: kwalker on Dec 26, 2012 2:00 PM
    Edited by: kwalker on Dec 26, 2012 2:00 PM

    Hi Kelly,
    We are running in a new 11g environment and are receiving an ora-24333 from forms with sub-selects. The same form works in 10g and the sql statement, itself, works in sqlplus. The following is an example of codeAlways post code snippets in &#123;code&#125; tags as explained in FAQ.
    >
    exec_sql.parse(oracle_handle, oracle_cursor,
    'update vendor a
    set (status, vendor_type) =
    (select decode(rec_sttus,'||''' '''||','||'''ACTIVE'''||',
    '||'''I'''||','||'''INACTIVE'''||',
    '||'''D'''||','||'''DELETE'''||',
    '||'''F'''||','||'''FOREIGN'''||',
    '||'''N'''||','||'''RENUMBERED'''||',
    '||'''K'''||','||'''KEEPER'''||',
    rec_sttus),
    vndr_type
    from prch_vndr b
    where a.vendor_no = b.vndr_num)
    where vendor_no in
    (select vndr_num
    from prch_vndr)');
    t_temp := exec_sql.execute(oracle_handle, oracle_cursor);
    exec_sql.parse(oracle_handle, oracle_cursor, 'commit');
    t_temp := exec_sql.execute(oracle_handle, oracle_cursor);Any ideas where we might have a configuration setting missing or what has changed with 11g forms of which we are unaware?>
    a. EXEC_SQL package for simple updates looks like an overkill. EXECUTE IMMEDIATE will meet the requirement.
    b. The ORA-24333 error is related to data. Is the database and schema for 10g, SQLDeveloper and 11g the same? If they are different then check data in the database/schema used with Forms 11g.
    Cheers,

  • ORA-24333: zero iteration count  Cause: An iteration count of zero was specified for the statement Action: Specify the number of times this statement must be executed

    Get the following error from Oracle 
    ORA-24333: zero iteration count
    Cause: An iteration count of zero was specified for the statement
    Action: Specify the number of times this statement must be executed
    Any suggestions on whether is this a Oracle bug or if not what should be set to avoid this failure.

    Hello get this from executing the following.
    Occurs intermitently.
    select MAX(LENGTH(lxVal)) from lxString_74501fb6 where lxType=910231053
    Find the MaxLenght(LxVal) returned is null for this query.
    Did google it but says the iterator not initialized. But not the case here
    Thanks

  • ORA-24333 An iteration count of zero was specified for the statement

    Hi all,
    in example below oracle generate error ORA-24333,
    Cause: An iteration count of zero was specified for the statement
    Action: Specify the number of times this statement must be executed
    On Error GoTo errHandler:
    Dim pOraStmt As OraSqlStmt 'obiekt OO4O
    Dim stat As Long
    aWystapilBlad = False
    gOraDatabase.LastServerErrReset
    gOraDatabase.BeginTrans
    Set pOraStmt = gOraDatabase.CreateSql("begin " & _
    NAZWA_PAKIETU & "." & NAZWA_PROCEDURY & _
    "; END;", ORASQL_NONBLK)
    stat = pOraStmt.NonBlockingState
    While stat = ORASQL_STILL_EXECUTING
    DoEvents
    stat = pOraStmt.NonBlockingState
    Wend
    '>>>>>>>>>>>>>>>>>ERROR ORA-24333 zero iteration count!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
    If gOraDatabase.LastServerErr > 0 Then
    aWystapilBlad = True
    GenerujKomunikaty BLAD_SYSTEMOWY_NR & Err.Number & vbNewLine & BLAD_OPIS_BLEDU & gOraDatabase.LastServerErrText, WyswietlNaEkran, blad, TYTUL_APLIKACJA
    PrzeniesDanychCODGiK = False
    End If
    gOraDatabase.CommitTrans
    PrzeniesDanych = True
    Exit Function
    errHandler:
    aWystapilBlad = True
    gOraDatabase.Rollback
    PrzeniesDanych = False
    Can anybody help me?
    Regards
    Zbyszek

    Hello get this from executing the following.
    Occurs intermitently.
    select MAX(LENGTH(lxVal)) from lxString_74501fb6 where lxType=910231053
    Find the MaxLenght(LxVal) returned is null for this query.
    Did google it but says the iterator not initialized. But not the case here
    Thanks

  • ORA-00911: invalid character using multiple select statements

    I am getting an ORA-00911: invalid character error when trying to execute 2 select statements using ODP.NET.
    cmd.CommandText = "select sysdate from dual;select sysdate from dual;";
    cmd.Connection = conn;
    cmd.CommandType = System.Data.CommandType.Text;
    conn.Open();
    OracleDataReader dr = cmd.ExecuteReader();
    This works in SQL server but for some reason it appears this does not work in Oracle?
    If this is the case what is a vaiable workaround? Wrapping the 2 statements in a transaction?
    Seems strange that you can't return multiple result sets using in-line sql statements.

    Oracle doesn't support passing multiple statements like that, and this is unrelated to ODP.NET.
    SQL> select * from emp;select * from dept;
    select * from emp;select * from dept
    ERROR at line 1:
    ORA-00911: invalid character
    You could do it via an anonymous block and ref cursors though if you dont want to do it via a stored procedure..
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    public class test
    public static void Main()
        using (OracleConnection con = new OracleConnection("data source=orcl;user id=scott;password=tiger;"))
            con.Open();
            string strSql = "begin open :refcur1 for select * from emp;" +
                "open :refcur2 for select * from dept;" +
                "open :refcur3 for select * from salgrade;end;";
            using (OracleCommand cmd = new OracleCommand(strSql, con))
                cmd.Parameters.Add("refcur1", OracleDbType.RefCursor, ParameterDirection.Output);
                cmd.Parameters.Add("refcur2", OracleDbType.RefCursor, ParameterDirection.Output);
                cmd.Parameters.Add("refcur3", OracleDbType.RefCursor, ParameterDirection.Output);
                OracleDataAdapter da = new OracleDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                cmd.Parameters["refcur1"].Dispose();
                cmd.Parameters["refcur2"].Dispose();
                cmd.Parameters["refcur3"].Dispose();
                foreach (DataTable dt in ds.Tables)
                    Console.WriteLine("\nProcessing {0} resultset...", dt.ToString());
                    foreach (DataRow row in dt.Rows)
                        Console.WriteLine("column 1: {0}", row[0]);
    }Hope it helps,
    Greg

  • Report Builder ORA 24333 Zero iteration count

    The following query works fine in SQL environment
    Break on team_name;
    select substr(st.team_name, 1, 20) team_name, sst.team_id, sst.staff_sso
    from
    ssa_staff_team sst, ssa_teams st
    where st.team_id = sst.team_id(+)
    order by team_name;
    But when I cut and paste it into "SQL Query Statement" of Oracle Report it does not work. the error message is ORA-24333 - zero iteration count ==> Break on TEAM_Name
    What did I do wrong"
    How do I fix this?

    Just follow the report wizard and it will ask you on which column(s) to break.
    Don't try to do it afterwards, because that is a pain in the .... You will have to modify your data and layout model yourself if you don't use the wizard.

  • Passing value as a parameter in select statement

    Hi,
    Very simple query, how do I pass the values that i get in the cursor to a select statement. If table1 values are 1,2,3,4 etc , each time the cursor goes through , I will get one value in the variable - Offer
    So I want to pass that value to the select statement.. how do i do it?
    the one below does not work.
    drop table L1;
    create table L1
    (col1 varchar(300) null) ;
    insert into L1 (col1)
    select filter_name from table1 ;
    SET SERVEROUTPUT ON;
    DECLARE
    offer table1.col1%TYPE;
    factor INTEGER := 0;
    CURSOR c1 IS
    SELECT col1 FROM table1;
    BEGIN
    OPEN c1; -- PL/SQL evaluates factor
    LOOP
    FETCH c1 INTO offer;
    EXIT WHEN c1%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(offer);
    select * from table1 f where f.filter_name =:offer ;
    factor := factor + 1;
    DBMS_OUTPUT.PUT_LINE(factor);
    END LOOP;
    CLOSE c1;
    END;

    Hi Greg,
    Thanks for the response, No there is no ODB.net involved here.
    If I remove the : from :offer. I get this error now.
    Changed SQL is:
    select * from table1 f where f.filter_name =offer ;
    Error report:
    ORA-06550: line 16, column 23:
    PL/SQL: ORA-00942: table or view does not exist
    ORA-06550: line 16, column 9:
    PL/SQL: SQL Statement ignored
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using Select statement in IF condition?

    hi all,
    Can i use select statement in IF COndition in pl sql ?
    eg like- if( select 1 from ASD) then
    end if;

    There is no way to do any kind of select statement inside if conditions.
    Why don't test simple cases like this first?
    An example to show it.
    SQL> begin
      2   if exists (select 1 from dual) then
      3    dbms_output.put_line('ok');
      4   end if;
      5  end;
      6  /
    if exists (select 1 from dual) then
    ERRORE alla riga 2:
    ORA-06550: line 2, column 5:
    PLS-00204: function or pseudo-column 'EXISTS' may be used inside a SQL
    statement only
    ORA-06550: line 2, column 2:
    PL/SQL: Statement ignored
    SQL> begin
      2   if ( (select count(*) from dual) > 0 ) then
      3    dbms_output.put_line('ok');
      4   end if;
      5  end;
      6  /
    if ( (select count(*) from dual) > 0 ) then
    ERRORE alla riga 2:
    ORA-06550: line 2, column 8:
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( - + case mod new not null others <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    count current exists max min prior sql stddev sum variance
    execute forall merge time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string> pipe
    <an alternatively-quoted string literal with character set specification>
    <an alternativ
    ORA-06550: line 2, column 33:
    PLS-00103: Encountered the symbol ")" when expecting one of the following:
    . , @ ; for <an identifier>
    <a double-quoted delimited-identifier> group having intersect
    minus order partition start subpartition union where connect
    SQL> begin
      2   if ( 0 in (select count(*) from dual) ) then
      3    dbms_output.put_line('ok');
      4   end if;
      5  end;
      6  /
    if ( 0 in (select count(*) from dual) ) then
    ERRORE alla riga 2:
    ORA-06550: line 2, column 12:
    PLS-00405: subquery not allowed in this context
    ORA-06550: line 2, column 2:
    PL/SQL: Statement ignoredBye Alessandro

  • How to get the value from a function using a select statement

    I have a function(user defined not built in) that returns multiple values(like an array). My question is how do i get those values in a select statement. when i tried to retrieve it,
    select pack.my_members from dual;
    i am getting an error
    ORA-00902: invalid datatype
    I am sure this must be a syntax error with the select statement
    The following is the function that give the array of data
    package pack
    package spec
    Type my_table is table of varchar2(25);
    function the_members
    return pack.my_table;
    pakcage body
    function the_members return pack.my_table
    Remarks: This function returns a table containing names of the
    members
    is
    tm pack.my_table:= pack.my_table('first member','second member','third member','fourth member');
    begin
    return tm;
    end the_members;

    Check this example on Pipelinedfunction

  • Using Cursor in Select statements? How to do this?

    I am getting an error whilt passing a cursor to a select clause:
    SELECT dbms_xmlquery.getXML('select deptno, dname, '||
    'cursor(select empno, ename, sal from emp e where e.deptno = d.deptno) employees '||
    'from dept d where d.deptno in (10, 20)')
    FROM dual;
    DBMS_XMLQUERY.GETXML('SELECTDEPTNO'||'CURSORIS(SELECTEMPNOFROMEMPEWHEREE.DEPT=D.
    <?xml version = '1.0'?>
    <ERROR>oracle.xml.sql.OracleXMLSQLException: ORA-00923
    : FROM keyword not found where expected
    </ERROR
    THIS IS DUE TO THE CURSOR AND ITS FROM STATEMENT?
    CAN ANY ONE PLEASE GUIDE AS TO HOW TO USE CURSORS IN A SELECT STATEMENT PLEASE?

    Another duplicate thread. See my response Select CLAUSE error using CURSORS & XSU.Please SEE..
    Cheers, APC

  • Use of a stored procedure in a select statement submitted to cx_oracle

    Hi,
    I am developping under python and I'm using the cx_oracle interface.
    I've written a stored procedure that I've tested directly under sqlplus session : it's ok. I've also tested this stored procedure from python by using callproc routine : its also ok.
    Now I need to use this procedure within a select statement that I submit to the execute statement of cx_oracle as :
    s = "select a.airport_name,gmlpos.ExpLatLong(a.point_name) from airport"
    self.db = oracledb('ops/opeope00@ACE2008B')
    dbmsg = self.db.execute(s)
    IF (dbmsg == "") :
    An error occurs :
    Message = request = select a.AIRPORT_NAME, gmlpos.ExpLatLong(a.point_name) from airport, errmsg = ORA-00904: "GMLPOS"."EXPLATLONG": invalid identifier
    Noting that the execution of any other select (without stored procedure) order from python works fine.
    Is anybody has a solution or workaround ?
    thanks a lot for your help

    The result gives what is expected :
    AIRP
    GMLPOS.EXPLATLONG(A.POINT_NAME)
    LFLL
    -45.71666666666667 -5.08333333333333
    As I said the stored procedure works fine.
    Thanks for your expertise
    PS : why change the login password until nobody says which machine or database is concerned ?

  • How to use bind variable value for table name in select statement.

    Hi everyone,
    I am having tough time to use value of bind variable for table name in select statement. I tried &p37_table_name. ,
    :p37_table_name or v('p37_table_name) but none worked.
    Following is the sql for interactive report:
    select * from v('p37_table_name') where key_loc = :P37_KEY_LOC and
    to_char(inspection_dte,'mm/dd/yyyy') = :P37_INSP_DT AND :p37_column_name is not null ;
    I am setting value of p37_table_name in previous page which is atm_state_day_insp.
    Following is error msg:
    "Query cannot be parsed, please check the syntax of your query. (ORA-00933: SQL command not properly ended) "
    Any help would be higly appreciated.
    Raj

    Interestingly enough I always had the same impression that you had to use a function to do this but found out from someone else that all you need to do is change the radio button from Use Query-Specific Column Names and Validate Query to Use Generic Column Names (parse query at runtime only). Apex will substitute your bind variable for you at run-time (something you can't normally do in pl/sql without using dynamic sql)

Maybe you are looking for