ERROR IN PROCEDURE

I'm trying to write a procedure that will compute the start and end dates of the weeks within a period, etc. Number of business days in a week is 5; that is, Monday to Friday.
The first part of the code I have to write is giving me problems please help. The table below was created:
Wrote file afiedt.buf
1 CREATE TABLE WEEKS
2 (WEEKID VARCHAR2(20),
3 TRANSACTION_YEAR VARCHAR2(20),
4 START_DATE DATE,
5 END_DATE DATE,
6 DAYS VARCHAR2(20),
7* WEEK_NUMBER VARCHAR2(20))
SQL> /
Table created.
SQL> --- Code To Generate start date, end date weekid, week number, etc in A financial Year
SQL> Create OR REPLACE PROCEDURE Weeksinyear IS
2 BEGIN
3 declare
4 sdate_v weeks.start_date%type;
5 edate_v weeks.end_date%type;
6 ndays_v weeks.days%type;
7 nweek_v Weeks.week_number%type;
8 weekid_v weeks.weeksid%type;
9 transyear_v weeks.weeks.transaction_year%type;
10 numbweeks_v number;
11 fyearst_v date;
12 fyeared_v date;
13 totaldays_V number;
14 i number;
15 d number;
16 begin
17 fyearst_v := '05-jan-2004';
18 fyeared_v := '26-jan-2004';
19 sdate := fyearst_v;
20 transyear_v := to_char('05-jan-2004','yyyy');
21 nweek_v :=1;
22 ndays_v := 5;
23 totaldays_v := to_number(to_date(fyeared) - to_date(fyearst));
24 nweekid_v :=1;
25 i := 1;
26 loop
27 If to_char(fyearst_v,'DAY') ='MONDAY ' then
28 loop
29 i := i + 4;
30 if i < totaldays_v then
31 d := to_number(totaldays_v - i);
32 edate_v := (sdate_v + (d - 1));
33 elseif i = totaldays_v then
34 edate_v := sdate_v + 4;
35 elseif i < totaldays then
36 edate := (sdate + 4);
37 endif;
38 weekid_v := (i||'000'||'i');
39 insert into weeks(weekid, transaction_year, start_date, end_date, days, week_number)
40 values(weekid_v,transyear, sdate_v, ndays, nweek_v);
41 if totaldays_V > 7 then
42 weekid_v := weekid + 1;
43 sdate_v := sdate_v + 7;
44 transyear_V := transyear_v;
45 nweek_v := nweek_v + 1;
46 ndays_v := ndays_v;
47 totaldays_v := to_number(totaldays_v - 7);
48 else exit;
49 end loop;
50 else exit;
51 end loop;
52 end;
53 END;
54 /
Warning: Procedure created with compilation errors.
SQL> sho err;
Errors for PROCEDURE WEEKSINYEAR:
LINE/COL ERROR
33/35 PLS-00103: Encountered the symbol "I" when expecting one of the
following:
:= . ( @ % ;
35/35 PLS-00103: Encountered the symbol "I" when expecting one of the
following:
:= . ( @ % ;
49/23 PLS-00103: Encountered the symbol "LOOP" when expecting one of
the following:
if
LINE/COL ERROR
51/17 PLS-00103: Encountered the symbol "LOOP" when expecting one of
the following:
if
SQL>

So many things, I don't really know where to start.
At line 32
IF TO_CHAR(fyearst,'DAY') ='MONDAY ' then
Will never be true it needs to be either
IF TO_CHAR(fyearst,'DAY') ='MONDAY ' THEN -- A total of 9 characters (padded to the length of WEDNESDAY) or
IF TRIM(TO_CHAR(fyearst,'DAY')) ='MONDAY' THEN
Fixing this leads to a second problem in the inner loop. At line 35
IF i < totaldays THEN
is logically incorrect. The variable i will take the values 5, 9, 13, 17 and enter the if condition, but will not be equal to totaldays at line 38. On the fifth iteration i = 21 so the conditional at line 35 fails and you have an infinite loop, so the test needs to be:
IF i <= totaldays THEN
to even get into any of your processing. Now, on the fifth pass, the conditional on line 38 (IF i = totaldays THEN ) will be true, so edate gets set, but the condition on line 40 (IF i > totaldays THEN) can never be true, so we're back to an infinite loop.
So change line 40 to
IF i >= totaldays THEN
Now, the insert gets done, and the test at line 45 (IF totaldays > 7 THEN) passes and totaldays gets reset, and we go back to the top of the inner loop. Now, i = 21 and totaldays = 14, so the condition at line 35 fails, and again, we're in an infinite loop, so lets reset i as well as totaldays.
Now i still goes 5, 9, 13, 17, 21 but totaldays = 14, so the test at line 38 is never true, and once more, an infinite loop.
At this point I gave up and put an explicit exit after the insert statement, just to see what should be inserted, and got another infinite loop in the outer loop because there is no terminating condition on the loop since fyearst never gets changed. Having seen some output, I think what you are looking for is something more like:
INSERT INTO weeks
SELECT rownum, TO_CHAR(TO_DATE('05-jan-2004','dd-mon-yyyy'),'YYYY'),
       NEXT_DAY(TO_DATE('05-jan-2004','dd-mon-yyyy') - 7,'MONDAY') + ((rownum - 1) * 7),
       NEXT_DAY(TO_DATE('05-jan-2004','dd-mon-yyyy') + 1,'FRIDAY') + ((rownum - 1) * 7),
       '5', TO_CHAR(rownum)
FROM all_objects
WHERE rownum <= 52or, if you really want a procedure:
CREATE OR REPLACE PROCEDURE weeksinyear (p_start IN DATE, p_end IN DATE) AS
   num_weeks NUMBER;
BEGIN
   num_weeks := (NEXT_DAY(p_end,'MONDAY') - NEXT_DAY(p_start - 7,'MONDAY')) /7;
   INSERT INTO weeks
   SELECT rownum, TO_CHAR(p_start,'YYYY'),
          NEXT_DAY(p_start - 7,'MONDAY') + ((rownum - 1) * 7),
          NEXT_DAY(p_start + 1,'FRIDAY') + ((rownum - 1) * 7),
          '5', TO_CHAR(rownum)
   FROM all_objects
   WHERE rownum <= num_weeks;
   COMMIT;
END;If you will always want to do this for an entire year, then the procedure could be simplified to:
CREATE OR REPLACE PROCEDURE weeksinyear (p_start IN DATE) AS
BEGIN
   INSERT INTO weeks
   SELECT rownum, TO_CHAR(p_start,'YYYY'),
          NEXT_DAY(p_start - 7,'MONDAY') + ((rownum - 1) * 7),
          NEXT_DAY(p_start + 1,'FRIDAY') + ((rownum - 1) * 7),
          '5', TO_CHAR(rownum)
   FROM all_objects
   WHERE rownum <= 52;
   COMMIT;
END;TTFN
John

Similar Messages

  • While opening the iTune Store i receive the following error, "The procedure entry point ADAdPolicyEngine_DidEnterSation could not be located in the dynamic link library iAdCore.dll" Please help me to clear this error.

    While opening the iTune Store i receive the following error, "The procedure entry point ADAdPolicyEngine_DidEnterSation could not be located in the dynamic link library iAdCore.dll" Please help me to clear this error.

    I faced the same issue. This solved it for me: Troubleshooting issues with iTunes for Windows updates
    Hope this helps.

  • Was trying to update my ITunes and get this error: The procedure entry point AVCFPlayerItemDurationChangedNotification could not be located in the dynamic link library AVFoundationCF.dll. Just got the new IPhone and am trying to share music files. Can any

    I have Windows Vista computer. I am trying to upgrade my ITunes so can share files with other home computer. (Just got the new IPhone). I get this system error: The procedure entry point AVCFPlayerItemDurationChangedNotification could not be located in the dynamic link library AVFoundationCF.dll. Tries system restore and redownloaded...NOW Itunes will not even open. Can anyone help?

    I uninstalled Apple Application Support, opened iTunesSetup with WinRar, and went down the list of msi's. AppleApplicationSupport was an install, all the others I did Repair.  Did not have to reboot. Works okay now.
    HTH

  • Getting Error-- "The procedure entry point _UP_GetActiveTreeCell could not be located in the dynamic link library cvirte.dll" on host machine.

    I am trying to build an executible program that will be portable to machines which do not have CVI installed.  It works fine on my CVI v9.1 system.  However, whether or not I include "Full run-time support" in the build options, I get the error "The procedure entry point _UP_GetActiveTreeCell could not be located in the dynamic link library cvirte.dll" when I try to run it on a machine without CVI.  Please help.

    To run a CVI application on a system were the CVI IDE is not installed you need to have the CVI RunTime Engine installed. According to the error message at the bottom of this page you may have an older RTE installed in the target system.
    To obtain it you can either download the RTE and install in the target system or better let the IDE build a distribution disk that installs all necessary software in it: this guide drives you in creating the appropriate installer for your application: you can find it also in CVI help function.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Can't launch itunes due to the following error; The procedure entry point AVCFPlayerAppliesMediaSelectionCriteriaKey could not be located in the dynamic link library AVFoundationCF.dll.

    Can't launch itunes due to the following error; The procedure entry point AVCFPlayerAppliesMediaSelectionCriteriaKey could not be located in the dynamic link library AVFoundationCF.dll.

    Hey bcolden,
    I would try uninstalling and reinstalling following the directions in here:
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    http://support.apple.com/kb/HT1923
    This section in particular contains important information in the uninstall process:
    Use the Control Panel to uninstall iTunes and related software components in the following order and then restart your computer:
    iTunes
    Apple Software Update
    Apple Mobile Device Support
    Bonjour
    Apple Application Support (iTunes 9 or later)
    Important: Uninstalling these components in a different order, or only uninstalling some of these components may have unintended affects.
    Let us know if following that article and uninstalling those components in that order helped the situation.
    Welcome to Apple Support Communities!
    Best,
    Delgadoh

  • REPLICAT ERROR(The procedure entry point long jmp could not be located )

    Hi,
    I am getting the following error
    The procedure entry point long jmp could not be located in the dynamic link library orauts.dll
    Does anyone know anything about this? please help.
    Thanks
    V

    i googled to the solution before i got to the answer but thanks anyway... you are right i changed my oracle home yesterday...today i had to reset to make this work...
    Thanks
    Venkat

  • HT203175 Why won't iTunes install properly? It gives the start up error "The procedure entry point JSStringGetUTF8String could not be located in the dynamic link library WebKit.dll"

    I can't get iTunes to install/start on my HP laptop. When I start/install the current version, I get the following error "The procedure entry point "JSStringGetUTF8String could not be located in the dynamic link library WebKit.dll". Why isn't this dll included in the distribution? What do I do to get iTunes to install on my 64-bit AMD HP laptop.

    Taken at face value, you're having trouble with an Apple Application Support program file there. (Apple Application Support is where single copies of program files used by multiple different Apple programs are kept.)
    Let's try something relatively simple first. Restart the PC. Now head into your Uninstall a program control panel, select "Apple Application Support" and then click "Repair".
    Does iTunes launch properly now?
    If no joy after that, try the more rigorous uninstall/reinstall procedure from the following post:
    Re: I recently updated to vista service pack 2 and I updated to itunes

  • Why i receive errors: "The procedure entry point longjmp could not be found in the dynamic link lib. orauts.dll" and "Error ORA-12560"

    Hello,
    "C:\app\xps\product\11.2.0\dbhome_1"  where is my installation of database oracle enterprise 11g; I use Windows 7 Pro.
    I have in System PATH : C:\app\xps\product\11.2.0\dbhome_1\bin
    I have in HKEY_LOCAL_MACHINE > SOFTWARE > ORACLE > SYSMAN > OracleDBConsoleorcl : "ORACLE_HOME" value "C:\app\xps\product\11.2.0\dbhome_1"
    When i execute "sqlplus / as sysdba" command, i receive error: "The procedure entry point longjmp could not be found in the dynamic link lib. orauts.dll" and "Error ORA-12560"
    If i execute
    set ORACLE_HOME=C:\app\xps\product\11.2.0\dbhome_1
    C:\>set PATH=%ORACLE_HOME%\bin;%PATH%
    sqlplus "/ as sysdba"
    I don't receive Error.
    Why?

    You don't mention which specific version of the operating system that you are using - Windows XP, Vista, or 7 and whether you're using a 32-bit or 64-bit version.
    FWIW, kernell32.dll is a Windows system-level module, so it's possible that you have some corruption in your Windows installation which is preventing FM from launching.
    Also, 2Gb of RAM is a bit lean for FM.

  • FDM Conditional Map error - Invalid Procedure Call or arguments

    Hi,
    I am trying to add a script to my LIKE mapping to pick up the target Product based on the type of target account.
    This is the script I have written -
    If Mid(varValues(14),1,1) = "6" Then Result = varValues(37) Else Result = varValues(21) End If
    When i try to import (using Integration script from a database table) I get the error - Invalid Procedure Call or arguments.
    If I remove the 'Else' part, it imports successfully. Also I tried the same using Case statements - I get the same error, if I remove 'Case Else' it works fine.
    Any hekp on this would be highly appreciated!
    Thanks in advnace...

    This mapping is associated with Product dimension - UD10 (varValues(37)). UD10 is active and mappable, mapped to target Product dimension. UD2 (varValues(21)) is the lookup which is not mapped to a target dimension.

  • Error compiling procedure

    Hi to All,
    While creating a procedure I got a "ORA-00942: table or view does not exist" the table is there I can do a describe do a select, but some reason it does not see it if referenced in the procedure, if I use the same statement in "DECLARE" instead of "CREATE OR REPLACE" it sees the table and no error is given.
    Below is the code:
    FFS> DESC STE_V1SITE
    Name
    SITE_ID_NU
    ST_NU
    SITE_NU
    SITE_FMLY_ID_NU
    PRE_SITE_ID_NU
    SITE_DS
    FFS> CREATE OR REPLACE PROCEDURE temp IS
    2
    3 CURSOR site_ds_cur (
    4 P_site_id IN NUMBER
    5 , P_Thru_Dt IN DATE
    6 ) IS
    7 SELECT site.site_ds
    8 FROM ste_v1site site
    9 WHERE site.site_id_nu = P_site_id ;
    10
    11 TYPE site_ds_typ IS
    12 TABLE OF ste_v1site.site_ds%TYPE
    13 INDEX BY BINARY_INTEGER;
    14
    15 site_ds_tbl site_ds_typ;
    16
    17 BEGIN
    18 NULL;
    19
    20 END;
    21 /
    Warning: Procedure created with compilation errors.
    FFS> SHO ERROR
    Errors for PROCEDURE TEMP:
    LINE/COL ERROR
    7/3 PL/SQL: SQL Statement ignored
    8/10 PL/SQL: ORA-00942: table or view does not exist
    11/3 PL/SQL: Item ignored
    12/12 PLS-00201: identifier 'STE_V1SITE' must be declared
    FFS>
    FFS> DECLARE
    2 CURSOR site_ds_cur (
    3 P_site_id IN NUMBER
    4 , P_Thru_Dt IN DATE
    5 ) IS
    6 SELECT site.site_ds
    7 FROM ste_v1site site
    8 WHERE site.site_id_nu = P_site_id ;
    9
    10 TYPE site_ds_typ IS
    11 TABLE OF ste_v1site.site_ds%TYPE
    12 INDEX BY BINARY_INTEGER;
    13
    14 site_ds_tbl site_ds_typ;
    15
    16 BEGIN
    17 NULL;
    18 END;
    19 /
    PL/SQL procedure successfully completed.
    FFS> CREATE OR REPLACE PROCEDURE temp IS
    2 BEGIN
    3 NULL;
    4 END;
    5 /
    Procedure created.
    Thanks to all those who provide help...
    Habeeb

    somthing like this
    SQL> declare
      2  cursor c(pdeptno number) is select empno,ename from emp
      3  where deptno=pdeptno;
      4  begin
      5  for i in c(10) loop
      6    dbms_output.PUT_LINE(i.empno||'     :   '||i.ename);
      7  end loop;
      8  end;
      9  /
    7782     :   CLARK
    7839     :   KING
    7934     :   MILLER
    PL/SQL procedure successfully completed.

  • PLS-00382 Error in procedure

    I have a procedure (below) that is invalid. Last night the instance of the database I'm working in got refreshed (data only) and a few of my procedures were invalidated, including this one. When I tried to recreate it I got the following error:
    PLS-00382: expression is of wrong type
    I don't understand why it's now not working (worked fine yesterday), or what this error means in relation to the statement.
    Does anyone know what I'm doing wrong here?
    Thanks,
    Pete
    SQL> CREATE OR REPLACE PROCEDURE nyp.WBS_NOTE
    2 IS
    3 CURSOR C_WBS_NOTES IS
    4 SELECT * FROM WBS_NOTES;
    5 V_WBS_ID NUMBER;
    6 V_WBSMEMO_ID NUMBER;
    7 V_PROJ_ID NUMBER;
    8 V_WBS_VAL VARCHAR2(200);
    9 V_WBS_PARENT VARCHAR2(200);
    10
    11 BEGIN
    12 UPDATE
    13 WBS_NOTES W
    14 SET W.TEXT = REPLACE(W.Text, 'CHR(13)', '
    15 ');
    16 INSERT INTO WBS_NOTE_PROJ_NOT_FOUND
    17 SELECT *
    18 FROM WBS_NOTES W WHERE EXISTS(
    19 SELECT 'A'
    20 FROM ACC_CONV_PROJ_NOT_FOUND P
    21 WHERE W.Project_num = P.Project_num);
    22 DELETE
    23 FROM WBS_NOTES W WHERE EXISTS(
    24 SELECT 'A'
    25 FROM ACC_CONV_PROJ_NOT_FOUND P
    26 WHERE W.Project_num = P.Project_num);
    27 FOR NOTES IN C_WBS_NOTES LOOP
    28 SELECT P.PROJ_ID
    29 INTO V_PROJ_ID
    30 FROM PROJECT P
    31 WHERE P.PROJ_SHORT_NAME = NOTES.PROJECT_NUM;
    32 V_WBS_VAL := NOTES.WBS;
    33 V_WBS_PARENT := SUBSTR(V_WBS_VAL, 1, INSTR(V_WBS_VAL, '.', -1) - 1);
    34 WHILE INSTR(V_WBS_PARENT, '.') <> 0 LOOP
    35 V_WBS_PARENT := SUBSTR(V_WBS_PARENT, INSTR(V_WBS_PARENT, '.') + 1, 200);
    36 END LOOP;
    37 V_WBS_VAL := SUBSTR(V_WBS_VAL, INSTR(V_WBS_VAL, '.') + 1, 200);
    38 WHILE INSTR(V_WBS_VAL, '.') <> 0 LOOP
    39 V_WBS_VAL := SUBSTR(V_WBS_VAL, INSTR(V_WBS_VAL, '.') + 1, 200);
    40 END LOOP;
    41 SELECT W.WBS_ID
    42 INTO V_WBS_ID
    43 FROM PROJWBS W
    44 , PROJWBS PW
    45 WHERE UPPER(W.WBS_NAME) = UPPER(V_WBS_VAL)
    46 AND PW.PROJ_ID = V_PROJ_ID
    47 AND PW.WBS_ID = W.PARENT_WBS_ID
    48 AND UPPER(PW.WBS_SHORT_NAME) = UPPER(V_WBS_PARENT);
    49 GETNEXTKEYS('wbsmemo_wbs_memo_id', 1, V_WBSMEMO_ID);
    50 EXECUTE IMMEDIATE
    51 ' INSERT INTO WBSMEMO ' ||
    52 ' SELECT ' || V_WBSMEMO_ID ||
    53 ', ''' || V_PROJ_ID || '''' ||
    54 ', ''' || V_WBS_ID || '''' ||
    55 ', MT.MEMO_TYPE_ID ' ||
    56 ', ''' || NOTES.TEXT || '''' ||
    57 ' FROM MEMOTYPE MT ' ||
    58 ' WHERE MT.MEMO_TYPE = ''' || NOTES.NTBKTYPE || '''';
    59 END LOOP;
    60 END;
    61 /
    Warning: Procedure created with compilation errors.
    SQL> SHOW ERRORS
    Errors for PROCEDURE NYP.WBS_NOTE:
    LINE/COL ERROR
    50/2 PL/SQL: Statement ignored
    51/2 PLS-00382: expression is of wrong type

    There could be data type mis-match within the time you re-compiled the program. Check the data type for which you are Inserting / Updating with the values you are actually using to populate.
    Note:
    Insert into TABLE1
    Select * from TABLE2.
    It is not advisible to have the above statement
    eventhough this will work as long as
    the fields in table TABLE1 and TABLE2 are same.
    Instead of "*" use the filed names.
    CRAMANA

  • Error in procedure creation

    Hi,
    I am creating the procedure but getting the following error. I could not identify where the exact problem at line 5:
    Oracle 11.2.0
    SQL> CREATE OR REPLACE PROCEDURE BEDPOST_SATYA
    2 (TRANDATE OUT BEDPOSTCHECK.TRANDATE%TYPE,
    3 NOS OUT BEDPOSTCHECK.NOS%TYPE,
    4 UNIT OUT BEDPOSTCHECK.TRANDATE%TYPE,
    5 TDATE VARCHAR2(20);)
    6 AS
    7 Select to_char(SYSDATE-1,'YYYYMMDD') into TDATE from dual;
    8 cursor satya is
    9 select trandate,nos,unit from bedpostcheck where trandate=tdate;
    10 begin
    11 open satya;
    12 loop
    13 fetch satya
    14 into trandate,nos,unit;
    15 exit when satya%notfound;
    16 dbms_output.put_line (trandate || unit || nos);
    17 end loop
    18 close satya;
    19 END BEDPOST_SATYA;
    20 /
    Warning: Procedure created with compilation errors
    SQL> SHOW ERRORS;
    Errors for PROCEDURE JEEVADB.BEDPOST_SATYA:
    LINE/COL ERROR
    5/15 PLS-00103: Encountered the symbol "(" when expecting one of the following: := . ) , @ % default character
    thanks
    satya

    user608405 wrote:
    I have modified but getting the following errors:
    SQL> CREATE OR REPLACE PROCEDURE BEDPOST_SATYA
    2 (TRANDATE OUT BEDPOSTCHECK.TRANDATE%TYPE,
    3 NOS OUT BEDPOSTCHECK.NOS%TYPE,
    4 UNIT OUT BEDPOSTCHECK.TRANDATE%TYPE,
    5 TDATE VARCHAR2(20))
    6 AS
    7 Select to_char(SYSDATE-1,'YYYYMMDD') into TDATE from dual;
    8 cursor satya is
    9 select trandate,nos,unit from bedpostcheck where trandate=tdate;
    10 begin
    11 open satya;
    12 loop
    13 fetch satya
    14 into trandate,nos,unit;
    15 exit when satya%notfound;
    16 dbms_output.put_line (trandate || unit || nos);
    17 end loop
    18 close satya;
    19 END BEDPOST_SATYA;
    20 /
    Warning: Procedure created with compilation errors
    SQL> show errors;
    Errors for PROCEDURE JEEVADB.BEDPOST_SATYA:
    LINE/COL ERROR
    5/15 PLS-00103: Encountered the symbol "(" when expecting one of the following: := . ) , @ % default character The symbol ":=" was substituted for "(" to continue.
    7/1 PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior external language The symbol "begin" was substituted for "SELECT" to continue.
    8/8 PLS-00103: Encountered the symbol "SATYA" when expecting one of the following: := . ( @ % ;try this or the prior posting that i have.
    CREATE OR REPLACE PROCEDURE BEDPOST_SATYA (TRANDATE OUT BEDPOSTCHECK.TRANDATE%TYPE,
                                               NOS OUT BEDPOSTCHECK.NOS%TYPE,
                                               UNIT OUT BEDPOSTCHECK.TRANDATE%TYPE) As
      cursor satya is
        select trandate,nos,unit
          from bedpostcheck
         where trandate = (SYSDATE-1,'YYYYMMDD');
    begin
      open satya;
      loop
        fetch satya into trandate, nos, unit;
        exit when satya%notfound;
        dbms_output.put_line (trandate || unit || nos);
      end loop;
      close satya;
    END BEDPOST_SATYA;
    /

  • If there is no error in procedure/function, what is  value for SQLCODE..?

    Hi all...
    If there is no error in procedure/function, what is value for SQLCODE..?
    I Think, 0 (zero) is the default value for SQLCODE
    and default value for all other varaibles in PL/SQL is NULL. I am right or wrong...?
    Thanks in advance,
    Pal
    Message was edited by:
    user546710

    why not test?
    DECLARE
    err_code NUMBER(9);
    BEGIN
        err_code := SQLCODE;
        DBMS_OUTPUT.PUT_LINE(err_code);
    END;                                                                                                                                                                                                                                                           

  • DBLink error in procedure

    Hi,
    Please help me to solve this DBLink error in procedure.
    Created a below DBLink and it is working fine all sql statements in sql plus.
    DBLink created statement
    CREATE DATABASE LINK "OFFICE2"
    CONNECT TO "SALES" IDENTIFIED BY "SALES"
    USING 'TNSOFFICE2';
    SELECT TRANSACTIONID
    FROM RECEIPT_DETAIL@OFFICE2
    INSERT INTO RECEIPT_DETAIL@OFFICE2
    (TRANSACTIONID)
    VALUES
    (665035);
    While I am using this same statements in procedure, I am getting a error
    'ORA-00942 table or view does not exist' in dblink used statements and procedure is not compiling.
    Please help me to solve this problem
    CREATE OR REPLACE
    PROCEDURE TEST_PROC1 AS
    L_REC_NO NUMBER(10);
    CURSOR C1 IS
    SELECT TRANSACTIONID
    FROM RECEIPT_DETAIL@OFFICE2
    BEGIN
    OPEN C1;
    FETCH C1 INTO L_REC_NO;
    CLOSE C1;
    INSERT INTO RECEIPT_DETAIL@OFFICE2
    (TRANSACTIONID)
    VALUES
    (665035);
    END TEST_PROC1;
    Thanks & Regards,
    Jen.

    Jen. wrote:
    Created a below DBLink and it is working fine all sql statements in sql plus.Who owns this database link? (name of the schema)
    While I am using this same statements in procedure, I am getting a error
    'ORA-00942 table or view does not exist' in dblink used statements and procedure is not compiling.Who owns this stored procedure?
    CURSOR C1 IS
    SELECT TRANSACTIONID
    FROM RECEIPT_DETAIL@OFFICE2
    BEGIN
    OPEN C1;
    FETCH C1 INTO L_REC_NO;
    CLOSE C1;Why? The following is a lot less code, easier to read and more maintainable.
      L_REC_NO NUMBER(10);
    begin
      select transationid into  l_rec_no from from receipt_detail@office2;
    end;No need for an explicit cursor.
    Also why are you using a L_ prefix for variables? And why underscores? This is an extremely silly standard that fails to understand the impact of Hungarian-like notation, how to correctly manage scope resolution, and using camelcase for variables (a standard in most modern programming languages).
    The very worse place you can look at for programming standards is PL/SQL code from Oracle (as they have no consistent set standard as proved by the packages supplied by them, and often resort to COBOL-like standards of the 80's - which has no place in the 21st century software engineering)

  • Capture error in procedure

    Hi,
    I'm running a procedure, i would like that if any error occures there will be a message that an error cccured, don't want to specifiy the error.
    tried:
    procedure...
    EXCEPTION
    htp.p('an error occured');
    end;doesn't seem to work.
    thx
    Esther

    It looks like
    EXCEPTION WHEN OTHERS THEN
    htp.p('something');
    END;

Maybe you are looking for