Statement ignored

I am getting following error when i call function thru SQL.
SELECT F1(100) FROM DUAL
ERROR at line 1:
ORA-06552: PL/SQL: Statement ignored
ORA-06553: PLS-382: expression is of wrong type
My function is
CREATE OR REPLACE FUNCTION F1(N NUMBER) RETURN BOOLEAN
IS
BEGIN
IF N > 100 THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
END;
/

In addition to the explanation of ushitaki
Oracle says
PLS-00382: expression is of wrong type
Cause: An expression has the wrong datatype for the context in which it was found.
Action: Change the datatype of the expression. You might want to use datatype conversion functions.
I think there is datatype issue. I started researching on this and found that, boolean value cannot be printed in pl/sql as well.
1 create or replace procedure ss
2 as
3 b boolean;
4 begin
5 b:=true;
6 dbms_output.put_line(b);
7* end;
SQL> /
Warning: Procedure created with compilation errors.
SQL> show err
Errors for PROCEDURE SS:
LINE/COL ERROR
6/1 PLS-00306: wrong number or types of arguments in call to
'PUT_LINE'
6/1 PL/SQL: Statement ignored
SQL> ed
Wrote file afiedt.buf
1 create or replace procedure ss
2 as
3 b boolean;
4 begin
5 b:=true;
6 if (b=true) then
7 dbms_output.put_line('true');
8 end if;
9* end;
10 /
Procedure created.
SQL> execute ss;
true
PL/SQL procedure successfully completed.
SQL>
Hope this helps.

Similar Messages

  • Error: PL/SQL statement ignored

    In the code below i am getting 3 errors:
    a. PL/SQL statement ignored
    b. PLS-00201
    c. PL/SQL: ORA-00904 : invalid identifier
    please help. thank you
    =========================================
    Package body:
    =========================================
    create or replace package BODY manage_students
    as
         procedure find_sname
         (i_student_id IN student.student_id%TYPE,
         o_first_name OUT student.first_name%TYPE,
         o_last_name OUT student.last_name%TYPE)
         IS
         v_student_id student.student_id%TYPE;
         BEGIN
              select first_name, last_name
                   into o_first_name, o_last_name
                   from student
                   where student_id = i_student_id;
         exception
              when others
              then
                   DBMS_OUTPUT.PUT_LINE('Error in finding student_id: '||v_student_id);
         end find_sname;
         function id_is_good
         (i_student_id in student.student_id%TYPE)
              return BOOLEAN
         IS
              v_id_cnt number;
         begin
              select count(*)
                   into v_in_cnt
                   from student
                   where student_id = i_student_id;
              return 1 = v_id_cnt;
         EXCEPTION
         when others then
              return FALSE;
         end id_is_good;
    END manage_students;
    =========================
    Package specification:
    =========================
    set serveroutput on
    create or replace package manage_students
    as
         procedure find_sname
              (i_student_id IN student.student_id%TYPE,
              o_first_name OUT student.first_name%TYPE,
              o_last_name OUT student.last_name%TYPE
         function id_is_good
         (i_student_id IN student.student_id%TYPE)
              RETURN BOOLEAN;
    END manage_students;
    Edited by: [email protected] on Mar 19, 2009 6:03 AM
    Edited by: [email protected] on Mar 19, 2009 6:03 AM

    Congrats, someonElse! ;-)
    And about the when others: read about it on asktom why it's a bad practice, here's an example:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1509245700346768268#1535781400346575552
    I've spent myself way too much time on finding and fixing bugs caused by 'when others', so I always comment about it too ;-)
    Edited by: hoek on Mar 19, 2009 2:14 PM
    Edited by: hoek on Mar 19, 2009 2:18 PM

  • Error message "SQL Statement ignored" while try to run an Funtion in APEX

    Hello All,
    In order to creating an application in APEX from CSV format i need to run below funtion.
    CREATE OR REPLACE FUNCTION bcl_custom_auth (
    p_username IN VARCHAR2,
    p_password IN VARCHAR2)
    RETURN BOOLEAN IS
    BEGIN
    FOR c1 IN (SELECT 1
    FROM bcl_employees
    WHERE UPPER(userid) = UPPER(p_username)
    AND UPPER(last_name) = UPPER(p_password))
    LOOP
    RETURN TRUE;
    END LOOP;
    RETURN FALSE;
    END;
    but i am getting below error message:
    Error at line 6: PL/SQL: SQL Statement ignored
    4. RETURN BOOLEAN IS
    5. BEGIN
    6. FOR c1 IN (SELECT 1
    7. FROM bcl_employees
    8. WHERE UPPER(userid) = UPPER(p_username)
    Could some body please check as i am new to PLSQL.
    Thanks & regards,
    Souvik Ghosh

    843873 wrote:
    Hello Edstevens,
    I did not understand your answer .Could you please elaborate.
    Thanks & regards,
    Souvik Ghosh
    Edited by: 843873 on Jul 8, 2011 11:43 PMNotice that the message had been edited? I changed my mind from my original, shot-from-the-hip, mesage, and simply deleted the entire content. would have preferred to delete the entire message but can't.

  • SQL Statement ignored performing List of Values query

    Hi, New user just learning the basics. I have created a simple table PERSON with columns, ID, firstname, lastname, phone, city, State_ID
    Then clicked create Lookup table - State_Lookup with columns State_ID and State_Name.
    I create a page, include all columns from PERSON. For State the field is a select list that should do a lookup form the STATE_LOOKUP table. (I have entered 4 states in the table)
    I am getting the following error however:
    Error: ORA-06550: line 1, column 14: PL/SQL: ORA-00904: "STATE_ID": invalid identifier ORA-06550: line 1, column 7: PL/SQL: SQL Statement ignored performing List of Values query: "select STATE_ID d, STATE_ID v from STATE_ID_LOOKUP order by 1".
    I have not entered any sql, just selected all of my options using defaults and dropdowns. What is causing the error and what do I need to change?
    Thanks

    Okay, learned something: The database link name used, must not contain a dash. The DB_DOMAIN is appended automatically when you create a DB link, so if IT contains a dash, the db link name does as well. Check DBA_DB_LINKS to make sure you don't hit this well-hidden feature.
    Regards
    Martin Klier
    [http://www.usn-it.de|http://www.usn-it.de]

  • Error in Trigger (PL/SQL: SQL Statement Ignored)

    Here is the trigger:
    CREATE OR REPLACE TRIGGER DRUGREPLACEMENT
    AFTER INSERT ON PHARMACEUTICALS
    REFERENCING NEW AS newDrugs
    FOR EACH ROW
    WHEN (newDrugs.drugname = newDrugs.genericname)
    BEGIN
    UPDATE prescription
    SET pharmaceuticalid = newDrugs.drugID
    WHERE pharmaceuticalid IN(SELECT pharmaceuticalid FROM prescription, pharmaceuticals WHERE drugid = pharmaceuticalid AND newDrugs.genericname = pharmaceutical.genericname);
    END;
    Error is:
    Error(2,1): PL/SQL: SQL Statement ignored
    Error(3,24): PL/SQL: ORA-00904: "NEWDRUGS"."DRUGID": invalid identifier
    pharmaceuticalid is a number in my prescription table.
    drugid is a number; genericname and drugname are both varchars in my pharmaceuticals table. Any idea why I am getting these errors? (I tried putting quotes around newdrugs.drugid but then it just said "newdrugs.drugid" is invalid. Thanks for your help
    -Brian

    One more thing. Your trigger is selecting from triggering table. So single row inserts will work, but multiple row inserts into PHARMACEUTICALS will fail with famous "table is mutating" error. There is no need to select from PHARMACEUTICALS. Change:
    UPDATE ************
    SET pharmaceuticalid = newDrugs.drugID
    WHERE pharmaceuticalid IN(SELECT pharmaceuticalid FROM ************, pharmaceuticals WHERE drugid = pharmaceuticalid AND newDrugs.genericname = pharmaceutical.genericname);to
    UPDATE ************
      SET pharmaceuticalid = newDrugs.drugID
      WHERE pharmaceuticalid IN (
                                 SELECT pharmaceuticalid
                                   FROM ************
                                   WHERE drugid = :newDrugs.pharmaceuticalid
                                     AND :newDrugs.genericname = pharmaceutical.genericname
                                );SY.

  • Error 0 Statement Ignored

    I'm migrating from Reports 10.xxx to 11.1.2.0, and I run into something very strange. Any select statement on any trigger on Reports 11.xxx  returns Error 0 at line x, column x SQL statement ignored.
    The reports have been and are still running on Reports 10xxx with no problems.
    Below one of those triggers:
    function BeforeReport return boolean is
    begin
      select rv_low_value
      into :cp_name
      from cg_ref_codes
      where rv_domain = 'COMPANY';
      return (TRUE);
    end;
    Any help will be appreciated,
    Luis

    What is that :cp_name. Is it a parameter?

  • Compiler error (error 0 statement ignored)

    I developped a library (.pll) under forms 4.5. I tried to
    convert it to forms 6i. The conversion process is fine but when
    I recompile all functions & procedures where I used a select
    statement failed(error 0, statement ignored).
    Thanks for any help. Lami Said

    First, please post your exact version of Oracle Forms (eg; 11.1.1.3.0).
    Second, can you please post the code that is causing you trouble. It would be helpful to see the full code, not just a sample as we can see how your SELECT statement is being used. Most likely, you are dealing with a Syntax issue, but we need to see your code to confirm this.
    Lastly, as most of you are new to the Oracle Forums, it would be helpful for you to review the following:
    <ul>
    <li>Oracle Forums FAQ
    <li>Before posting on this forum please read
    <li>10 Commandments for the OTN Forums Member
    <li>How to ask questions the smart way
    </ul>
    Following these simple guidelines will ensure you have a positive experience in any forum; not just this one! ;-)
    Craig...

  • Cursor Error in trigger - Statement Ignored/identifier must be declared PLS

    I have been asked to implement a trigger and believe I have the code complete but am getting a final error on the compile. I have been running in circles for a day trying to resolve my issue. I have no PL/SQL knowlege so have been pulling from a book and google. I have three Cursors defined and the third compiles fine, the first two give the below error though I can't see a significant difference between the three. I can't help but think it is something stupid I am not seeing but I am at a loss.
    If I comment out the reference to the cursor it will compile with the cursor definition but as soon as I add the Open statement the errors below appear.
    Any help would be greatly appreciated as my head is getting sore.
    Thanks
    Mike
    Error(30,13): PL/SQL: Statement ignored
    Error(30,20): PLS-00201: identifier 'CURSORGETFROMDISTMAKRERS' must be declared
    Error(51,13): PL/SQL: Statement ignored
    Error(51,20): PLS-00201: identifier 'CURSORGETTODISTMAKRERS' must be declared
    -- Table I am writing to
    create table IMSV7.CTRANSWODISTMARK (
    WORKORDERKEY INTEGER,
    DISTMARKFROM NUMBER (9,4),
    DISTMARKFROMATTRIBUTE VARCHAR (10),
    DISTMARKTO NUMBER (9,4),
    DISTMARKTOATTRIBUTE VARCHAR (10)
    -- Excerpt from the HISTORY table I am placing the trigger against
    COMPKEY NUMBER (9,0)
    DISTFROMFT FLOAT
    DISTTOFT FLOAT
    HISTKEY NUMBER (9,0)
    -- Trigger code
    CREATE OR REPLACE TRIGGER MaintainCTRANSWODISTMARK
    AFTER INSERT or UPDATE of DISTFROMFT, DISTTOFT ON IMSV7.HISTORY
    REFERENCING NEW as NewWO
    FOR EACH ROW
    BEGIN
    DECLARE
    -- Declare cursors
    CURSOR CursorGetFromDistMarkers (WOCompKey IN NUMBER, WODistFromFT IN FLOAT) IS
    SELECT ATTRCODE, DISTFROMFT, MARKERFROM from RWATTRDF DF, RWATTR A
    where WOCompkey = A.COMPKEY AND DF.ATTRKEY = A.ATTRKEY and DF.ATTRTYPE = 'DISTMARK'
    and WODistFromFT >= DISTFROMFT and WODistFromFT <= DISTTOFT
    order by A.EFFDATE DESC, DISTFROMFT DESC;
    FromDistanceMarker CursorGetFromDistMarkers%ROWTYPE;
    CURSOR CursorGetToDistMarkers (WOCompKey IN NUMBER, WODistToFT IN FLOAT) IS
    SELECT ATTRCODE, DISTFROMFT, MARKERFROM from RWATTRDF DF, RWATTR A
    where WOCompkey = A.COMPKEY AND DF.ATTRKEY = A.ATTRKEY and DF.ATTRTYPE = 'DISTMARK'
    and WODistToFT >= DISTFROMFT and WODistToFT <= DISTTOFT
    order by A.EFFDATE DESC, DISTFROMFT DESC;
    ToDistanceMarker CursorGetToDistMarkers%ROWTYPE;
    CURSOR CursorGetCTRANSWODistMark (WOHistKey IN NUMBER) IS
    SELECT WORKORDERKEY from CTRANSWODISTMARK
    where WORKORDERKEY = WOHistKey;
    CTRANSWODistMark CursorGetCTRANSWODistMark%ROWTYPE;
    varDistmarkFrom NUMBER;
    varDistmarkFromAttribute VARCHAR2(10);
    varDistmarkTo NUMBER;
    varDistmarkToAttribute VARCHAR2(10);
    BEGIN
    -- Process From measurement
    IF NOT CursorGetFromDistMakrers%ISOPEN
    THEN
    OPEN CursorGetFromDistMarkers(:NewWO.COMPKEY, :NewWO.DISTFROMFT);
    END IF;
    FETCH CursorGetFromDistMarkers INTO FromDistanceMarker;
    IF CursorGetFromDistMarkers%NOTFOUND
    THEN
    -- No distance markers found, use MILES
    varDistmarkFrom := :NewWO.DISTFROMFT / 5280;
    varDistmarkFromAttribute := 'MILES';
    ELSE
    -- Found a distance marker, convert to its units and use those
    -- Distance is the Marker start distance plus the offset from that start of the marker
    varDistmarkFrom := FromDistanceMarker.MARKERFROM + :NewWO.DISTFROMFT - FromDistanceMarker.DISTFROMFT;
    varDistmarkFromAttribute := FromDistanceMarker.ATTRCODE;
    END IF;
    CLOSE CursorGetFromDistMarkers;
    -- Process To measurement
    IF NOT CursorGetToDistMakrers%ISOPEN
    THEN
    OPEN CursorGetToDistMarkers(:NewWO.COMPKEY, :NewWO.DISTTOFT);
    END IF;
    FETCH CursorGetToDistMarkers INTO ToDistanceMarker;
    IF CursorGetToDistMarkers%NOTFOUND
    THEN
    -- No distance markers found, use MILES
    varDistmarkTo := :NewWO.DISTTOFT / 5280;
    varDistmarkToAttribute := 'MILES';
    ELSE
    -- Found a distance marker, convert to its units and use those
    -- Distance is the Marker start distance plus the offset from that start of the marker
    varDistmarkTo := ToDistanceMarker.MARKERFROM + :NewWO.DISTTOFT - ToDistanceMarker.DISTFROMFT;
    varDistmarkToAttribute := ToDistanceMarker.ATTRCODE;
    END IF;
    CLOSE CursorGetToDistMarkers;
    -- Check for existing record to know if we should add or update
    IF NOT CursorGetCTRANSWODistMark%ISOPEN
    THEN
    OPEN CursorGetCTRANSWODistMark(:NewWO.HISTKEY);
    END IF;
    FETCH CursorGetCTRANSWODistMark INTO CTRANSWODistMark;
    IF CursorGetCTRANSWODistMark%NOTFOUND
    THEN
    -- Record does not exist, add one
    Insert into CTRANSWODISTMARK (WORKORDERKEY, DISTMARKFROM, DISTMARKFROMATTRIBUTE, DISTMARKTO, DISTMARKTOATTRIBUTE)
    values (:NewWO.HISTKEY, varDistmarkFrom, varDistmarkFromAttribute, varDistmarkTo, varDistmarkToAttribute);
    ELSE
    -- Existing record, update it
    Update CTRANSWODISTMARK set DISTMARKFROM = varDistmarkFrom, DISTMARKFROMATTRIBUTE = varDistmarkFromAttribute,
    DISTMARKTO = varDistmarkTo, DISTMARKTOATTRIBUTE = varDistmarkToAttribute
    Where WORKORDERKEY = :NewWO.HISTKEY;
    END IF;
    END;
    END;
    run;
    show errors trigger MaintainCTRANSWODISTMARK;

    the cursor is mispelled
      IF NOT CursorGetFromDistMakrers%ISOPENchange it to:
    IF NOT CursorGetFromDistMarkers%ISOPEN

  • ORA-06550: line 1, column 17: PL/SQL: ORA-00936: missing expression ORA-06550: line 1, column 9: PL/SQL: SQL Statement ignored

    Here is tthe code:
    begin
    declare
      p varchar2(32767) := null;
      l_clob clob;
      l_length number := 1;
    begin
    p:=p||'F|#OWNER#:QS_SPECIFICHHNO:P2_HHNO:HHNO';
    wwv_flow_api.create_page_process(
      p_id     => 1223125545905315 + wwv_flow_api.g_id_offset,
      p_flow_id=> wwv_flow.g_flow_id,
      p_flow_step_id => 2,
      p_process_sequence=> 1,
      p_process_point=> 'AFTER_SUBMIT',
      p_process_type=> 'DML_FETCH_ROW',
      p_process_name=> 'Fetch Row from QS_SPECIFICHHNO',
      p_process_sql_clob => p,
      p_process_error_message=> 'Unable to fetch row.',
      p_process_success_message=> '',
      p_process_is_stateful_y_n=>'N',
      p_runtime_where_clause=>'WHERE ( ( (HHNO) = P2_HHNO ) )',
      p_process_comment=>'');
    end;
    null;
    end;
    I execute it as follows in SQL Developer:
    select * from QS_SPECIFICHHNO
    WHERE ( ( (HHNO) = &P2_HHNO ) )
    No problem:  I receive exactyl one row in my result set which is what I expect.
    I think (definitely correct me if I am wrong)  Apex is complaining about the following line of code:
    p:=p||'F|#OWNER#:QS_SPECIFICHHNO:P2_HHNO:HHNO';
    It is complaining about a missing expession line 1 ccolumn 9  -   |#OWNER#:
    This is an Automatic Fetch query.  P2_HHNO is a simple text field where the user enters a primary key value (Household Number)
    The household number is used in the where clause of the QS_SPECIFICHHNO view.
    Here is the view:
    CREATE OR REPLACE FORCE VIEW "CASETRANS"."QS_SPECIFICHHNO" ("HHNO","CNAME","PDATE","TDATE","AGE","INWORKNO","ONWORKNO","ONCPS","ONYTHSRV","CPA","TMSUCCESS","VOL","D_N","DLQ","TRU","VPA","PA5","PA46","CPC","COOHPA4","COOHPA5","KINPA5","KINPA4","COOH","CKIN") AS
      SELECT HHNO,
             CNAME,
             PDate,
             TDate,
             msaccess_utilities.datediff('d', PDate, TDate, 0) Age,
             InWorkNo,
             OnWorkNo,
             OnCPS,
             OnYthSrv,
             CPA,
             TmSuccess,
             Vol,
             D_N,
             DLQ,
             TRU,
             VPA,
             PA5,
             PA46,
             CPC,
             COOHPA4,
             COOHPA5,
             KINPA5,
             KINPA4,
             COOH,
             CKIN
        FROM CaseTransfers
        ORDER BY CaseTransfers.HHNo,
                 CaseTransfers.PDate DESC

    'F|#OWNER#:QS_SPECIFICHHNO:P2_HHNO:HHNO'
    Is perfectly valid, it is an APEX DML string
    F = Fetch
    #OWNER# = the schema from the workspace
    QS_SPECIFICHHNO = the table/view
    P2_HHNO = The APEX item to match with the key
    HHNO = The key in the table/view
    The p_runtime_where_clause appears to be invalid;
    a) The "WHERE" keyword is not necessary, also it should be '&P2_HHNO.' not '&P2_HHNO'
    b) The record should have already matched using the DML string
    Try deleting the runtime_where_clause, it should then work.
    regards,

  • Crystal Reports Statement Ignored

    Can someone explain to me why there are records on my Crystal Reports that have values that are equal to "Cash" (in data column "") although my logic (Line #4) is suppose to exclude all records with "Cash" for the "" data column ?  Thanks  ! ! !
    1)  in {?RWDate}
    2)  And Not( in ["5021", "5022", "5023", "5024",
    3)         "5025", "5026", "5027", "5028", "5029", "5030", "5031", "5032"]
    4)  And <> "Cash")
    5)  And ((Not( Like 'TBD'
    6)  And ( = 5 Or = 8)))
    7)  And Not( Like 'Approval'))
    Edited by: Lenell Hooker on Mar 5, 2010 6:52 PM

    Micah/Carl/Fuskie/Graham,
    I got it . . . I used trim(ucase(field)) and removed ")" from the fourth (4th) line
    and placed it on the third (3rd) line as shown below.  Thanks to all ! ! !
    StringVar strRef_Purpose;
    strRef_Purpose := ;
    strRef_Purpose := Trim((ucase(strRef_Purpose)));
    1) in {?RWDate}
    2) And Not( in ["5021", "5022", "5023", "5024",
    3) "5025", "5026", "5027", "5028", "5029", "5030", "5031", "5032"] )
    4) And strRef_Purpose "&lt;" and "&gt;" "Cash"
    5) And ((Not( Like 'TBD'
    6) And ( = 5 Or = 8)))
    7) And Not( Like 'Approval'))

  • Error(11,1): PL/SQL: SQL Statement ignored

    FUNCTION getName ( theSSN IN NUMBER ) RETURN VARCHAR2
    IS
    theTotal NUMBER;
    theName VARCHAR2(40);
    s varchar2(10);
    BEGIN
    select count(*) into theTotal from employee where SSN = theSSN;
    if (theTotal = 0) then
    RETURN('');
    else
    select sex as s, (FName || ' ' || Lname) into theName
    from employee
    where SSN = theSSN;
    if s='f' then
    RETURN (theName);
    end if;
    end if;
    endI should how to write this line. Thank!

    Hi,
    Try to modify next in bold :
    FUNCTION getName ( theSSN IN NUMBER ) RETURN VARCHAR2
    IS
    theTotal NUMBER;
    theName VARCHAR2(40);
    s varchar2(10);
    BEGIN
    select count(*) into theTotal from employee where SSN = theSSN;
    if (theTotal = 0) then
    RETURN('');
    else
    select sex <s>as s</s>, (FName || ' ' || Lname)
    into s, theName
    from employee
    where SSN = theSSN;
    if s='f' then
    RETURN (theName);
    else
    RETURN('');
    end if;
    end if;
    endNicolas.

  • Can we use return statement in procedure?

    Can we use return statement in procedure or we can use more than one return statement in procedure?

    HamidHelal wrote:
    NOReally? Did you at least test it? You can use RETURN in procedure or in anonymous PL/SQL block. The only restriction is you can't specify return value:
    SQL> begin
      2      dbms_output.put_line('Before return');
      3      return;
      4      dbms_output.put_line('After return');
      5  end;
      6  /
    Before return
    PL/SQL procedure successfully completed.
    SQL> create or replace
      2    procedure p1
      3      is
      4      begin
      5          dbms_output.put_line('Before return');
      6          return;
      7          dbms_output.put_line('After return');
      8  end;
      9  /
    Procedure created.
    SQL> exec p1;
    Before return
    PL/SQL procedure successfully completed.
    SQL> begin
      2      dbms_output.put_line('Before return');
      3      return 99;
      4          dbms_output.put_line('After return');
      5  end;
      6  /
        return 99;
    ERROR at line 3:
    ORA-06550: line 3, column 5:
    PLS-00372: In a procedure, RETURN statement cannot contain an expression
    ORA-06550: line 3, column 5:
    PL/SQL: Statement ignored
    SQL> create or replace
      2    procedure p1
      3      is
      4      begin
      5          dbms_output.put_line('Before return');
      6          return 99;
      7          dbms_output.put_line('After return');
      8  end;
      9  /
    Warning: Procedure created with compilation errors.
    SQL> show err
    Errors for PROCEDURE P1:
    LINE/COL ERROR
    5/9      PL/SQL: Statement ignored
    5/9      PLS-00372: In a procedure, RETURN statement cannot contain an
             expression
    SQL> SY.

  • Simple stored procedure - select with an if statement, returning a cursor

    Hi,
    I'm trying to create a very simple stored procedure, but having never worked with them before I'm not quite sure what I'm doing wrong.
    Here's my code:
    create or replace
    procedure contact_return(
        v_contact_id IN varchar2,
        p_cursor OUT SYS_REFCURSOR)
    AS
    begin
      set sql_statement varchar2(4000) := '
        SELECT URN,
          FIRSTNAME,
          LASTNAME,
          TITLE,
          CREATED_DT,
          AREA_URN,
          MOBILE,
          WORK,
          EMAIL,
          ORG_NAME,
          ADDRESS,
          POSTCODE,
          IN_USE
        FROM CONTACT';
      if v_contact_id is not null then
        sql_statement := sql_statement || ' where urn = ' || v_contact_id;
      end if;
      open p_cursor for sql_statement;
    end;
    It's actually returning 2 errors:
    Error(7,3): PL/SQL: SQL Statement ignored
    Error(7,7): PL/SQL: ORA-00922: missing or invalid option
    Which seem to be a problem with my set sql_statement line, but it looks correct to me?
    Thanks

    rajendra wrote:
    Dear User,
    It is not allowed to declare a variable inside the PL/SQL block means after begin ( in your case line no 7 ).
    Lot of errors in your code.
    Tell me your exact requirement and what you want to do , after that I will be able to solve your problem.
    Thanks,
    Rajendra
    Well, you can declare after the begin, though it'll be as part of an embedded code block e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure contact_return(empno IN  number
      2                                            ,c     OUT SYS_REFCURSOR
      3                                            ) AS
      4  begin
      5    declare
      6      sql_statement varchar2(4000) := '
      7        select *
      8        from emp
      9        where empno = nvl(:1,empno)';
    10    begin
    11      open c for sql_statement using contact_return.empno;
    12    end;
    13* end;
    SQL> /
    Procedure created.
    SQL> var x refcursor
    SQL> exec contact_return(7788,:x);
    PL/SQL procedure successfully completed.
    SQL> print x;
         EMPNO ENAME      JOB              MGR HIREDATE                    SAL       COMM     DEPTNO
          7788 SCOTT      ANALYST         7566 19-APR-1987 00:00:00       3000                    20
    so, it is allowed, as long as it's coded correctly.

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

  • Select statement in a procedure

    Hi Grues,
    I have written this procedure but it gives me error,
    can anyone guide me what should i do.
    CREATE OR REPLACE PROCEDURE FLAG_ANALYSIS IS
    CURSOR CUR_FLAG IS
              SELECT SOURCE, FEAT_CODE
              FROM FLAG_ANALYSIS_SID_L3 ;
              M_SOURCE      VARCHAR2(250);
              M_FEAT_CODE      NUMBER;
              M_REL13_SID     NUMBER;
              M_REL14_SID     NUMBER;
              M_REL14_L3     NUMBER;
    BEGIN
         OPEN CUR_FLAG;
    LOOP
         M_SOURCE      := '-';
         M_FEAT_CODE     := 0 ;
         M_REL13_SID     := 0 ;
         M_REL14_SID     := 0 ;
         M_REL14_L3     := 0 ;
         fetch CUR_FLAG into      M_SOURCE,M_FEAT_CODE;
    exit when CUR_FLAG%found = false;
         M_REL13_SID:= SELECT COUNT(*) FROM ARCHIVE_POI_14_3.REL13_3_AU_POI_INTERM A,
                   POI_SHARED.SH_POI_sID B
                   WHERE A.SID=B.SID AND B.FEAT_CODE=M_FEAT_CODE
                   AND A.SOURCE=M_SOURCE GROUP BY A.SID;
         commit;
    end loop;
         close CUR_FLAG;
    commit;
    end;
    /

    34/2 PL/SQL: SQL Statement ignored
    37/41 PL/SQL: ORA-00933: SQL command not properly ended
    set serveroutput on;
    CREATE OR REPLACE PROCEDURE FLAG_ANALYSIS IS
    CURSOR CUR_FLAG IS
              SELECT SOURCE, FEAT_CODE
              FROM FLAG_ANALYSIS_SID_L3 ;
              M_SOURCE      VARCHAR2(250);
              M_FEAT_CODE      VARCHAR2(250);
              M_REL13_SID     VARCHAR2(250);
              M_REL14_SID     VARCHAR2(250);
              M_REL14_L3     VARCHAR2(250);
    BEGIN
         OPEN CUR_FLAG;
    LOOP
         M_SOURCE      := '-';
         M_FEAT_CODE     := '-';
         M_REL13_SID     := '-';
         M_REL14_SID     := '-';
         M_REL14_L3     := '-';
         fetch CUR_FLAG into      M_SOURCE,M_FEAT_CODE;
    exit when CUR_FLAG%found = false;
         SELECT COUNT(*) FROM ARCHIVE_POI_14_3.REL13_3_AU_POI_INTERM A,
                   POI_SHARED.SH_POI_sID B
                   WHERE A.SID=B.SID AND B.FEAT_CODE=M_FEAT_CODE
                   AND A.SOURCE=M_SOURCE GROUP BY A.SID into M_REL13_SID;
    --commit;
    end loop;
         close CUR_FLAG;
    commit;
    end;
    /

Maybe you are looking for

  • Back to my Mac causing kernel panic 100%.

    Every time I try to connect to my iMac (27", 2011 model, running latest Lion) from my MacBook Pro (13" 2009 model, running latest Lion), using Back to my Mac causes the iMac to kernel panic and reboot.  This started relatively recently, perhaps with

  • Show only with error messages

    How can I have this: <div class="userMessage"> show up in my page only if there are any error messages to display? I have tried to to bind an outputText to my backing bean like this: JSF page: <h:outputText value="<div class=userMessage>" id="userMes

  • Possible to make folders or something to help organize ipod playlists?

    In my Itunes I use the folders to help organize my playlists nicely. But in my new Ipod these playlists disappear, making for a list of too many playlist in the playlists section to scroll through. Is there any way to organise the playlists in the pl

  • Files to backup ?

    If someday my harddisk breakdown or my computer might get stolen, I would like to be prepared and backup the files, that are made when syncing with iTunes. But where are these files ? I have done a search, and I guess that they might be located here

  • Which difference parallel database and RAC database

    Hi Experts, I saw some document about parallel database and RAC database. My boss confused these two product. which difference between parallel database and RAC database? does parallel database is a "old RAC"? Thanks Jim