Solved

Procedure gives error

Posted on 2015-02-12
11
31 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
  • 5
  • 4
11 Comments
 
LVL 76

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 76

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
 
LVL 76

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 76

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 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to take different types of Oracle backups using RMAN.

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now