Procedure compile error

Hi, i get an ' identifier EMAIL_ATTACH must be declared' error when i run the following code
create or replace
PROCEDURE read_demo(FILENAME VARCHAR2) IS
V_BFILE BFILE := BFILENAME(EMAIL_ATTACH, FILENAME);
V_LGH_FILE BINARY_INTEGER;
BEGIN
dbms_lob.fileopen(V_BFILE, dbms_lob.file_readonly);
dbms_lob.fileclose(V_BFILE);
END;
EMAIL_ATTACH is a Directory that has been created on the database by myself.
Any ideas to what th problem may or not be.

Hi
you probably just need to enclose the EMAIL_ATTACH with '' like the example on
http://www.techonthenet.com/oracle/functions/bfilename.php
Hope it helps.

Similar Messages

  • PL/SQL Procedure Compilation error

    Hi,
    <br><br>
    I have wrote a PL/SQL Stored Procedure to read a couple of table values and then output some data to a file, when I create the procedure on the database I get the following compilation error:
    <br><br>
    LINE/COL ERROR<br>
    -------- -----------------------------------------------------------------<br>
    25/7 PLS-00103: Encountered the symbol ")" when expecting one of the<br>
    following:<br>
    ( - + case mod new null <an identifier><br>
    <a double-quoted delimited-identifier> <a bind variable> avg<br>
    count current max min prior sql stddev sum variance execute<br>
    forall merge time timestamp interval date<br>
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string> pipe<br>
    The symbol "null" was substituted for ")" to continue.<br>
    <br>
    The script is below: <br><br>
    CREATE OR REPLACE <br>
         PROCEDURE TDF_EXTRACT AS<br>
    v_file UTL_FILE.FILE_TYPE;<br>
    YEAR number(4);<br>
    Q1_VALUE NUMBER(7);<br><br>
    BEGIN<br><br>
    SELECT PERSON_VALUE<br>
    INTO     Q1_VALUE<br>
    FROM PERSON<br>
    WHERE ID = 79;<br><br>
    SELECT EXTRACT(YEAR FROM SYSDATE)<br>
    INTO YEAR <br>
    FROM DUAL;<br><br>
    v_file := UTL_FILE.FOPEN(location => '/tmp',<br>
    filename => 'extratced_values.txt',<br>
    open_mode => 'W',<br>
    max_linesize => 32767);<br><br>
    UTL_FILE.PUT_LINE(v_file,<br>
    'Q1'     ||     YEAR     ||     '23'     ||     Q1_VALUE || '\r\n' ||<br>
              );<br><br>
    UTL_FILE.FCLOSE(v_file);<br><br>
    END TDF_EXTRACT;

    'Q1' || YEAR || '23' || Q1_VALUE || '\r\n' ||
    );Syntax error during concatenation, maybe?
    C.
    Message was edited by:
    cd

  • Procedure compilation Error.......

    Hi ,
    I am getting an error while compiling the procedure...Please help me out..
    create or replace procedure generate_test_file RETURN NUMBER
    IS
    CURSOR curEmployee IS
    SELECT empno,
    ename,sal
    FROM Emp;
    --Line to output
    sOutputLine VARCHAR2(4000);
    uFileHndl UTL_FILE.FILE_TYPE;
    sFileName VARCHAR2(30);
    sEmployeeid varchar2(30);
    sEmployeeName varchar2(50);
    sEmployeeSalary varchar2(30);
    sOutputLine varchar2(120);
    -- The directory you want file to be generated
    gs_TestDir CONSTANT VARCHAR2(50):='c:\tms\';
    c_comma VARCHAR2(2) :=',' ; -- Delimiter
    BEGIN
    OPEN curEmployee
    sFileName := 'test.csv'; ---------(ERRORED OUT IN THIS LINE)
    uFileHndl := UTL_FILE.FOPEN(gs_TestDir,sFileName,'w');
    LOOP
    FETCH curEmployee INTO sEmployeeId,sEmployeeName,sEmployeeSalary;
    EXIT WHEN curEmployee%NOTFOUND;
    sOutputLine := sEmployeeId || c_comma ||
    sEmployeeName || c_comma ||
    sEmployeeSalary;
    UTL_FILE.PUT_LINE(uFileHndl,sOutputLine);
    END LOOP;
    CLOSE curEmployee;
    -- Close the output file
    UTL_FILE.FCLOSE(uFileHndl);
    RETURN 0;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(SQLERRM);
    UTL_FILE.FCLOSE(uFileHndl);
    CLOSE curEmployee;
    RETURN SQLCODE;
    END;
    Error:
    20/1 PLS-00103: Encountered the symbol "SFILENAME" when expecting one
    of the following:
    . ( % ; for
    The symbol ";" was substituted for "SFILENAME" to continue.
    Thanks,
    Nitesh

    Check out the comments in ---------------------XXXX--------------------- below in the code and also this is FUNCTION and not PROCEDURE as you retruning some value using RETURN clause.
    The below code is compiling fine.
    create or replace function generate_test_file RETURN NUMBER
    IS
    CURSOR curEmployee IS
    SELECT empno,
    ename,sal
    FROM Emp;
    --Line to output
    sOutputLine VARCHAR2(4000);
    uFileHndl UTL_FILE.FILE_TYPE;
    sFileName VARCHAR2(30);
    sEmployeeid varchar2(30);
    sEmployeeName varchar2(50);
    sEmployeeSalary varchar2(30);
    sOutputLine varchar2(120); ---------------DECLARE TWICE ----------------------------
    -- The directory you want file to be generated
    gs_TestDir CONSTANT VARCHAR2(50):='c:\tms\';
    c_comma VARCHAR2(2) :=',' ; -- Delimiter
    BEGIN
    OPEN curEmployee; ----------------SEMICOLON MISSING ---------------------
    sFileName := 'test.csv'; ---------(ERRORED OUT IN THIS LINE)
    uFileHndl := UTL_FILE.FOPEN(gs_TestDir,sFileName,'w');
    LOOP
    FETCH curEmployee INTO sEmployeeId,sEmployeeName,sEmployeeSalary;
    EXIT WHEN curEmployee%NOTFOUND;
    sOutputLine := sEmployeeId || c_comma ||
    sEmployeeName || c_comma ||
    sEmployeeSalary;
    UTL_FILE.PUT_LINE(uFileHndl,sOutputLine);
    END LOOP;
    CLOSE curEmployee;
    -- Close the output file
    UTL_FILE.FCLOSE(uFileHndl);
    RETURN 0;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(SQLERRM);
    UTL_FILE.FCLOSE(uFileHndl);
    CLOSE curEmployee;
    RETURN SQLCODE;
    END;
    ~Vinod

  • Warning: Procedure created with compilation errors.

    I am trying to upload a pdf file into a blob column of a table. I get this error with these three ways of doing that:Warning: Procedure created with compilation errors.
    Any ideas why?
    -- THE STORAGE TABLE FOR THE IMAGE FILE
    ALTER TABLE PDM
    DROP PRIMARY KEY CASCADE;
    DROP TABLE PDM CASCADE CONSTRAINTS;
    CREATE TABLE PDM (
    DNAME VARCHAR2(30), -- DIRECTORY NAME
    SNAME VARCHAR2(30), -- SUBDIRECTORY NAME
    FNAME VARCHAR2(30), -- FILE NAME
    IBLOB BLOB); -- IMAGE FILE
    -- CREATE THE PROCEDURE TO LOAD THE FILE
    CREATE OR REPLACE PROCEDURE LOAD_FILE (
    PDNAME VARCHAR2,
    PSNAME VARCHAR2,
    PFNAME VARCHAR2) IS
    SRC_FILE BFILE;
    DST_FILE BLOB;
    LGH_FILE BINARY_INTEGER;
    BEGIN
    SRC_FILE := BFILENAME('PDF_DIR', '266-5210.pdf');
    -- INSERT A NULL RECORD TO LOCK
    INSERT INTO PDM
    (DNAME, SNAME, FNAME, IBLOB)
    VALUES
    (PDNAME, PSNAME, PFNAME, EMPTY_BLOB())
    RETURNING IBLOB INTO DST_FILE;
    -- LOCK RECORD
    SELECT IBLOB
    INTO DST_FILE
    FROM PDM
    WHERE DNAME = PDNAME
    AND SNAME = PSNAME
    AND FNAME = PFNAME
    FOR UPDATE;
    -- OPEN THE FILE
    DBMS_LOB.FILEOPEN(SRC_FILE, DBMS_LOB.FILE_READONLY);
    DBMS_LOB.OPEN(DST_FILE, DBMS_LOB.LOB_READWRITE);
    -- DETERMINE LENGTH
    LGH_FILE := DBMS_LOB.GETLENGTH(SRC_FILE);
    -- READ THE FILE
    DBMS_LOB.LOADFROMFILE(DST_FILE, SRC_FILE, LGH_FILE);
    -- UPDATE THE BLOB FIELD
    UPDATE PDM
    SET IBLOB = DST_FILE
    WHERE DNAME = PDNAME
    AND SNAME = PSNAME
    AND FNAME = PFNAME;
    -- CLOSE FILE
    DBMS_LOB.FILECLOSE(SRC_FILE);
    END LOAD_FILE;
    -- THE STORAGE TABLE FOR THE IMAGE FILE
    ALTER TABLE PDM
    DROP PRIMARY KEY CASCADE;
    DROP TABLE PDM CASCADE CONSTRAINTS;
    CREATE TABLE PDM
    FNAME VARCHAR2(1000)
    ,IBLOB BLOB
    -- CREATE THE PROCEDURE TO LOAD THE FILE
    CREATE OR REPLACE PROCEDURE LOAD_FILE AS (
    SRC_FILE BFILE := BFILENAME('PDF_DIR', '262-2827.pdf');
    DST_FILE BLOB;
    BEGIN
    -- INSERT A NULL RECORD TO LOCK
    INSERT INTO PDM
    (FNAME, IBLOB)
    VALUES
    ('262-2827.pdf', EMPTY_BLOB())
    RETURNING IBLOB INTO DST_FILE;
    -- OPEN THE FILE
    DBMS_LOB.FILEOPEN(SRC_FILE, DBMS_LOB.FILE_READONLY);
    DBMS_LOB.OPEN(DST_FILE, DBMS_LOB.LOB_READWRITE);
    -- READ THE FILE
    DBMS_LOB.LOADFROMFILE( SRC_FILE, DST_FILE);
    -- UPDATE THE BLOB FIELD
    UPDATE PDM
    SET FNAME = SRC_FILE,
    IBLOB = DST_FILE;
    -- CLOSE FILE
    DBMS_LOB.CLOSE(DST_FILE);
    DBMS_LOB.FILECLOSE(SRC_FILE);
    COMMIT;
    END LOAD_FILE;
    ALTER TABLE IMAGE_TABLE
    DROP PRIMARY KEY CASCADE;
    DROP TABLE IMAGE_TABLE CASCADE CONSTRAINTS;
    CREATE TABLE IMAGE_TABLE (
    ID NUMBER PRIMARY KEY,
    IMAGE ORDSYS.ORDIMAGE);
    CREATE OR REPLACE DIRECTORY IMAGEDIR AS 'C:\cards\';
    GRANT READ ON DIRECTORY IMAGEDIR TO PUBLIC;
    GRANT READ ON DIRECTORY MY_FILES TO twilliam;
    GRANT READ ON DIRECTORY MY_FILES TO tmwillia;
    CREATE OR REPLACE PROCEDURE IMAGE_IMPORT(DEST_ID NUMBER,
    FILENAME VARCHAR2)
    IS
    IMG ORDSYS.ORDIMAGE;
    CTX RAW(64) := NULL;
    BEGIN
    DELETE FROM IMAGE_TABLE
    WHERE ID = DEST_ID;
    INSERT INTO IMAGE_TABLE (ID, IMAGE)
    VALUES (DEST_ID, ORDSYS.ORDIMAGE.INIT())
    RETURNING IMAGE INTO IMG;
    IMG.IMPORTFROM(CTX, 'FILE', 'IMAGEDIR', FILENAME);
    UPDATE IMAGE_TABLE SET IMAGE=IMG WHERE ID=DEST_ID;
    END
    CALL IMAGE_IMPORT(7142,'125-0502.pdf');
    CALL IMAGE_IMPORT(7143,'125-0503.pdf');
    SELECT ID,
    T.IMAGE.GETHEIGHT(),
    T.IMAGE.GETWIDTH()
    FROM IMAGE_TABLE T;
    SELECT ID,
    T.IMAGE.GETFILEFORMAT(),
    T.IMAGE.GETCOMPRESSIONFORMAT()
    FROM IMAGE_TABLE T;
    SELECT ID,
    T.IMAGE.GETCONTENTFORMAT(),
    T.IMAGE.GETCONTENTLENGTH()
    FROM IMAGE_TABLE T;

    In the second load_file procedure you should probably change the update command
    -- UPDATE THE BLOB FIELD
    UPDATE PDM
    SET FNAME = SRC_FILE,
    IBLOB = DST_FILE;into this
    -- UPDATE THE BLOB FIELD
    UPDATE PDM
    SET IBLOB = DST_FILE
    WHERE  FNAME = '262-2827.pdf';but I'm not sure how to explain the eof error message. Usually this happens when you forget an "END;" or "END LOOP;" command.
    Ok I rechecked and the declaration of the second procedure seems wrong
    -- CREATE THE PROCEDURE TO LOAD THE FILE
    CREATE OR REPLACE PROCEDURE LOAD_FILE AS (
    SRC_FILE BFILE := BFILENAME('PDF_DIR', '262-2827.pdf');
    DST_FILE BLOB;
    BEGINshould be rewritten as
    -- CREATE THE PROCEDURE TO LOAD THE FILE
    CREATE OR REPLACE PROCEDURE LOAD_FILE
      AS
      SRC_FILE BFILE := BFILENAME('PDF_DIR', '262-2827.pdf');
      DST_FILE BLOB;
    BEGIN
    ...I removed one parenthesis which was not closed.
    And for the image_import procedure there is a semikolon missing after the final END.
    END*;*
    Edited by: Sven W. on Nov 24, 2008 5:54 PM.
    Edited by: Sven W. on Nov 24, 2008 5:56 PM
    Edited by: Sven W. on Nov 24, 2008 5:59 PM

  • Create Procedure - How to Detect Compilation Errors

    Hi,
    I am working on an application where users will be able to type in their own stored procedures. I perform some basic parsing of the function spec, to make sure it is well-formed, but that's all the parsing I do. I assumed an SQLException would be thrown by the executeUpdate() call which creates the procedure if the procedure is malformed. This is not the case. executeUpdate() returns 0, whether or not the procedure was created with compilation errors.
    After they type it in, I would like to be able to tell the user whether or not their procedure is syntactically correct. Given that writing a complete PL/SQL parser in Java is obviously out of the question, how can I do this? There must be a way.
    Thanks in advance for any and all help,
    James

    Note that there is a USER_ERRORS table.
    You could DELETE FROM USER_ERRORS before issuing the procedure declaration and then SELECT ... FROM USER_ERRORS to see if errors have occured and if so to print them out.

  • Help with Data Block Based on Procedure--getting compilation error

    I am trying to create a datablock based on a procedure , but im getting errors in compilation:
    Errors are :
    1) identifier 'HSM_WSH_DEL_UTIL.DEL_TBL' must be declared
    2)PL/SQL ERROR 320 at line 7, column 27
    the declaration of the type of this expression is incomplete or malformed
    ANy Help would be appreciated !
    Heres my pkg spec and body for the data block:
    CREATE OR REPLACE PACKAGE hsm_wsh_del_util IS
    TYPE del_record is record
    (delivery_id number);
    TYPE del_tbl is table of del_record INDEX BY BINARY_INTEGER;
    procedure do_query(p_del IN OUT del_tbl);
    END hsm_wsh_del_util ;
    CREATE OR REPLACE PACKAGE BODY hsm_wsh_del_util IS
    procedure do_query(p_del IN OUT del_tbl)
    IS
    idx number :=1;
    CURSOR DELIVERY IS
    SELECT DELIVERY_ID
    FROM abc_deliveries;
    begin
    FOR CUR IN DELIVERY LOOP
    p_del(idx).delivery_id :=cur.delivery_id;
    idx:= idx+1;
    END LOOP;
    end do_query;
    END hsm_wsh_del_util;
    Edited by: 981170 on Mar 13, 2013 1:08 PM

    Hi,
    Yes I did use the wizard,
    I agve it the package.proc name for query.
    it pulled up the field delivery ID,
    Hit finish, because I do not need update/delete/inserts.
    the query data source columns and arguments was defaulted correctly.
    THe QUERY-PROCEDURE was built by default.
    It is giving me an error though: wrong number or types of arguments in call to POPULATE_BLOCK..
    DECLARE
    bk_data HSM_WSH_DEL_UTIL.DEL_TBL;
    BEGIN
    hsm_wsh_del_util.do_query(bk_data);
    PLSQL_TABLE.POPULATE_BLOCK(bk_data, 'NEW_DELIVERIES');
    END;

  • Procedure created with compilation errors. help?

    SQL> create or replace procedure p_update_audit_log
    2 ( p_audit_id audit_log.audit_id%type
    3 p_grade_update audit_log.grade_update%type
    4 p_grade audit_log.grade%type
    5 sys_date
    6 p_user_id audit_log.user_id%type
    7 is
    8 BEGIN
    9 insert into audit_log (user_id, audit_id, grade, grade_update,
    10 sys_date)
    11 values (p_user_id, p_audit_id, p_grade, p_grade_update, sys_date);
    12 END p_update_audit_log;
    13
    14
    15
    16
    17
    18 /
    Warning: Procedure created with compilation errors.
    SQL> show errors
    Errors for PROCEDURE P_UPDATE_AUDIT_LOG:
    LINE/COL ERROR
    3/1 PLS-00103: Encountered the symbol "P_GRADE_UPDATE" when expecting
    one of the following:
    := ) , default character
    The symbol "," was substituted for "P_GRADE_UPDATE" to continue.
    4/1 PLS-00103: Encountered the symbol "P_GRADE" when expecting one of
    the following:
    := ) , default character
    The symbol "," was substituted for "P_GRADE" to continue.
    5/1 PLS-00103: Encountered the symbol "SYS_DATE" when expecting one
    LINE/COL ERROR
    of the following:
    := ) , default character
    The symbol ", was inserted before "SYS_DATE" to continue.
    7/1 PLS-00103: Encountered the symbol "IS" when expecting one of the
    following:
    := ) , default character
    The symbol ")" was substituted for "IS" to continue.
    Could anyone help me with this problem?

    These are syntax errors:
    Try this
    create or replace procedure p_update_audit_log
    ( p_audit_id audit_log.audit_id%type,
    p_grade_update audit_log.grade_update%type,
    p_grade audit_log.grade%type,
    sys_date DATE,
    p_user_id audit_log.user_id%type)
    is
    BEGIN
    insert into audit_log (user_id, audit_id, grade, grade_update,
    sys_date)
    values (p_user_id, p_audit_id, p_grade, p_grade_update, sys_date);
    END p_update_audit_log;

  • Procedure created with compilation errors

    I created a procedure and that when I run it in SQLPlus I get this message:
    Warning: Procedure created with compilation errors.
    Where can I go to see what the errors are?

    I tried adding 'show errors' to the end of the procedure but it didn't display any errors. I'm using this script that is for MS SQL and I wanted to see what I would need to change in order for it to work in Oracle:
    Can you tell me where I should put the 'show errors' statmement?
    DROP PROCEDURE      scp_mig_jobs_copy;
    CREATE PROCEDURE scp_mig_jobs_copy
    AS
    ** File Name:
    ** scp_mig_jobs_copy.sql
    ** Procedure Name:
    ** scp_mig_jobs_copy
    ** Description:
    ** This procedure is used to move data from the limited staging table,
    **          scp_mig_jobs, to the full migration table scp_mig_jobs2
    **          It first trunacates the migration table, then copies the data
    ** Saba Version:
    ** SE2005 May release + August patch.
    ** Input Parameter(s):
    **          None
    ** Output Parameter(s):
    ** None
    ** Return Codes:
    **          None.
    ** Error Codes:
    ** None.
    ** Calling Procedure(s):
    ** Procedures Called:
    **          None.
    ** Database Table(s) Accessed:
    **          sct_mig_jobs
    **          sct_mig_jobs2
    ** Database View(s) Accessed:
    **          None.
    ** Cursor(s):
    **          None.
    ** Misc:
    BEGIN
    DECLARE @xerror     NUMBER;
    PRINT '**************************************************';
    PRINT 'Begin Copying data from the staging table, sct_mig_jobs, to the migration table, sct_mig_jobs2';
    PRINT getDate();
    PRINT ' '
    BEGIN TRAN
    TRUNCATE TABLE sct_mig_jobs2
    INSERT INTO sct_mig_jobs2 (
    name, description, custom0, custom1, --These are the only fields that the staging table has
    id, CI_Name
    created_by, created_on,
    updated_by, updated_on,
    split,
    custom2, custom3, custom4, custom5, custom6, custom7, custom8, custom9,
    process_ind, process_date, valid_rec_ind, rec_status, err_num, err_msg
    SELECT name, description, custom0, custom1, --These are the only fields that the staging table has
    NULL id,
         NULL CI_Name,
    NULL created_by, NULL created_on,
    NULL updated_by, NULL updated_on,
    NULL split,
    NULL custom2, NULL custom3, NULL custom4, NULL custom5, NULL custom6, NULL custom7, NULL custom8, NULL custom9,
    NULL process_ind, NULL process_date, NULL valid_rec_ind, NULL rec_status, NULL err_num, NULL err_msg
    FROM sct_mig_jobs
    SET @xerror = @@error;
    IF(@xerror<>0)
    BEGIN
    ROLLBACK TRAN;
    PRINT 'Error:: ' + STR(@xerror);
    PRINT '--Unable to copy data from the staging table to the migration table';
    END
    ELSE
    BEGIN
    COMMIT TRAN;
    PRINT 'Data successfully copied from the staging table to the migration table';
    END
    PRINT ' ';
    PRINT ' ';
    END
    /

  • Simple Create procedure throws compile error

    I have a table MyTable with two fields key and value. The table has few records with some number values.
    I want to increment this number value and return the updated number value from a procedure.
    Below is the procedure that I wrote. When I try to run this, I get this error from the SQLPlus prompt.
    Warning: Procedure created with compilation errors.
    Here is the procedure.
    CREATE OR REPLACE PROCEDURE GetNextValue
         (v_key IN VARCHAR2(25), v_value OUT NUMBER DEFAULT -1) AS
    BEGIN
         UPDATE MyTable SET value=value+1 WHERE key=v_key;
         SELECT value INTO v_value FROM MyTable WHERE key=v_key;
    END GetNextValue;
    I stored this in a .sql file.
    Also is there any way that I can write the body in single query to both update the value and return it in the return variable?
    Appreciate your help.

    Hi,
    When creating a PL/SQL procedure, always say SHOW ERRORS on a separate line right after the /. That will geive you more detailed error messages.
    In this case, you'll probably get "OUT and IN OUT formal parameters may not have default expressions".
    If you want v_value set to -1 in the event that there is no row with key=v_key, then you can say:
    CREATE OR REPLACE PROCEDURE GetNextValue
    (   v_key    IN   VARCHAR2
    ,   v_value  OUT  NUMBER
    AS
    BEGIN
        UPDATE MyTable
            SET value=value+1
            WHERE key=v_key;
        SELECT value
            INTO v_value
            FROM MyTable
            WHERE key=v_key;
    EXCEPTION
        WHEN  NO_DATA_FOUND  THEN
            v_value := -1;
        WHEN OTHERS  THEN
            RAISE;
    END GetNextValue;
    SHOW ERRORS

  • Compilation error while creating procedure

    Hi,
    I am getting compilation error while creating procedure
    CREATE OR REPLACE My_CHANGEDATE IS
    error_string VARCHAR2(400) := NULL;
    BEGIN
    Create table set_temp as select * from set;
    CURSOR c1 is
         SELECT a.SETNUM, b.CHANGEDATE from
         set a, setsp_t2 b
         where a.setnum = b.setnum
         and trunc(a.changedate) < trunc(b.CHANGEDATE);
    BEGIN
         FOR rec IN c1 LOOP
              UPDATE set SET changedate = rec.changedate
              WHERE setnum = rec.setnum;
              Insert into set_temp select * from set where setnum = rec.setnum;
              END LOOP;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              NULL;
         WHEN OTHERS THEN
                   error_string := 'My_CHANGEDATE - '||SUBSTR(SQLERRM,1,350);
    DBMS_OUTPUT.PUT_LINE(error_string);
                   RAISE;
    END My_CHANGEDATE;

    I have taken your code and cleaned it up to be more readable. Please see the comments in the code.
    CREATE OR REPLACE My_CHANGEDATE
    IS
            error_string VARCHAR2(400) := NULL;
    BEGIN
            /* The only way to issue DDL in a procedure is to either user
             * DBMS_SQL or EXECUTE IMMEDIATE. Creating objects is generally
             * not needed or recommended in frequently run code.
            Create table set_temp as select * from set;    
            /* The cursor declarations need to go in the declaration section of the
             * procedure (between IS .. BEGIN).
            CURSOR c1 is                                   
            SELECT a.SETNUM, b.CHANGEDATE from
            set a, setsp_t2 b
            where a.setnum = b.setnum
            and trunc(a.changedate) < trunc(b.CHANGEDATE);
            BEGIN   /* Where is the END that goes with this begin? */
            /* Single record processing is generally not recommended. It is considered a "slow-by-slow" method. */
            FOR rec IN c1 LOOP
                    UPDATE set SET changedate = rec.changedate
                    WHERE setnum = rec.setnum;
                    Insert into set_temp select * from set where setnum = rec.setnum;
            END LOOP;
    EXCEPTION
            WHEN NO_DATA_FOUND THEN
                    NULL;
            WHEN OTHERS THEN
                    error_string := 'My_CHANGEDATE - '||SUBSTR(SQLERRM,1,350);
                    DBMS_OUTPUT.PUT_LINE(error_string);
                    RAISE;
    END My_CHANGEDATE;My general recommendations are as follows:
    1. Remove the CREATE TABLE from the procedure altogether.
    2. Don't use reserved words for object names (e.g. SET)
    3. Remove the record by record processing and consolidate it to a single UDPATE statement as follows (note untested):
    UPDATE  set s
    SET     changedate = (
                            SELECT  CHANGEDATE
                            FROM    SET A
                            ,       SETSO_T2 B
                            WHERE   A.SETNUM = B.SETNUM
                            AND     S.SETNUM = A.SETNUM
                            AND     TRUNC(A.CHANGEDATE) < TRUNC(B.CHANGEDATE)
    WHERE EXISTS(
                    SELECT  NULL
                    FROM    SET A
                    WHERE   A.SETNUM = S.SETNUM
                    )HTH!

  • Why procedure created with compilation errors?

    CREATE or REPLACE PROCEDURE AddStudent(
    p_stuID number,
    p_lname varchar2(30),
    p_fname varchar2(20),
    p_major varchar2(5) check(major IN
    ('ACCT','ECT','EET','BIS','BSIT','CIS','TCOM')),
    P_standing varchar2(10) check(standing IN
    ('FRESHMAN','SOPHOMORE','JUNIOR','SENIOR')),
    P_gpa number(3,2) IS
    BEGIN
    INSERT INTO STUDENT (P_STUID, P_LNAME, P_FNAME, P_MAJOR,
    P_STANDING, P_GPA, P_ADVISOR) VALUES
    (STUDENT_SEQ.NEXTVAL, 'SMITH', 'HEATHER', 'CIS', 'JUNIOR', 3.8,
    2);
    INSERT INTO STUDENT (P_STUID, P_LNAME, P_FNAME, P_MAJOR,
    P_STANDING, P_GPA, P_ADVISOR) VALUES
    (STUDENT_SEQ.NEXTVAL, 'ELLIOTT', 'DAVE', 'CIS', 'JUNIOR', 3.65,
    2);
    COMMIT;
    END;
    SQL> /
    Warning: Procedure created with compilation errors.
    any help would be appreciated

    I would guess it's because you can't use CHECK like that (at
    least not in Oracle 8i). If you want to check the validity of
    procedural parameters you'll have to code this sort of thing:
    BEGIN
    IF major NOT IN ('whatever', 'etc') THEN
    RAISE_APPLICATION_ERROR(-22200, 'Invlaid value for MAJOR');
    ELSIF ....
    For future reference you can use the SQL*Plus command SHOW ERR
    to see what went wrong - it gives you line numbers and error
    messages.
    HTH, APC

  • Compilation errors with store procedure

    Hi guys, I just started SQL so forgive me if I ask any real stupid questions. This is the problem I have right now as said in my title.
    This is my procedure.sql
    CREATE OR REPLACE PROCEDURE verify IS
    no_of_duplicates NUMBER:=0;
    BEGIN
    SELECT COUNT(*) INTO no_of_duplicates
    FROM EMPLOYEE
    WHERE E# =
    (sELECT E# FROM DRIVER
    WHERE EXISTS
    (SELECT E# FROM MECHANIC
    WHERE DRIVER.L# = MECHANIC.L#));
    IF no_of_duplicates:=0 THEN dbms_output.put_line('OK');
    ELSE
    SELECT E#,NAME FROM EMPLOYEE
    WHERE E# =
    (SELECT E# FROM DRIVER
    WHERE EXISTS
    (SELECT E# FROM MECHANIC
    WHERE DRIVER.L# = MECHANIC.L#));
    END IF;
    END verify;
    While trying to create the procedure, it gives me the compilation errors. I have been stuck with this for hours and can't seem to find anything wrong with it. Can anyone point me in the right direction? Thanks!

    Hi,
    Once again, post your code.  The error occurs when you call the procedure, but you haven't posted the code that calls the procedure and causes the error.
    When I do this in SQL*Plus:
    SET  SERVEROUTPUT  ON  FORMAT WRAPPED
    EXEC  verify;
    The procedure you posted runs perfectly (that is, is displays the e# only, exactly as it was designed to do).
    One way to display both the e# and the name is to BULK COLLECT both the e# and name into separate collections, like this:
    CREATE OR REPLACE PROCEDURE verify IS 
        TYPE  e#_table  IS TABLE OF employee.e#%TYPE;
        e#_list    e#_table;
        TYPE  name_table  IS TABLE OF employee.name%TYPE;
        name_list  name_table;
    BEGIN 
        SELECT            e#,       name
        BULK COLLECT INTO e#_list,  name_list
        FROM              employee 
        WHERE   e# IN (
                          SELECT  d.e#
                          FROM    driver    d
                          JOIN    mechanic  m  ON  d.e#  = m.e# 
        IF  e#_list.COUNT  = 0
        THEN
            dbms_output.put_line ('OK, there are no illict duplications');
        ELSE     -- that is, e#_list.COUNT <> 0
            dbms_output.put_line ('The following employees are both drivers and mechanics:');
            FOR j IN 1..e#_list.COUNT LOOP    -- i in parentheses sometimes displays wrong on the OTN site
                dbms_output.put      ( TO_CHAR ( e#_list (j)
                                               , '999999999999'
                dbms_output.put      ('   ');
                dbms_output.put_line (name_list (j)); 
            END LOOP; 
        END IF; 
    END verify; 
    SHOW ERRORS
    Here's the output I get when I run the procedure above with your sample data:
    The following employees are both drivers and mechanics:
                1   John Smith
    You'll notice I made several other changes in your code, sometimes because they are clearly better practices, and sometimes just to show you different ways to do the same thing, which you may or may not want to use in this problem.
    For example, you were doing the same query (with only very slight differences) 2 times: once to get no_of_duplicates, and then a second time to get the actual data.  I don't know if that's the most efficient way to do what you need.  Say there are 1000 rows in the result set.  You'll fetch all 1000 once just to get the total number, (which you don't need, if all you care about at this point is if there are any), and then to get the data.  When you do a BULK COLLECT, you automatically get the COUNT anyway, so why not do the BULK COLLECT first, then use that COUNT to see what you have to do next.  If the COUNT is more than 0, then you've already got the data, and you don't need to fetch it again.  Also, repeating (essentially) the same code is a maintenance problem.  If you ever need to make a change, you need to make the same change in multiple places.  At best, that's a pain; but this is the exactly the kind of mistake that is easy to miss in in testing, and you might have code running for weeks in Production before you notice that sometimes it's giving the wrong results.
    Another example: e# is a NUMBER.  While it is possible to convert NUMBERs into VARCHAR2s, and then store those VARCHAR2s in a VARCHAR2 collecction, wouldn't it make more sense just to store them in a NUMBER collection?

  • Procedure compilation failed with SQL command not properly ended error

    Hi All,
    Kindly help me to fix this.
    I am compiling a procedure and getting an error. Procedure and error details are as follows:
    Procedure:
    CREATE or REPLACE PROCEDURE jiostore_new.auditReportCount (u_name IN VARCHAR2,stdate IN DATE,eddate IN DATE)
    IS
    BEGIN
    DECLARE Total Number;
    BEGIN
    SELECT COUNT(am.id) into Total FROM auditMaster_ AS am  INNER JOIN jioworld.deviceos_ dvos ON dvos.id=am.deviceOs WHERE am.updatedBy=u_name or am.updatedBy=ALL AND DATE(am.updatedDate)>=stdate OR DATE(am.updatedDate)='0000-00-00' AND DATE(am.updatedDate)<=eddate or DATE(am.updatedDate)='0000-00-00';
    dbms_output.put_line('Total Count:' || Total);
    END;
    END;
    Error:
    Error(6,1): PL/SQL: SQL Statement ignored
    Error(6,50): PL/SQL: ORA-00933: SQL command not properly ended
    Regards,
    Vishal G

    2922723 wrote:
    Hi All,
    Kindly help me to fix this.
    I am compiling a procedure and getting an error. Procedure and error details are as follows:
    Procedure:
    CREATE or REPLACE PROCEDURE jiostore_new.auditReportCount (u_name IN VARCHAR2,stdate IN DATE,eddate IN DATE)
    IS
    BEGIN
    DECLARE Total Number;
    BEGIN
    SELECT COUNT(am.id) into Total FROM auditMaster_ AS am  INNER JOIN jioworld.deviceos_ dvos ON dvos.id=am.deviceOs WHERE am.updatedBy=u_name or am.updatedBy=ALL AND DATE(am.updatedDate)>=stdate OR DATE(am.updatedDate)='0000-00-00' AND DATE(am.updatedDate)<=eddate or DATE(am.updatedDate)='0000-00-00';
    dbms_output.put_line('Total Count:' || Total);
    END;
    END;
    Error:
    Error(6,1): PL/SQL: SQL Statement ignored
    Error(6,50): PL/SQL: ORA-00933: SQL command not properly ended
    Regards,
    Vishal G
    The first thing, is that for your own sanity you should learn to format your code for readability.  And for the sanity of those from whom you seek help, you should learn to preserve that formatting when you post to a forum:
    CREATE OR REPLACE PROCEDURE jiostore_new.auditReportCount(
        u_name IN VARCHAR2,
        stdate IN DATE,
        eddate IN DATE)
    IS
    BEGIN
      DECLARE
        Total NUMBER;
      BEGIN
        SELECT COUNT(am.id)
        INTO Total
        FROM auditMaster_ AS am
        INNER JOIN jioworld.deviceos_ dvos
        ON dvos.id              =am.deviceOs
        WHERE am.updatedBy      =u_name
        OR am.updatedBy          =ALL
        AND DATE(am.updatedDate)>=stdate
        OR  DATE(am.updatedDate) ='0000-00-00'
        AND DATE(am.updatedDate)<=eddate
        OR  DATE(am.updatedDate) ='0000-00-00';
        dbms_output.put_line('Total Count:' || Total);
      END;
    END;
    What is the data type of am.updateDate?  It appears to be a varchar being passed to a function named DATE to convert it to a DATEfor comparison to your input parameters,  But you also compare it to strings. 
    Where are the variables 'u_name' and 'ALL'?  (and what kind of a name is that for a variable -- 'ALL'?)

  • PL/SQL Procedure Complilation Error

    Can any one advise on the following PL/SQL Compilation errors I am receiving:<br><br>
    LINE/COL ERROR<br>
    -------- -----------------------------------------------------------------<br>
    22/1 PL/SQL: SQL Statement ignored<br>
    24/51 PL/SQL: ORA-00942: table or view does not exist<br>
    32/1 PL/SQL: SQL Statement ignored<br>
    34/30 PL/SQL: ORA-00942: table or view does not exist<br>
    40/1 PL/SQL: SQL Statement ignored<br>
    42/6 PL/SQL: ORA-00942: table or view does not exist<br><br>
    I know the tables exists and if I run the SELECT statements through SQLPLUS (without the INTO statements) they return the values as expected.<br><br>
    Procedure as below:<br><br>
    SQL> CREATE OR REPLACE PROCEDURE BS_TDF_EXTRACT AS<br>
    2 <br>
    3 v_file UTL_FILE.FILE_TYPE;<br>
    4 <br>
    5 EXTRACT_YEAR number;<br>
    6 <br>
    7 --Indicator 23 autogeneration<br>
    8 Q1_VALUE_23 number;<br>
    9 Q1_VALUE_23_PASSED_TOTAL number;<br>
    10 Q1_VALUE_23_FAILED_TOTAL number;<br>
    11 Q1_VALUE_23_TOTAL_JOBS number;<br>
    12 <br>
    13 <br>
    14 BEGIN<br>
    15 <br>
    16 --Initialise current Extract Year<br>
    17 SELECT EXTRACT(YEAR FROM SYSDATE) <br>
    18 INTO EXTRACT_YEAR<br>
    19 FROM DUAL;<br>
    20 <br>
    21 --Initialise PASSED TOTAL<br>
    22 SELECT COUNT(*) <br>
    23 INTO Q1_VALUE_23_PASSED_TOTAL<br>
    24 FROM REP_POSTINSP_OUT_GU A1, REP_JOB_INVOICED A2, REP_JOB_INDICATORS A3<br>
    25 WHERE UPPER(A1.POSTINSP_SUCC_IND) = 'P' <br>
    26 AND A1.JOB_NUMBER = A2.JOB_NUMBER<br>
    27 AND A2.JOB_NUMBER = A3.JOB_NUMBER<br>
    28 AND A2.COMPLETION_DATE BETWEEN TO_DATE('01-APR-2006') AND TO_DATE('30-JUN-2006') <br>
    29 AND A3.POST_INSPECTION_NOT_DONE IS NULL;<br>
    30 <br>
    31 --Initialise FAILED TOTAL<br>
    32 SELECT COUNT(*) <br>
    33 INTO Q1_VALUE_23_FAILED_TOTAL<br>
    34 FROM REP_POSTINSP_OUT_GU A1, REP_JOB_INVOICED A2<br>
    35 WHERE UPPER(A1.POSTINSP_SUCC_IND) = 'F' <br>
    36 AND A1.JOB_NUMBER = A2.JOB_NUMBER <br>
    37 AND A2.COMPLETION_DATE BETWEEN TO_DATE('01-APR-2006') AND TO_DATE('30-JUN-2006');<br>
    38 <br>
    39 --Initialise TOTAL JOBS<br>
    40 SELECT COUNT(DISTINCT JOB_NUMBER)<br>
    41 INTO Q1_VALUE_23_TOTAL_JOBS<br>
    42 FROM REP_JOB_INVOICED;<br>
    43 <br>
    44 --Initialise Indicator Value<br>
    45 Q1_VALUE_23:= (Q1_VALUE_23_PASSED_TOTAL + Q1_VALUE_23_FAILED_TOTAL)/Q1_VALUE_23_TOTAL_JOBS;<br>
    46 <br>
    47 v_file := UTL_FILE.FOPEN(location => '/tmp',<br>
    48 filename => 'bs_imported_values.txt',<br>
    49 open_mode => 'W',<br>
    50 max_linesize => 32767);<br>
    51 <br>
    52 UTL_FILE.PUT_LINE(v_file, 'Q1' || EXTRACT_YEAR || '23' || Q1_VALUE_23 || '\r\n');<br>
    53 <br>
    54 UTL_FILE.FCLOSE(v_file);<br>
    55 <br>
    56 END BS_TDF_EXTRACT;<br>
    57 /<br><br>
    Warning: Procedure created with compilation errors.<br><br>
    SQL> show errors;<br>
    Errors for PROCEDURE BS_TDF_EXTRACT:<br><br>
    LINE/COL ERROR<br>
    <br>22/1 PL/SQL: SQL Statement ignored<br>
    24/51 PL/SQL: ORA-00942: table or view does not exist<br>
    32/1 PL/SQL: SQL Statement ignored<br>
    34/30 PL/SQL: ORA-00942: table or view does not exist<br>
    40/1 PL/SQL: SQL Statement ignored<br>
    42/6 PL/SQL: ORA-00942: table or view does not exist<br>

    go to sql prompt and look for desc of these and if they are not available get permissions,DB link what ever may be required to access it can be the only possibility REP_POSTINSP_OUT_GU A1, REP_JOB_INVOICED A2, REP_JOB_INDICATORS A3

  • Compilation error while generating the form in linux

    Hello everyone,
    I am using Oracle Designer ver10.1.2.4 in windows to generate the forms with standard object library ofgwebol.olb and template form ofgwebt.fmb. form (with both .fmb and .fmx files) are generated without errors. Also when I open the forms in separately they compiles without errors. But when I copy the same .fmb file into linux enviroment and compile it using frmcmp.sh userid=user/password@database module_type=form compile_all=yes module=form_name it gives following errors.
    $> frmcmp.sh userid=odin/odin@ontw10g module_ty
    pe=form compile_all=yes module=LOGIN_SCHERM
    Forms 10.1 (Form Compiler) Version 10.1.2.0.2 (Production)
    Forms 10.1 (Form Compiler): Release - Production
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    PL/SQL Version 10.1.0.4.2 (Production)
    Oracle Procedure Builder V10.1.2.0.2 - Production
    Oracle Virtual Graphics System Version 10.1.2.0.0 (Production)
    Oracle Multimedia Version 10.1.2.0.2 (Production)
    Oracle Tools Integration Version 10.1.2.0.2 (Production)
    Oracle Tools Common Area Version 10.1.2.0.2
    Oracle CORE 10.1.0.4.0 Production
    FRM-18108: Failed to load the following objects.
    Source Module:ofgwebol.olb
    Source Object: CGSO$CHAR_DO
    Source Module:ofgwebol.olb
    Source Object: CGSO$CHAR_DO
    Source Module:ofgwebol.olb
    Source Object: CGSO$BLOCK
    Source Module:ofgwebol.olb
    Source Object: CGSO$CANVAS
    Source Module:ofgwebol.olb
    Source Object: CGSO$WINDOW
    Compiling function CGTE$CHECK_CONSTRAINT_VIO...
    No compilation errors.
    Compiling procedure CGTE$INLOGGEN_ERRORS...
    No compilation errors.
    L/SQL ERROR 0 at line 17, column 3
    Statement ignored
    PL/SQL ERROR 201 at line 36, column 3
    identifier 'CGNV$.NAV_CLOSE_FORMS' must be declared
    PL/SQL ERROR 0 at line 36, column 3
    Statement ignored
    PL/SQL ERROR 201 at line 37, column 3
    identifier 'CGNV$.NAV_OPENING_WND' must be declared
    PL/SQL ERROR 0 at line 37, column 3
    Statement ignored
    Compiling KEY-HELP trigger on form...
    No compilation errors.
    Compiling WHEN-WINDOW-ACTIVATED trigger on form...
    Compilation error on WHEN-WINDOW-ACTIVATED trigger on form:
    PL/SQL ERROR 201 at line 6, column 8
    identifier 'CGNV$GET_ITEM_WINDOW' must be declared
    PL/SQL ERROR 0 at line 4, column 3
    Statement ignored
    Compiling POST-TEXT-ITEM trigger on form...
    Compilation error on POST-TEXT-ITEM trigger on form:
    PL/SQL ERROR 201 at line 4, column 3
    identifier 'CGNV$.STORE_WND_ITEM' must be declared
    PL/SQL ERROR 0 at line 4, column 3
    Statement ignored
    Compiling WHEN-WINDOW-CLOSED trigger on form...
    Compilation error on WHEN-WINDOW-CLOSED trigger on form:
    PL/SQL ERROR 201 at line 5, column 3
    identifier 'CGNV$.TERMINATE_WINDOW' must be declared
    PL/SQL ERROR 0 at line 5, column 3
    Statement ignored
    Compiling WHEN-FORM-NAVIGATE trigger on form...
    Compilation error on WHEN-FORM-NAVIGATE trigger on form:
    PL/SQL ERROR 201 at line 3, column 3
    identifier 'CGNV$.REMOVE_CHILD_FORM' must be declared
    PL/SQL ERROR 0 at line 3, column 3
    Statement ignored
    Compiling KEY-EXIT trigger on form...
    Compilation error on KEY-EXIT trigger on form:
    PL/SQL ERROR 201 at line 5, column 3
    identifier 'CGNV$.NAV_ENTER_QUERY' must be declared
    PL/SQL ERROR 0 at line 5, column 3
    Statement ignored
    PL/SQL ERROR 201 at line 9, column 5
    identifier 'CGNV$.CLOSE_ALL_WINDOWS' must be declared
    PL/SQL ERROR 0 at line 9, column 5
    Statement ignored
    Compiling KEY-CLRFRM trigger on form...
    No compilation errors.
    Compiling ON-ERROR trigger on INLOGGEN data block...
    No compilation errors.
    Compiling KEY-PREV-ITEM trigger on AGB_ID item in INLOGGEN data block...
    Compilation error on KEY-PREV-ITEM trigger on AGB_ID item in INLOGGEN data block
    PL/SQL ERROR 201 at line 4, column 3
    identifier 'CGNV$GO_PREV_ITEM' must be declared
    PL/SQL ERROR 0 at line 4, column 3
    Statement ignored
    Compiling KEY-NEXT-ITEM trigger on AGB_NAAM item in INLOGGEN data block...
    Compilation error on KEY-NEXT-ITEM trigger on AGB_NAAM item in INLOGGEN data blo
    ck:
    PL/SQL ERROR 201 at line 4, column 3
    identifier 'CGNV$GO_NEXT_ITEM' must be declared
    PL/SQL ERROR 0 at line 4, column 3
    Statement ignored
    Compilation errors have occurred.
    Form not created
    I think some standard library are missing in Linux environment. But I do not know the name of them and neither I can find. Please suggest the what need to be done to resolve the problem. The reason I am compiling the form in Linux is that I can run the form in windows because of corrupted installation of OC4j.
    Thanking you all much in advance.
    Edited by: Deepank on Dec 2, 2008 1:49 AM

    Deepank-
    When generating forms from Designer, Designer attaches libraries - like ofgmes.pll, ofgnavl.pll, etc. You will need to copy these libraries to the same directory where your forms reside on your Linux box. To find out what libraries ate attached to your form, open it on your windows PC after generating it from Designer and you will see the attached libraries. Also, watch out for the case-sensitivity of Linux. If you have the Designer libraries on your linux box and you still get errors, try changing the case of the names of the libraries.
    Hope this helps,
    Dan

Maybe you are looking for

  • ITunes updated to 7.3.1 and now won't open

    I started iTunes and it automatically updated. Now I get a message that OSX 10.4.7 is required to use iTunes. This computer will only go to 10.4.3. I tried downloading the system updaters, but they will not install because the 1GHz processor isn't en

  • Idoc in trfc queue

    Hi, I have requirement where the idocs are sent to external (non sap) system, now when system is down or for some other reason the idocs gets queued up in trfc queue(SM58) , now when the system is up and running these idoc gets passed to the external

  • My Office Print Pro 8600 Plus will not print pdf files sent to it from an iPad using ePrint.

    My Office Print Pro 8600 Plus will not print pdf files sent to it from an iPad using ePrint.  I just get an error message when I go to the  HP Eprint centre.  It does print the cover e-mail but nothing else.  The attachment is not secure as far as I

  • System Update v3.14 error: "an error occurred while downloadin​g packages"

    I installed the new version of System Update v3.14 from the Leonvo web site on my ThinkCentre A30 (8199-B2U) running Windows XP SP2, however I get the error message "an error occurred while downloading packages" when the percentage hits 15% or 17%. I

  • What is Temp File etilqs xKTXRBvWnu6?

    Every time I open my Firefox browser Win Patrol reports a hidden file. I'm using XP Pro with SP2 and they are always in C:\Documents and Settings\Owner\Local Settings\Temp. These files always have etilqs as the prefix with the last group of numbers a