Compilation error in procedure

P_start_date and p_end_date is input to the procedure
it is giving execution error.
v_sql := 'SELECT
     as_no ,
     l_no ,
     dtc_no ,
     reg_date ,
     card_no ,
     last_name ,
     no_mail ,
     no_call      
FROM registration@' ||p_db_link || ' a
WHERE a.first_name IS NOT NULL
AND a.datestamp = (SELECT max(b.datestamp) FROM registration@' ||p_db_link || ' b
WHERE a.card_no = b.card_no)
AND TO_DATE(a.reg_date,''dd-mon-yy'') BETWEEN ' || p_start_date || ' AND ' || p_end_date ;
========= Here is the sql while executing...
SELECT
as_no ,
l_no ,
dtc_no
reg_date ,
card_no ,
last_name
first_name ,
zip_code ,
start_weight
goal_weight ,
mbrship_status ,
weeks_completed ,
height
previous_wt ,
previous_date ,
datestamp ,
notes
modified_date ,
old_style_reg_no ,
lifetime_no
miss_you_sent ,
miss_you_datestamp ,
address ,
city
state ,
phone ,
phone_type ,
email
memo ,
sex ,
birth_date
age_range ,
no_mail ,
no_call
FROM
registration@link_champ a
WHERE a.first_name IS NOT NULL
AND a.datestamp =
(SELECT max(b.datestamp) FROM registration@link_champ b
WHERE a.card_no = b.card_no)
AND TO_DATE(a.reg_date,'dd-mon-yy') BETWEEN
10-MAR-06 AND 11-MAR-06
ErrorORA-00904: "MAR": invalid identifier
ORA-Error in fetching the cursor values
PL/SQL procedure successfully completed.

they are date type
I modifed the query and it is working fine now, but it is still taking lots of time...
Here is what i changed the procedure....
I have used the bulk collect here, but still there is no big performance improvement..
CREATE OR REPLACE PACKAGE BODY pkg_merge_member_info IS
PROCEDURE p_merge_member_info(p_db_link in VARCHAR2, p_start_date in date, p_end_date in date) IS
generic_cv sys_refcursor;
generic_cv2 sys_refcursor;
generic_cv3 sys_refcursor;
v_rcw_card_no varchar2(20);
v_pmi_inactive_date date;
v_pmi_inactive_reason varchar2(50);
v_ccw_last_meeting date;
type     tbl_as_no           is table of      NUMBER(8)     INDEX BY BINARY_INTEGER;
type     tbl_l_no           is table of      NUMBER(8)     INDEX BY BINARY_INTEGER;
type     tbl_dtc_no           is table of      NUMBER(8)     INDEX BY BINARY_INTEGER;
type     tbl_reg_date           is table of      DATE     INDEX BY BINARY_INTEGER;
type     tbl_card_no           is table of      VARCHAR2(20)     INDEX BY BINARY_INTEGER;
type     tbl_last_name           is table of      VARCHAR2(32)     INDEX BY BINARY_INTEGER;
type     tbl_first_name           is table of      VARCHAR2(32)     INDEX BY BINARY_INTEGER;
type     tbl_zip_code           is table of      CHAR(5)     INDEX BY BINARY_INTEGER;
type     tbl_start_weight           is table of      NUMBER(8,2)     INDEX BY BINARY_INTEGER;
type     tbl_goal_weight           is table of      NUMBER(8,2)     INDEX BY BINARY_INTEGER;
type     tbl_mbrship_status           is table of      VARCHAR2(32)     INDEX BY BINARY_INTEGER;
type     tbl_weeks_completed           is table of      NUMBER(8)     INDEX BY BINARY_INTEGER;
type     tbl_height           is table of      NUMBER(8,2)     INDEX BY BINARY_INTEGER;
type     tbl_previous_wt           is table of      NUMBER(8,2)     INDEX BY BINARY_INTEGER;
type     tbl_previous_date           is table of      DATE     INDEX BY BINARY_INTEGER;
type     tbl_datestamp           is table of      DATE     INDEX BY BINARY_INTEGER;
type     tbl_notes           is table of      VARCHAR2(128)     INDEX BY BINARY_INTEGER;
type     tbl_modified_date           is table of      DATE     INDEX BY BINARY_INTEGER;
type     tbl_old_style_reg_no           is table of      VARCHAR2(32)     INDEX BY BINARY_INTEGER;
type     tbl_lifetime_no           is table of      VARCHAR2(32)     INDEX BY BINARY_INTEGER;
type     tbl_miss_you_sent           is table of      CHAR(1)     INDEX BY BINARY_INTEGER;
type     tbl_miss_you_datestamp           is table of      DATE     INDEX BY BINARY_INTEGER;
type     tbl_address           is table of      VARCHAR2(64)     INDEX BY BINARY_INTEGER;
type     tbl_city           is table of      VARCHAR2(32)     INDEX BY BINARY_INTEGER;
type     tbl_state           is table of      CHAR(2)     INDEX BY BINARY_INTEGER;
type     tbl_phone           is table of      VARCHAR2(16)     INDEX BY BINARY_INTEGER;
type     tbl_phone_type           is table of      VARCHAR2(4)     INDEX BY BINARY_INTEGER;
type     tbl_email           is table of      VARCHAR2(64)     INDEX BY BINARY_INTEGER;
type     tbl_memo           is table of      VARCHAR2(192)     INDEX BY BINARY_INTEGER;
type     tbl_sex           is table of      CHAR(1)     INDEX BY BINARY_INTEGER;
type     tbl_birth_date           is table of      DATE     INDEX BY BINARY_INTEGER;
type     tbl_age_range           is table of      VARCHAR2(8)     INDEX BY BINARY_INTEGER;
type     tbl_no_mail           is table of      CHAR(1)     INDEX BY BINARY_INTEGER;
type     tbl_no_call           is table of      CHAR(1)      INDEX BY BINARY_INTEGER;
v_AS_NO tbl_as_no      ;
v_L_NO tbl_l_no      ;
v_DTC_NO tbl_dtc_no      ;
v_REG_DATE tbl_reg_date      ;
v_CARD_NO tbl_card_no      ;
v_LAST_NAME tbl_last_name      ;
v_FIRST_NAME tbl_first_name      ;
v_ZIP_CODE tbl_zip_code ;      
v_START_WEIGHT tbl_start_weight ;      
v_GOAL_WEIGHT tbl_goal_weight ;     
v_MBRSHIP_STATUS tbl_mbrship_status ;     
v_WEEKS_COMPLETED tbl_weeks_completed ;     
v_HEIGHT tbl_height ;     
v_PREVIOUS_WT tbl_previous_wt ;     
v_PREVIOUS_DATE tbl_previous_date ;     
v_DATESTAMP tbl_datestamp ;     
v_NOTES tbl_notes ;     
v_MODIFIED_DATE tbl_modified_date ;     
v_OLD_STYLE_REG_NO tbl_old_style_reg_no ;     
v_LIFETIME_NO tbl_lifetime_no ;     
v_MISS_YOU_SENT tbl_miss_you_sent ;     
v_MISS_YOU_DATESTAMP tbl_miss_you_datestamp ;     
v_ADDRESS tbl_address ;     
v_CITY tbl_city ;     
v_STATE tbl_state ;     
v_PHONE tbl_phone ;     
v_PHONE_TYPE tbl_phone_type ;     
v_EMAIL tbl_email ;     
v_MEMO tbl_memo ;     
v_SEX tbl_sex ;     
v_BIRTH_DATE tbl_birth_date ;     
v_AGE_RANGE tbl_age_range ;     
v_NO_MAIL tbl_no_mail ;     
v_NO_CALL tbl_no_call ;     
o_error_Text VARCHAR2(1000);
v_sql_err VARCHAR2(4000);
tname VARCHAR2(32);
o_status VARCHAR2(10);
--v_schema_name                              VARCHAR2(100):=p_schema_name||'.';
v_last_upd_by VARCHAR2(20) :='Apollo Data Refresh';
v_created_by VARCHAR2(20) :='Apollo Data Refresh';
v_user_check_id NUMBER(10);
v_hire_date DATE;
v_fjc_no VARCHAR2(1);
v_sql VARCHAR2(4000);
v_emp_check NUMBER(1) := 0;
v_user_id NUMBER(10);
v_state_id NUMBER(10);
v_ejc_date_last_worked      DATE;
v_member_id NUMBER(10);
v_MEMBER_TYPE_ID NUMBER(10);
BEGIN
v_sql := 'SELECT
     as_no ,
     l_no ,
     dtc_no ,
     reg_date ,
     card_no ,
     last_name ,
     first_name ,
     zip_code ,
     start_weight ,
     goal_weight ,
     mbrship_status ,
     weeks_completed ,
     height ,
     previous_wt ,
     previous_date ,
     datestamp ,
     notes ,
     modified_date ,
     old_style_reg_no ,
     lifetime_no ,
     miss_you_sent ,
     miss_you_datestamp ,
     address ,
     city ,
     state ,
     phone ,
     phone_type ,
     email ,
     memo ,
     sex ,
     birth_date ,
     age_range ,
     no_mail ,
     no_call      
FROM registration@' ||p_db_link || ' a
WHERE a.first_name IS NOT NULL
AND a.datestamp = (SELECT max(b.datestamp) FROM registration@' ||p_db_link || ' b
WHERE a.card_no = b.card_no)
AND TO_DATE(a.reg_date,''dd-mon-yy'') BETWEEN ''' || p_start_date || ''' and ''' || p_end_date ||'''' ;
--AND  TO_DATE(a.reg_date,''dd-mon-yy'') BETWEEN   p_start_date and p_end_date  ' ;
--USING  p_start_date, p_end_date    ;
o_Error_Text := 'ORA-Error in fetching the cursor values ';
tname:= NULL;
dbms_output.put_line(v_sql);
execute immediate v_sql bulk collect into
     v_as_no ,
     v_l_no ,
     v_dtc_no ,
     v_reg_date ,
     v_card_no ,
     v_last_name ,      
     v_first_name ,
     v_zip_code ,
     v_start_weight ,
     v_goal_weight ,
     v_mbrship_status ,
     v_weeks_completed ,
     v_height ,
     v_previous_wt ,
     v_previous_date ,
     v_datestamp ,
     v_notes ,
     v_modified_date ,
     v_old_style_reg_no ,
     v_lifetime_no ,
     v_miss_you_sent ,
     v_miss_you_datestamp ,
     v_address ,
     v_city ,
     v_state ,
     v_phone ,
     v_phone_type ,
     v_email ,
     v_memo ,
     v_sex ,
     v_birth_date ,
     v_age_range ,
     v_no_mail ,
     v_no_call ;
FOR i IN v_card_no.FIRST..v_card_no.LAST
LOOP
o_Error_Text := 'ORA-Error in getting member id for the card no';
tname:= 'members';
     SELECT count(1) INTO v_emp_check
     FROM members
     WHERE champ_code=v_CARD_NO(i);
IF v_emp_check = 0 THEN
o_Error_Text := 'ORA-Error in executing sequence seq_user_id';
tname:= NULL;
SELECT user_id_seq.nextval INTO v_user_id FROM dual;
o_Error_Text := 'ORA-Error in INSERTing to users table';
tname:= 'Users';
     INSERT INTO users
     ( user_id ,
          user_type_id ,
          first_name ,
          last_name ,
          mid_name ,
          gender ,
          date_of_birth ,
          notes ,
          site_id ,
          created_date ,
          created_by ,
          last_upd_date ,
          last_upd_by
     VALUES
     ( v_user_id ,
          2 , -- Member type
          v_first_name(i),
          v_last_name(i) ,
          null , -- mid name
          v_sex(i) , -- gender
          v_birth_date(i) ,
          v_notes(i) ,
          1 , -- site id
          pkg_utilities.fn_sysdate(1) , -- Created Dt
          v_created_by , -- Created by
          pkg_utilities.fn_sysdate(1) , -- Modified Dt
          v_last_upd_by -- Modified by
end if;
dbms_output.put_line(i);
end loop;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error' ||sqlerrm);
DBMS_OUTPUT.PUT_LINE(o_error_text);
v_sql_err :=SQLERRM;
ROLLBACK;
pkg_champ_message_log.champ_message_log ('pkg_merge_employee_info.p_merge_employee_info', tname, null,'Apollo', v_sql_err,'Error',o_Error_Text,O_STATUS);
end;
END PKG_MERGE_member_INFO;
/

Similar Messages

  • Newbie Trouble Figuring Out Compile Error in Procedure

    I'm inexperienced at PL/SQL programming and I've been reading through the 10gR2 PL/SQL user's guide trying to figure out what's wrong with my procedure but I'm not having any luck. I would appreciate your help.
    I wanted a procedure that I could use on small tables (which are not partitioned by date) that I could use to delete rows older than days_old days old. I wanted it to be generic so I didn't want to have to hard code the table name (table_name), table's primary key (primary_key) or the name of the column in table_name that I wanted to match dates against. Here's what I came up with:
    CREATE OR REPLACE PROCEDURE delete_old_rows (table_name VARCHAR2, primary_key VARCHAR2, date_col_name VARCHAR2, days_old NUMBER) AS
    v_sql VARCHAR2(256);
    CURSOR rows_to_delete IS
    SELECT primary_key FROM table_name WHERE date_col_name < trunc(SYSDATE) - days_old;
    BEGIN
    FOR del_rows in rows_to_delete
    LOOP
    SELECT 'DELETE FROM table_name WHERE date_col_name = del_rows.date_col_name' INTO v_sql FROM dual;
    DBMS_OUTPUT.PUT_LINE(v_sql);
    -- EXECUTE IMMEDIATE v_sql;
    END LOOP;
    END;
    SHOW ERRORS;
    The compiler seems to be okay with my use of primary_key, date_col_name, and days_old as variables but when I start using the table_name variable I get a "SQL Statement Ignored" error on the SELECT in the CURSOR and a "table or view does not exist" error on the same statement.
    So, it compiles okay without using the table_name variable but it does no compile okay when I start using it.
    And yes, I know the EXECUTE IMMEDIATE is commented out -- I'm still developing it.
    Thank you

    Currently your cursor is referring to a table called "table_name" with a column called "date_col_name". To build a dynamic cursor using the table_name etc parameter values you are going to need dynamic sql, e.g:
    OPEN c_rows_to_delete FOR
        'SELECT primary_key FROM ' || table_name || ' WHERE ' || date_col_name || ' < trunc(SYSDATE)';where c_rows_to_delete is declared as a SYS_REFCURSOR. You can't use a Cursor FOR loop on ref cursors.
    Also PL/SQL has a handy assignment operator ":=" so you don't need to SELECT INTO FROM DUAL.
    Generally dynamic code is something to be used as a last resort.

  • Webutil form compilation error

    Hi all
    I configured webutil on Application server 10g on linux. but when i compile the demo form on application server using
    /u01/app/oracle/OraHome_2/bin/frmcmp.sh module=$ORACLE_HOME/forms/WU_TEST_106.fmb userid=webutil/webutil@orant module_type=form compile_all=yes OUTPUT_FILE=$ORACLE_HOME/forms/WU_TEST_106.fmx
    it give me the errors
    FRM-18108: Failed to load the following objects.
    Source Module:webutil.olb
    Source Object: WEBUTIL
    Compiling procedure GET_CLIENTINFO...
    Compilation error on procedure GET_CLIENTINFO:
    PL/SQL ERROR 201 at line 3, column 35
    identifier 'WEBUTIL_CLIENTINFO.GET_USER_NAME' must be declared
    PL/SQL ERROR 0 at line 3, column 3
    Statement ignored
    PL/SQL ERROR 201 at line 4, column 35
    identifier 'WEBUTIL_CLIENTINFO.GET_IP_ADDRESS' must be declared
    PL/SQL ERROR 0 at line 4, column 3
    Statement ignored
    Compilation errors have occurred.
    Form not created
    ==========================================
    i search a lot but failed ..
    any solution regarding this plz thanks in advance.

    [oracle@appserver ~]$ /u01/app/oracle/OraHome_2/bin/frmcmp_batch.sh module=$ORACLE_HOME/forms/webutil.pll userid=webutil/webutil@orant module_type=library compile_all=yes OUTPUT_FILE=$ORACLE_HOME/forms/webutil.plx
    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 11g Enterprise Edition Release 11.1.0.6.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing 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
    Compiling library WEBUTIL...
    Invalidating Package Spec CLIENT_IMAGE......
    Invalidating Package Spec CLIENT_OLE2......
    Invalidating Package Spec CLIENT_TEXT_IO......
    Invalidating Package Spec CLIENT_TOOL_ENV......
    Invalidating Package Spec CLIENT_WIN_API_DEBUG......
    Invalidating Package Spec CLIENT_WIN_API......
    Invalidating Package Spec CLIENT_WIN_API_ENVIRONMENT......
    Invalidating Package Spec CLIENT_WIN_API_PRELOAD......
    Invalidating Package Spec JAVA_EXCEPTION......
    Invalidating Package Spec WEBUTIL_BROWSER......
    Invalidating Package Spec WEBUTIL_CLIENTINFO......
    Invalidating Package Spec WEBUTIL_C_API......
    Invalidating Package Spec JAVA_SYSTEM......
    Invalidating Package Spec JAVA_APPSERV_READER......
    Invalidating Package Spec DELIMSTR......
    Invalidating Package Spec WEBUTIL_FILE......
    Invalidating Package Spec JAVA_APPSERV_WRITER......
    Invalidating Package Spec WEBUTIL_DB_LOCAL......
    Invalidating Package Spec JAVA_FILE......
    Invalidating Package Spec WEBUTIL_FILE_TRANSFER......
    Invalidating Package Spec WEBUTIL_HOST......
    Invalidating Package Spec WEBUTIL_SEPARATEFRAME......
    Invalidating Package Spec WEBUTIL_CORE......
    Invalidating Package Spec WEBUTIL_SESSION......
    Invalidating Package Spec WEBUTIL_UTIL......
    Invalidating Package Body WEBUTIL_UTIL......
    Invalidating Package Body WEBUTIL_SESSION......
    Invalidating Package Body WEBUTIL_SEPARATEFRAME......
    Invalidating Package Body WEBUTIL_HOST......
    Invalidating Package Body WEBUTIL_FILE_TRANSFER......
    Invalidating Package Body WEBUTIL_FILE......
    Invalidating Package Body WEBUTIL_DB_LOCAL......
    Invalidating Package Body WEBUTIL_C_API......
    Invalidating Package Body WEBUTIL_CORE......
    Invalidating Package Body WEBUTIL_CLIENTINFO......
    Invalidating Package Body WEBUTIL_BROWSER......
    Invalidating Procedure Body SHOW_WEBUTIL_INFORMATION......
    Invalidating Package Body JAVA_SYSTEM......
    Invalidating Package Body JAVA_FILE......
    Invalidating Package Body JAVA_EXCEPTION......
    Invalidating Package Body JAVA_APPSERV_WRITER......
    Invalidating Package Body JAVA_APPSERV_READER......
    Invalidating Package Body DELIMSTR......
    Invalidating Package Body CLIENT_WIN_API_PRELOAD......
    Invalidating Package Body CLIENT_WIN_API_ENVIRONMENT......
    Invalidating Package Body CLIENT_WIN_API_DEBUG......
    Invalidating Package Body CLIENT_WIN_API......
    Invalidating Package Body CLIENT_TOOL_ENV......
    Invalidating Package Body CLIENT_TEXT_IO......
    Invalidating Package Body CLIENT_OLE2......
    Invalidating Package Body CLIENT_IMAGE......
    Invalidating Procedure Body CLIENT_HOST......
    Invalidating Function Body CLIENT_GET_FILE_NAME......
    Compiling Package Spec CLIENT_IMAGE......
    Compiling Package Spec CLIENT_OLE2......
    Compiling Package Spec CLIENT_TEXT_IO......
    Compiling Package Spec CLIENT_TOOL_ENV......
    Compiling Package Spec CLIENT_WIN_API_DEBUG......
    Compiling Package Spec CLIENT_WIN_API......
    Compiling Package Spec CLIENT_WIN_API_ENVIRONMENT......
    Compiling Package Spec CLIENT_WIN_API_PRELOAD......
    Compiling Package Spec JAVA_EXCEPTION......
    Compiling Package Spec WEBUTIL_BROWSER......
    Compiling Package Spec WEBUTIL_CLIENTINFO......
    Compiling Package Spec JAVA_SYSTEM......
    Compiling Package Spec JAVA_APPSERV_READER......
    Compiling Package Spec DELIMSTR......
    Compiling Package Spec WEBUTIL_FILE......
    Compiling Package Spec JAVA_APPSERV_WRITER......
    Compiling Package Spec WEBUTIL_DB_LOCAL......
    Compiling Package Spec JAVA_FILE......
    Compiling Package Spec WEBUTIL_FILE_TRANSFER......
    Compiling Package Spec WEBUTIL_HOST......
    Compiling Package Spec WEBUTIL_SEPARATEFRAME......
    Compiling Package Spec WEBUTIL_CORE......
    Compiling Package Spec WEBUTIL_SESSION......
    Compiling Package Spec WEBUTIL_UTIL......
    Compiling Package Body WEBUTIL_UTIL......
    Compiling Package Body WEBUTIL_SESSION......
    Compiling Package Body WEBUTIL_SEPARATEFRAME......
    Compiling Package Body WEBUTIL_HOST......
    Compiling Package Body WEBUTIL_FILE_TRANSFER......
    Compiling Package Body WEBUTIL_FILE......
    Compiling Package Body WEBUTIL_DB_LOCAL......
    Compiling Package Body WEBUTIL_C_API......
    Compiling Package Body WEBUTIL_CORE......
    Compiling Package Body WEBUTIL_CLIENTINFO......
    Compiling Package Body WEBUTIL_BROWSER......
    Compiling Procedure Body SHOW_WEBUTIL_INFORMATION......
    Compiling Package Body JAVA_SYSTEM......
    Compiling Package Body JAVA_FILE......
    Compiling Package Body JAVA_EXCEPTION......
    Compiling Package Body JAVA_APPSERV_WRITER......
    Compiling Package Body JAVA_APPSERV_READER......
    Compiling Package Body DELIMSTR......
    Compiling Package Body CLIENT_WIN_API_PRELOAD......
    Compiling Package Body CLIENT_WIN_API_ENVIRONMENT......
    Compiling Package Body CLIENT_WIN_API_DEBUG......
    Compiling Package Body CLIENT_WIN_API......
    Compiling Package Body CLIENT_TOOL_ENV......
    Compiling Package Body CLIENT_TEXT_IO......
    Compiling Package Body CLIENT_OLE2......
    Compiling Package Body CLIENT_IMAGE......
    Compiling Procedure Body CLIENT_HOST......
    Compiling Function Body CLIENT_GET_FILE_NAME......
    Done.
    [oracle@appserver ~]$
    here is the code how i compile webutil.. its done sucessfully.

  • Urgent: Form Compilation Error using frmcmp.sh on OAS 10.1.2, pls help..

    Hi All,
    I am upgrading from OAS 9.0.4 to 10.1.2 where Forms 10g application is deployed.
    When I try to recompile with frmcmp.sh :
    frmcmp.sh userid=system/oracle123@odb module_type=FORM module=menu1.fmb
    I get errors :
    Compiling Procedure GET_PATH...
    Compilation error on procedure GET_PATH:
    PL/SQL ERROR 201 at line 4, column 32
    Identifier 'APPS_MENU1_DET' must be declared
    PL/SQL ERROR 0 at line 4, column 3
    SQL Statement ignored
    Compilation error have occured.
    Form not created
    What cause this error ?
    FYI, on the above compilation I connect to different database/schema, not the one
    which is used by the Form, is this the reason of th error ?
    During compilation, Do I have to connect to the database/schema I used when develop the form ?
    DO I have to create all tables in the schema first before compilation ?
    Tnank you for your hwlp,
    xtanto
    PS. When I compile the same Form with F90genm.sh on OAS 9.0.4, NO ERROR.

    From my experience it's a really bad idea to install OCS into a AS IM. When it comes to upgrades and patches you'll pull your hair out!
    Why not install OCS first and then install the BI into the OCS AS server... I have not checked the certification matrix but that might be a better solution to look into.

  • Wierd SQL Select Compile Error

    Hello.
    When I do my SQL like this:
    SQL SELECT cus_surname as "Surname",
    cus_forename as
    "FirstName",
    cus_telephone as
    "Telephone",
    cus_address as
    "Address1",
    cus_line1 as
    "Address2",
    cus_line2 as
    "Address3",
    cus_town as
    "Address4",
    cus_city as
    "Address5",
    cus_postcode as
    "Address6"
    INTO :lCustomer
    FROM msp_customers
    WHERE cus_serial = :lRefCustomer.Serial
    on session SessionToUse;
    I get this compile error:
    The read-only virtual attribute
    FoundationClasses.FoundationBusinessObject.IsNew can't be passed as an
    OUTPUT or an INPUT OUTPUT parameter.
    Yet if I remove the "as" from the SQL Select syntax it works, with no
    compile errors.
    Why? I don't understand why they are different!
    Tim Sawyer
    PanCredit
    Leeds, UK.
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    I added a DBMS_OUTPUT.put_line(l_wrap) in keith codes
    and run out put wrapped test codes in sqlplus and can see wrapped test procedure.
    create or replace procedure test wrapped
    a000000
    b2
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    abcd
    7
    11d 124
    ohyVALi7ang26ROCF0CZ3wLg6ngwgy7Q2SdqfC/p+D6E39xrRLEK0/eVVEVSORSTWoZXk1gi
    JT9nTrV3IXmGVbi5uMlIl+0C/WV9wPlFL5z37QfcEOYUdmLx8iwul2hEvDehUX0jLfiltHqx
    MhAgy16zDvWPfv5uE4HrlBvRAYoDmETXR7r10x/uyQyUxDw4sVyq6Ndh4GSFw9zp801nKSN1
    P0GOB03CtlcnrqAjQhASJKrP4sXW74oOyr373DBBP/CLndRTT0TZ1HvWVzAgL5C++Dl6PNyQ
    But I got compiled errors as
    Compilation errors for PROCEDURE SYS.TEST
    Error: PLS-00103: Encountered the symbol "ASWALLET_OPEN" when expecting one of the following:
    ( ; is with authid as cluster compress order using compiled
    wrapped external deterministic parallel_enable pipelined
    result_cache
    The symbol "is" was substituted for "ASWALLET_OPEN" to continue.
    Line: 1
    Text: create or replace procedure test wrapped
    Error: PLS-00103: Encountered the symbol "=" when expecting one of the following:
    constant exception <an identifier>
    <a double-quoted delimited-identifier> table long double ref
    char time timestamp interval date binary national character
    nchar
    The symbol "<an identifier>" was substituted for "=" to continue.
    Line: 1
    Text: create or replace procedure test wrapped
    Error: PLS-00103: Encountered the symbol "=" when expecting one of the following:
    constant exception <an identifier>
    <a double-quoted delimited-identifier> table long double ref
    char time timestamp interval date binary national character
    nchar
    Line: 1
    Text: create or replace procedure test wrapped
    .Bot trigger and procedure works well before wrapped.
    I use oracle 11g2 at window 2003.
    Thanks
    newdba

  • 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

  • Ora-04021 error while compiling a stored procedure

    Hi Gurus,
    I am getting a ora-04021 timeout error while trying to compile a stored procedure. My Oracle version is 9i on Unix.
    Thanks
    Amitava.

    amitavachatterjee1975 wrote:
    Hi Gurus,
    I am getting a ora-04021 timeout error while trying to compile a stored procedure. My Oracle version is 9i on Unix.
    Thanks
    Amitava.
    my car won't go.
    tell me how to make my car go.
    How do I ask a question on the forums?
    https://forums.oracle.com/forums/thread.jspa?threadID=2174552#9360002
    [oracle@localhost ~]$ oerr ora 4021
    04021, 00000, "timeout occurred while waiting to lock object %s%s%s%s%s"
    // *Cause:  While waiting to lock a library object, a timeout occurred.
    // *Action: Retry the operation later.
    [oracle@localhost ~]$

  • Error while compiling a stored procedure

    Hi Expertise,
    I want to have all table names with their column name and tried using below stored procedure and it is throwing some compiler error at "fetch TestCurr into temp2;"
    I am very new to Data base and writing stored procedure and not able to understand how to resolve it. Please anyone help me out to correct it and provide some better idea to achieve my requirement. This is very urgent. One more thing, I want all these data into a log file.
    create or replace
    procedure temp as
    begin
    DECLARE
    cursor C1 IS SELECT COLUMN_NAME FROM user_tab_columns;
    file_id UTL_FILE.FILE_TYPE;
    Temp1 all_tables.table_name%TYPE;
    temp2 user_tab_columns.COLUMN_NAME%TYPE;
    cursor TempCur is Select table_name from all_tables where owner='XSS_ADMIN' order by TABLE_NAME;
    begin
    open TempCur;
    loop
    fetch TempCur into Temp1;
    exit when TempCur%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(Temp1);
    declare cursor TestCurr is select COLUMN_NAME from user_tab_columns where table_name= Temp1;
    open TestCurr;
    loop
    fetch TestCurr into temp2;
    exit when TestCurr%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(Temp2);
    end loop ;
    close TestCurr;
    end loop;
    Thanks in advance
    R e h a n

    Hi,
    declare cursor TestCurr is select COLUMN_NAME from user_tab_columns where table_name= Temp1;
    open TestCurr;
    loop The Cursor Declarations Should be done in the declaration Section of the PLSQL Block.
    The General Structure of Cursor Declaration is:
    DECLARE
    CURSOR curr IS
    SELECT FROM WHERE;
    rec curr%ROWTYPE;
    BEGIN
    OPEN curr;
    LOOP
    FETCH curr INTO rec;
    EXIT WHEN curr%NOTFOUND;
    END LOOP;
    CLOSE curr;
    END;
    If Use Multiple Cursor Declaration, then Use the below Structure ,
    DECLARE
    CURSOR curr IS
    SELECT FROM WHERE;
         CURSOR curr_1 IS
    SELECT FROM WHERE;
    rec curr%ROWTYPE;
    rec_1 curr_1%ROWTYPE;
    BEGIN
    OPEN curr;
    LOOP
    FETCH curr INTO rec;
    EXIT WHEN curr%NOTFOUND;
    END LOOP;
    CLOSE curr;
    END;
    So, You can Fetch the value for the Second Cursor in the LOOP of the First Cursor Statement.
    Or Just Declare a Single Cursor and User FOR-CURSOR LOOP as
    DECLARE
    CURSOR curr IS
    SELECT FROM WHERE;
    rec curr%ROWTYPE;
    BEGIN
    OPEN curr;
    LOOP
    FETCH curr INTO rec;
    EXIT WHEN curr%NOTFOUND;
         for rec_curr in(select *from where  col_name =rec.col_value)loop
         .............Processing
         end loop;
    END LOOP;
    CLOSE curr;
    END;
    You have ample example available for ,Please have a look at it and Try.. All the Best !!!!!
    Thanks,
    Shankar

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

Maybe you are looking for

  • I can no longer get my email to open

    My email has stopped working on my IPAD. It has worked for months but stopped. I have deleted and re-entered my email address....I have syned again....still doesn't open email. Any help would be appreciated.

  • What's New in Adobe Story | Digital Video CS6 | Adobe TV

    Adobe Evangelist Jason Levine shows how to use Adobe Story to outline, plan, script and schedule projects. http://adobe.ly/Ir92ME

  • XDODTEXE forces output to be UTF-8 ?

    I am using a data template as my XML generation source. The database character set is ISO-8859-1. I have some data that has French characters - accents, graves etc. When I use SQL or PL/SQL to generate the XML, there is no issue - the output contains

  • Photoshop CC asking for serial number which I do not have. [was: SOS Help please!!!]

    SOS Help please, I bought an annual subscription to Photoshop,month, worked fine ,now took the payment for the second month,but to enter the program I can't - the program asks for a serial number which I nikogda not received and personally ID just an

  • Convert Date using ORACLE WAREHOUSE BUILDER

    Hi, I need to convert date format from 'DD/MON/YYYY' to 'YYYY/MON/DD'. The data is varchar(2) and in the database is stored as date. I am using expression component. I used this expressionS REPLACE(TO_CHAR(INGRP1.FROMDATE), 'YYYY-MON-DD') REPLACE(TO_