[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 44
  • Last Modified:

Procedure gives error

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
KamalAgnihotri
Asked:
KamalAgnihotri
  • 5
  • 4
1 Solution
 
slightwv (䄆 Netminder) Commented:
>>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
 
slightwv (䄆 Netminder) Commented:
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
 
KamalAgnihotriAuthor Commented:
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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
slightwv (䄆 Netminder) Commented:
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
 
KamalAgnihotriAuthor Commented:
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
 
slightwv (䄆 Netminder) Commented:
Are you connected to the database as the BASE user?
0
 
KamalAgnihotriAuthor Commented:
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
 
slightwv (䄆 Netminder) Commented:
>>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
 
KamalAgnihotriAuthor Commented:
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
 
Steve WalesSenior Database AdministratorCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now