Solved

Procedure gives error

Posted on 2015-02-12
11
35 Views
Last Modified: 2016-02-08
Hi Experts,

Belo is a procedure, I am having issues. Please help me fix it.

I hav ethe sql statement that returns the exoected result. I wan to pass two parameters in the where claus which hac a CONTAINS parameter. THe first paramere is  p_Near_Text        which is a varchar2 datatype. the second, p_Near_Date is a data datatype.

CREATE OR REPLACE PROCEDURE NEAR_SARS_OF_INTEREST
    (p_Near_Text        IN         Varchar2,
     p_Near_Date        IN         Date)
IS
Type t_Doc_Record is RECORD (
   v_DOC_ID           NRTV.DOC_ID%Type,
   v_FILG_DT          DOC.FILG_DT%Type,
   v_LST_UPD_TS       DOC.LST_UPD_TS%Type);
   v_DOCUMENT t_Doc_Record;
BEGIN
     SELECT N.DOC_ID DOC_ID , D.FILG_DT FILING_DATE, D.LST_UPD_TS LAST_UPDATE
     INTO v_DOCUMENT
     FROM BASE.NRTV N,  BASE.DOC D
     WHERE CONTAINS = p_Near_Text
     AND N.DOC_ID=D.DOC_ID
     AND D.LST_UPD_TS > p_Near_Date;
END;
/

--################################################

Errors for PROCEDURE NEAR_SARS_OF_INTEREST:

LINE/COL ERROR
-------- -----------------------------------------------------------------
5/1      PL/SQL: Item ignored
6/4      PLS-00320: the declaration of the type of this expression is
         incomplete or malformed

6/23     PLS-00201: identifier 'NRTV.DOC_ID' must be declared
11/6     PL/SQL: SQL Statement ignored
13/6     PL/SQL: ORA-00904: : invalid identifier
SQL>
0
Comment
Question by:KamalAgnihotri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
11 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40606121
>>PLS-00201: identifier 'NRTV.DOC_ID' must be declared

Make sure there is a doc_id column in the nrtv table.

I cannot reproduce the first error.  What version of Oracle are you on (all 4 numbers please).
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40606126
Here is my test case that compiles using 11.2.0.2:
drop table my_nrtv purge;
create table my_nrtv(doc_id number, contains number); 

drop table my_doc purge;
create table my_doc(doc_id number, filg_dt date, lst_upd_ts date); 



CREATE OR REPLACE PROCEDURE NEAR_SARS_OF_INTEREST
     (p_Near_Text        IN         Varchar2,
      p_Near_Date        IN         Date)
 IS
 Type t_Doc_Record is RECORD (
    v_DOC_ID           NRTV.DOC_ID%Type,
    v_FILG_DT          DOC.FILG_DT%Type,
    v_LST_UPD_TS       DOC.LST_UPD_TS%Type);
    v_DOCUMENT t_Doc_Record;
 BEGIN
      SELECT N.DOC_ID DOC_ID , D.FILG_DT FILING_DATE, D.LST_UPD_TS LAST_UPDATE
      INTO v_DOCUMENT
      FROM my_NRTV N,  my_DOC D 
      WHERE CONTAINS = p_Near_Text
      AND N.DOC_ID=D.DOC_ID
      AND D.LST_UPD_TS > p_Near_Date;
 END;
/

show errors

Open in new window

0
 

Author Comment

by:KamalAgnihotri
ID: 40606417
Hi SlightWV,


The Database version is:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, Oracle Label Security, OLAP
Data Mining and Real Application Testing options


Warning: Procedure created with compilation errors.

SQL> sho errors
Errors for PROCEDURE NEAR_SARS_OF_INTEREST:

LINE/COL ERROR
-------- -----------------------------------------------------------------
5/1      PL/SQL: Item ignored
6/4      PLS-00320: the declaration of the type of this expression is
         incomplete or malformed

6/23     PLS-00201: identifier 'NRTV.DOC_ID' must be declared
11/6     PL/SQL: SQL Statement ignored
13/6     PL/SQL: ORA-00904: : invalid identifier
SQL>

--###################################

I checked, the table once again, the column DOC_ID in table NRTV exists.

Please help.  Thanks.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40606423
In the code you posted, you are looking at the NRTV table in the BASE schema.  Make sure that one has the correct column.

Post the results of:
describe BASE.NRTV
0
 

Author Comment

by:KamalAgnihotri
ID: 40606430
Here it is..........

SQL> desc BASE.NRTV;
 Name                                      Null?    Type
 ----------------------------------------- -------- ------------------
 NRTV_ID                                            NUMBER(38)
 DOC_ID                                             NUMBER(38)
 NRTV_TXT                                           CLOB
 REC_CRTD_TS                                        TIMESTAMP(6)
 REC_CRTD_NM                                        VARCHAR2(100)
 NRTV_SEQ_NUM                                       NUMBER(6)
 LST_UPD_USR_NM                                     VARCHAR2(100)
 LST_UPD_TS                                         TIMESTAMP(6)
 USTAGE_ETL_ID                                      NUMBER(38)
 BTCH_LG_ID                                         NUMBER(38)
 SYS_ENTRY_DT                                       DATE
 BATCH_NUM                                          NUMBER(20)

SQL>
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40606434
Are you connected to the database as the BASE user?
0
 

Author Comment

by:KamalAgnihotri
ID: 40606456
No I am not. But I have full permission to view (SELECT) the tables in the tables.

The following query runs successfully.

SQL>
SQL> SELECT N.DOC_ID DOC_ID , D.FILG_DT FILING_Date, D.LST_UPD_TS LAST_UPDATE
  2  FROM BASE.NRTV N,  BASE.DOC D
  3  WHERE CONTAINS (N.NRTV_TXT, 'NEAR(((XXXXXXXXXXX --- Taken out on purpose),(XXXXXXXXXXX --- Taken out on purpose)),10)')>0
  4  AND N.DOC_ID=D.DOC_ID
  5  AND D.LST_UPD_TS > '01-JAN-2014';

But the query does run sucessfully.

    DOC_ID FILING_DA LAST_UPDATE
---------- --------- ---------------------------------------------------------------------------
1.0048E+10 09-JUN-14 13-JUN-14 07.40.44.000000 AM
1.0031E+10 09-AUG-13 03-JUL-14 09.01.40.000000 PM
1.0049E+10 02-JUL-14 03-JUL-14 09.01.40.000000 PM
1.0053E+10 21-NOV-12 12-JAN-15 09.26.02.000000 AM

SQL>
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40606462
>>But I have full permission to view (SELECT) the tables in the tables.

Permission to objects needs to be explicitly granted when being used inside of procedures and functions.  The permission cannot be granted through a role.

Log in as the BASE user:
grant select on NRTV to procedure_owner;
grant select on DOC to procedure_owner;

Then try again.
0
 

Author Comment

by:KamalAgnihotri
ID: 40606524
Thanks. I am working on it. It requires approval  from "congress" (almost). Just kidding. Hence it may take a while. I will keep the question open for a few days. Once again. Thanks.
0
 
LVL 22

Expert Comment

by:Steve Wales
ID: 41453934
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to free up undo space? 3 62
Oracle SQL - Query help 7 78
having some issue on pl sql procedure 1 29
Oracle performance tuning 2 16
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question