Pragma restrict_references problem

PLS-00452: Subprogram  violates its associated pragma
I get this error when compiling a package. The problem is actually the following: I have a function which was initially written with variables of type "DATE". I migrated this function by replacing everywhere the "DATE" types with "TIMESTAMP WITH TIME ZONE" types, this being the only difference between the original function and the modified one. The initial function works, but the migrated one gives the above specified failure. There are no database interactions in a function, except for a select, which is not affected by the change. Does anybody know why this happens? Any help is greatly appreciated

Are you certain that you did NOTHING but change date types into timestamp with time zone types ?
Might you also have changed a variable from a local one to a global one ?
Is it possible that in a global edit you managed to change the name of a variable so that changes in precedence accidentally turned a local assignment into a global assignment.
Regards
Jonathan Lewis
Now on Twitter: @jloracle

Similar Messages

  • Problem in setting Pragma Restrict References

    Dear all,
    I've got a question on PRAGMA RESTRICT_REFERENCES. Please help. Thanks.
    I've created a view "V_STUDENT" which retrieves student information. One of
    columns in this view "STUD_NAME" will get the student name from a function
    "F_STUDNAME". This function is placed in a package. No error occurs when compilation
    of view & package. However, when I run the following command, problem occurs :
    1) select STUD_CODE, STUD_NAME from V_STUDENT
    group by STUD_CODE, STUD_NAME
    ORA-06573: FUNCTION F_STUDNAME modifies package state, cannot be used here
    I really don't know why or which statement would modify package state?
    I've tried to change "PRAGMA RESTRICT_REFERENCES (F_STUDNAME, 'WNDS')" to
    "PRAGMA RESTRICT_REFERENCES (F_STUDNAME, 'WNDS', 'WNPS')". Then, the above command executes
    normally. No more error message. But what's the reason ?
    2) select STUD_CODE, STUD_NAME from V_STUDENT
    No error message when the setting is "PRAGMA RESTRICT_REFERENCES (F_STUDNAME, 'WNDS')" for
    the above command. What're the differences ?
    CREATE OR REPLACE VIEW V_STUDENT ( STUD_CODE, STUD_NAME, ...
    ) AS SELECT STUD_CODE, PKG1.F_STUDNAME(STUD_CODE) STUD_NAME, ...
    FROM STUDNET ...
    CREATE OR REPLACE PACKAGE PKG1 IS
    FUNCTION F_STUDNAME(STUD_CODE STUDENT.STUD_CODE%TYPE) RETURN VARCHAR2;
    PRAGMA RESTRICT_REFERENCES (F_STUDNAME, 'WNDS');
    END;
    CREATE OR REPLACE PACKAGE BODY PKG1 IS
    FUNCTION F_STUDNAME(STUD_CODE STUDENT.STUD_CODE%TYPE) RETURN VARCHAR2 IS
    stud_name VARCHAR2(50);
    BEGIN
    IF STUD_CODE IS NOT NULL THEN
    SELECT STUD_FSTNAME| |' '| |STUD_LSTNAME
    INTO stud_name
    FROM ALL_STUDENT_NAME
    WHERE ALL_STUD_CODE = STUD_CODE
    ELSE
    RETURN NULL;
    END IF;
    RETURN stud_name;
    EXCEPTION
    WHEN OTHERS THEN RETURN NULL;
    END F_STUDNAME;
    END;
    Regards,
    Twin

    1. To use a function in the where/group by clause of a select statement the function must be WNDS and WNPS. As you have not explicitly stated that the function does not break the WNPS restriction the SQL engine assumes it does and so will not allow you to use it here. Add the restriction to the pragma, as you have done, and it will work.
    2. To use a function in the select cluase of a select statement only WNDS needs to be declared. Since this is stated the statement will work

  • What are SERIALLY_REUSABLE and RESTRICT_REFERENCES pragmas and when used?

    Hi everyone,
    I have recently joined in Discussion forums and My question is about SERIALLY_REUSABLE and RESTRICT_REFERENCES pragmas.
    what are these pragmas and when can we use them? please give me practical example as I have understood them
    in Oracle documentation but not able to use practically.
    It would be greatly appreciated if anyone can help me.
    Regards,
    Sachin Jaiswal

    SERIALLY_REUSABLE : This pragama indicates that, the package states are stored only for the block it is executing. Means teh package states are not stored for the session. In this way the constants defined in the package wont be available for the whole session.
    RESTRICT_REFERENCES: This pragma is to check, packaged functions have the expected purity during compilation itself. For example, if you want to assert that a packaged function wont do any db writes, you can use as below.
    create package p1 is ..
      function test_fn return number;
      pragma restrict_references(test_fn,wnds)
    end p1;

  • Function in SQL: PRAGMA used, but '..does not guarantee not to update database'- WHY?

    I use function in SQL statement. It is a dynamicaly build SQL, therefore I need overload functions. These funcs defined in package. The package has PRAGMA Restrict_References (.., WNDS). So all functions should be restricted to update database.
    But Oracle returns an error:
    Function NVL_ does not guarantee not to update database
    This is my build SQL:
    ----- the execution string is: ---------------
    Begin
    INSERT INTO TEST_TBL_BS (MILL_ORDER, CLM1, CLM2, CLM3, NOTES, INIT_DATE )
    VALUES (NV.NVL_(Arc_Utl.TEST_TBL_dltd.MILL_ORDER),
    NV.NVL_(Arc_Utl.TEST_TBL_dltd.CLM1),
    NV.NVL_(Arc_Utl.TEST_TBL_dltd.CLM2),
    NV.NVL_(Arc_Utl.TEST_TBL_dltd.CLM3),
    NV.NVL_(Arc_Utl.TEST_TBL_dltd.NOTES),
    Arch.Init_Time );
    End;
    This is NV package:
    PACKAGE NV IS
    PRAGMA Restrict_References ( NV, WNDS );
    NULL_date DATE := TO_DATE ('01/01/1001', 'mm/dd/yyyy');
    NULL_numb NUMBER := 0;
    NULL_str VARCHAR2 (10)
    := '?';
    -- overloaded NULL_Val function returns NULL_<type> value (defined early)
    -- depend on received variable type
    FUNCTION NULL_Val ( val_in IN DATE )
    RETURN DATE ;
    FUNCTION NULL_Val ( val_in IN NUMBER )
    RETURN NUMBER ;
    FUNCTION NULL_Val ( val_in IN VARCHAR2 )
    RETURN VARCHAR2 ;
    -- PRAGMA Restrict_References ( NULL_Val, WNDS ); -- can be used in SQLs
    -- these pretends to cover hole of the SYS.NVL that do not have posibility
    -- to return default NULL value for every given type
    FUNCTION NVL_ ( val_in IN DATE )
    RETURN DATE ;
    FUNCTION NVL_ ( val_in IN NUMBER )
    RETURN NUMBER ;
    FUNCTION NVL_ ( val_in IN VARCHAR2 )
    RETURN VARCHAR2 ;
    -- PRAGMA Restrict_References ( NVL_, WNDS ); -- can be used in SQLs
    END NV;
    CREATE OR REPLACE PACKAGE BODY NV AS
    -- NULL_Val set of overloaded functions - returns appropriate NULL value
    FUNCTION NULL_Val ( val_in IN DATE )
    RETURN DATE IS
    BEGIN RETURN NULL_date;
    END NULL_Val; -- for date
    FUNCTION NULL_Val ( val_in IN NUMBER )
    RETURN NUMBER IS
    BEGIN RETURN NULL_numb;
    END NULL_Val; -- for NUMBER
    FUNCTION NULL_Val ( val_in IN VARCHAR2 )
    RETURN VARCHAR2 IS
    BEGIN RETURN NULL_str;
    END NULL_Val; -- for VARCHAR2
    -- set NVL_ function to return default NULL value if received variable
    -- is NULL or the received variable if it is not NULL
    FUNCTION NVL_ ( val_in IN DATE )
    RETURN DATE IS
    BEGIN RETURN NVL( val_in, NULL_Val ( val_in )); END NVL_;
    FUNCTION NVL_ ( val_in IN NUMBER )
    RETURN NUMBER IS
    BEGIN RETURN NVL( val_in, NULL_Val ( val_in )); END NVL_;
    FUNCTION NVL_ ( val_in IN VARCHAR2 )
    RETURN VARCHAR2 IS
    BEGIN RETURN NVL( val_in, NULL_Val ( val_in )); END NVL_;
    END NV;
    Can anybody help : where is a problem and what I can do in my case?
    I work in Oracle 7.3
    Thank you,
    Alex

    Hi Alex,
    I've found that on the RDBS docs:
    If you specify DEFAULT instead of a function name, the pragma applies to all functions in the package spec or object type spec (including, in the latter case, the
    system-defined constructor). You can still declare the pragma for individual functions. Such pragmas override the default pragma.
    Try using that and let me know.
    The docs says also that the declaration of the pragma for an overloaded function applies to the nearest one. You may also try to insert several declaration, one after every function declaration.
    Bye Max

  • ORA-6571 ERROR (PACKAGE PRAGMA의 사용)

    제품 : SQL*PLUS
    작성날짜 : 1997-06-03
    * ORA-6571 Error ( Package Pragma 의 사용 )
    =============================================
    SQL문 안에서 Stored function을 call하여 사용하는 경우 ORA-6571 error가
    발생할 수 있습니다. 기본적으로 stored function이나 procedure, package에서의
    DML 문장의 사용은 보장이 되는 기능이나, sql list에서의 stored function의
    사용은 몇 가지 제약 조건을 가지고 수행이 가능합니다.
    아래의 자료는 ORA-6571 error가 발생하는 원인에 대하여 기술한 자료이며,
    stored function을 SQL EXPRESSION에서 사용하는 경우에 대해서만 적용이 되는
    사항입니다.
    Calling Stored Functions from SQL Expressions
    Stored function은 data dictionary에 저장이 되는 user defined pl/sql
    function을 의미하며, 하나의 database object로서 해당 database에 connect하는
    application에 의해서도 reference될 수 있습니다.
    Function에는 2가지 유형이 제공되고 있는데, package 형태(pl/sql package 내
    에서 defined된 function)와, standalone function(독립적인 function)이 있
    습니다.
    pl/sql version 2.0까지는 stored function을 call하는 부분이 procedural
    statement에서만 사용이 가능하였으나, pl/sql version 2.1부터는 sql 문 안에서
    도 stored function을 call하여 사용이 가능하게 되었습니다.
    2.1 version 이상의 pl/sql engine에서는 select 문이나 values, set, where,
    start with, group by, having, order by 등과 같은 sql expression에서
    function을 call하여 사용하실 수 있습니다.
    즉, user-defined function을 built-in sql function(round, length,
    months_between ...)과 같은 형태로 사용이 가능하도록 지원이 됩니다.
    이러한 sql 문의 확장 지원은 oracle server 내에서 보다 복잡한 data에 대한
    분석 작업을 용이하게 하며 data independency를 증가시킵니다.
    Sql expression의 내부에서 사용이 되는 function과는 다르게 stored procedure는
    statement로서만 call되며 sql expression에서 direct로 call될 수 없습니다.
    Calling Syntax
    stored function을 sql expression에서 call하고자 하는 경우에는 다음의 syntax
    를 사용하시면 됩니다.
    [schema.][package.]function[@dblink][(arg[, arg] ...)]
    argument를 넘기는 경우에는 positional notation을 사용하여 작업을 수행하셔야
    합니다.
    Remote oracle database에 있는 standalone function gross_pay를 call하는
    경우를 예로 들어보면 아래와 같이 기술할수 있습니다.
    SELECT gross_pay@newyork(eenum, stime, otime) INTO pay FROM dual;
    Using Default Values
    Stored function gross_pay가 DEFAULT 절을 사용하여 2개의 formal parameter를
    넘기는 경우의 function creation은 아래와 같이 기술됩니다.
    CREATE FUNCTION gross_pay
         (emp_id IN NUMBER,
         st_hrs IN NUMBER DEFAULT 40,
         ot_hrs IN NUMBER DEFAULT 0) RETURN
         NUMBER AS
    Procedural statement에서 gross_pay function을 call하는 경우에는 항상
    st_hrs의 default 값을 accept할 수 있으며, 이는 named notation을 사용하기
    때문에 가능합니다.
    그러나, sql expression에서는 ot_hrs의 default값을 accept하지 않는다면,
    st_hrs의 default값을 accept할 수 없으며, 이는 named notation을 sql
    expression에서는 사용할 수 없기 때문입니다.
    /* Named Notation */
    IF gross_pay(eenum, ot_hrs => otime) > pay_limit THEN . . .
    Meeting Basic Requirements
    sql expression에서 call 할 수 있는 user-defined pl/sql function은
    아래의 기본 조건을 만족하여야 합니다.
    1. Stored function이여야 합니다.
    pl/sql block이나 subprogram 내에 define된 function은 사용할 수 없습니다.
    2. Row function이여야 하며, column (group) function이여서는 안됩니다.
    이는 argument로 전체 column의 data를 사용할 수 없기 때문입니다.
    3. Function의 모든 formal parameter는 반드시 IN parameter이여야 합니다.
    OUT이나 IN OUT parameter는 사용될 수 없습니다.
    4. Formal parameter의 datatype은 oracle server internal type (CHAR,
    DATE, NUMBER)이어야 합니다.
    pl/sql type(BOOLEAN, RECORD, TABLE)은 사용할 수 없습니다.
    5. Return type도 반드시 oracle server internal type이여야 합니다.
    아래의 stored function은 상기의 조건을 모두 만족하는 function입니다.
    CREATE FUNCTION gross_pay
         (emp_id IN NUMBER,
         st_hrs IN NUMBER DEFAULT 40,
         ot_hrs IN NUMBER DEFAULT 0) RETURN NUMBER
    AS
         st_rate NUMBER;
         ot_rate NUMBER;
    BEGIN
         SELECT srate, orate INTO st_rate, ot_rate
         FROM payroll
         WHERE acctno = emp_id;
         RETURN st_hrs * st_rate + ot_hrs * ot_rate;
    END gross_pay;
    Controlling Side Effects
    Sql 문에서 call되는 stored function을 실행하기 위하여, oracle server는
    해당 function의 purity level(function이 side effect로 부터 free한 영역)을
    알고 있어야만 합니다.
    Side effect는 database table이나 packaged variable에 대한 reference를
    의미합니다.
    Side effect는 query의 parallelization을 제한할 수 있는데, 이유는
    order-dependent한 결과(indeterminate result)나 user session간에 지속적인
    값을 유지(not allowed)하는 package state가 요구되는 경우가 발생하기 때문입
    니다.
    그러므로, 아래에 기술되는 사항은 sql expression에서 call되는 stored
    function에 적용되어야 합니다.
    1. Function은 database table을 modify해서는 안된다.
    (insert, update, delete statement를 사용할 수 없다.)
    2. Remote나 parallelized function은 packaged variable의 값을 읽거나
    쓸 수(read or write) 없다.
    3. Select, values, set 절에서 call되는 function만이 packaged variable의
    값을 write할 수 있다.
    4. Function은 앞에 기술된 rules를 어기는 또 다른 subprogram을 call할 수 없다.
    마찬가지로 앞에 기술된 rule을 어기는 view를 reference할 수 없습니다.
    (Oracle은 view에 대한 reference를 function call을 포함하는 stored SELECT
    operation 으로 대체합니다.)
    Standalone function에 대하여 oracle은 function body를 checking함으로써,
    이러한 rule이 적용되도록 합니다.
    그러나, package에 대해서는 packaged function body는 hidden이 되며,
    package specification만이 visible하기 때문에, specification 부분에
    pragma(compiler directive) RESTRICT_REFERENCES를 기술하여야 합니다.
    Pragma는 pl/sql compiler에게 database table이나 packaged variable에
    대하여 read/write access를 하지 않는다는 것을 기술합니다.
    Function body를 compile하는 도중 pragma에 위반되는 내용이 있다면,
    compilation error가 발생합니다.
    Calling Packaged Functions
    Sql expression에서 packaged function을 call하기 위해서는, package
    specification에서 pragma RESTRICT_REFERENCES를 기술함으로써 purity level을
    선언하여야 합니다.
    Pragma는 function declaration 이후에 기술되어야 하는 사항이며, 주어진
    function에 대하여 단지 한 pragma만이 기술될 수 있습니다.
    Pragma RESTRICT_REFERENCES를 기술하는 syntax는 아래와 같습니다.
    PRAGMA RESTRICT_REFERENCES
    (function_name, WNDS [, WNPS] [, RNDS] [,RNPS]);
    WNDS means "writes no database state" (does not modify db tables)
    WNPS means "writes no package state" (does not change the values of
    packaged variables)
    RNDS means "reads no database state" (does not query database tables)
    RNPS means "reads no package state" (does not reference the values of
    packaged variables)
    어떤 순서로든 기술된 argument를 passing할 수 있으며, WNDS는 반드시
    pass되어야 합니다.
    아래의 예는 maximum purity level을 선언한 packaged function이며,
    database나 package state에 대하여 read나 write를 전혀 수행하지 않는
    function입니다.
    CREATE PACKAGE finance AS -- package specification
    FUNCTION compound
         (years IN NUMBER,
         amount IN NUMBER,
         rate IN NUMBER )
    RETURN NUMBER;
    PRAGMA RESTRICT_REFERENCES(compound, WNDS, WNPS, RNDS, RNPS);
    END finance;
    CREATE PACKAGE BODY finance AS -- package body
    FUNCTION compound
         (years IN NUMBER,
         amount IN NUMBER,
         rate IN NUMBER)
    RETURN NUMBER IS
    BEGIN
    RETURN amount * POWER((rate/100) + 1, years);
    END compound;
    -- no pragma in package body
    END finance;
    이후에 pl/sql block에서 compound function을 call하는 경우에는 아래와
    같이 기술될 수 있습니다.
    BEGIN
    SELECT finance.compound(yrs, amt, rte) -- function call
    INTO interest FROM accounts WHERE acctno = acct_id;
    Package는 initialization part를 가질 수 있으며, 이는 package body에는
    hidden됩니다.
    일반적으로 initialization part는 public variable에 대한 initialize
    statement를 기술하게 되며, 아래의 예에서는 prime_rate 이라는 public
    variable에 대한 예가 기술되어 있습니다.
    CREATE PACKAGE loans AS
         prime_rate REAL; -- public packaged variable
    END loans;
    CREATE PACKAGE BODY loans AS
    BEGIN     -- initialization part
         SELECT prime INTO prime_rate FROM rates;
    END loans;
    Initialization code는 package가 처음 reference되는 경우에 단지 한번만
    수행이 되며, 자신의 것이 아닌 database state나 package state를 read나
    write를 하게 되면, side effect의 원인이 될 수 있습니다. 더 나아가
    package를 reference하는 stored function은 indirect하게 side effect를
    발생시킬 수 있습니다. 그러므로, pragma RESTRICT_REFERENCES를 사용하여
    initialization code에 대한 purity level을 명시적으로 선언을 하거나
    암시해줄 수 있어야 합니다.
    Initialization code에 대한 Purity level을 선언하기 위하여, pragma를
    사용하여 작업을 하실 수 있으며, function name을 package name으로
    대체하여 기술하시면 됩니다.
    Package specification 부분에 기술되는 pragma는 다른 user들에게도
    open되어 있는 것이기 때문에, package를 reference 하는 user들은
    restriction에 대한 사항을 보게 되며, 해당하는 제약 사항을 따르게 됩니다.
    사용되는 syntax는 다음과 같습니다.
    PRAGMA RESTRICT_REFERENCES (
         package_name, WNDS [, WNPS] [, RNDS] [, RNPS]);
    Argument의 의미는 앞에서 기술된 사항과 동일합니다.
    아래의 예에서 보면, initialization code는 database state에 대한 read와
    package state에 대한 write를 수행합니다. 그러나 WNPS를 선언할 수 있는데
    이는 자기 자신의 package state만을 write하는 code이기 때문에 선언이 될
    수 있습니다.
    만약 public variable prime_rate이 다른 package에 포함되어 있는
    것이라면, WNPS는 선언될 수 없습니다.
    CREATE PACKAGE loans AS
    PRAGMA RESTRICT_REFERENCES (loans, WNDS, WNPS, RNPS);
    prime_rate REAL;
    END loans;
    CREATE PACKAGE BODY loans AS
    BEGIN
    SELECT prime INTO prime_rate FROM rates;
    END loans;
    Pragma를 인식함으로 해서 oracle은 initialization code의 purity level을
    알 수 있습니다.
    ( pragma에 의하여 선언된 rule을 위배하여 생성될 수 없기 때문 )
    Avoiding Problems
    Sql expression에서 packaged function을 call하기 위해서는 pragma
    RESTRICT_REFERENCES를 사용하여 function의 purity level을 선언하여야
    합니다.
    그러나 package가 initialization part를 가지고 있다면, pl/sql
    compiler는 function에 허용되는 가장 높은 purity level을 선언하도록
    허용하지 않습니다. 결과적으로 function을 remote에서 수행하거나,
    parallel하게 또는 sql 절에서 사용할 수 없도록 제한됩니다.
    이러한 사항은 packaged function이 package initialization code보다
    purity level이 더 높은 경우에 발생하며, 기억하여야 할 것은,
    package가 처음 reference되는 때에 initialization code가 실행된다는
    사항입니다. 처음 reference하는 것이 function call인 경우,
    initialization code에 의하여 부가적인 side effect가 발생하는
    원인이 됩니다.
    이러한 사항은 initialization code가 function의 purity level보다
    낮은 경우에 발생하는 사항입니다.
    이러한 문제를 해결하기 위해서는 package initialization code를
    subprogram으로 옮겨
    주어야 합니다. 이러한 방식으로 변경하는 경우에는 package가 reference
    되는 중에 implicitly하게 code를 run하지 않고 explicitly하게 code를
    run하게 되며, 이는 packaged function에 영향을 주지 않습니다.
    Name Precedence
    database column과 argument를 가지지 않는 function이 동일한 이름을
    가진다면, sql문안에서 database column이 우선순위를 가지게 됩니다.
    CREATE TABLE stats (rand_num NUMBER, . . .);
    CREATE FUNCTION rand_num
    RETURN NUMBER AS . . . .
    위와 같은 상황에서 아래의 sql문을 사용하는 경우 column rand_num을
    참조하게 됩니다.
    SELECT rand_num INTO start_val FROM stats WHERE . . .
    이 경우 stored function rand_num을 사용하기 위해서는 schema를
    기술해주어야 합니다.
    SELECT scott.rand_num INTO start_val FROM stats WHERE . . .
    Overloading
    Pl/sql에서는 packaged function에 대해서 overload를 허용합니다.
    (standalone은 허용되지 않음) 다시 말하면 넘겨주는 argument가 갯수나,
    순서, datatype등이 다르다면, 서로 다른 function에 대해서도 동일한
    이름을 사용할 수 있습니다.
    그러나 RESTRICT_REFERENCES pragma는 단지 한 function에 대해서만
    적용이 되며, 가장 가까운 곳에 선언된 function에 대하여 적용이 됩니다.
    아래의 예에서는 두번째 function에 pragma 선언이 적용됩니다.
    CREATE PACKAGE tests AS
    FUNCTION valid ( x NUMBER)
    RETURN CHAR;
    FUNCTION valid ( x DATE)
    RETURN CHAR;
    PRAGMA RESTRICT_REFERENCES (valid, WNDS);

    You will need to investigate/resolve these errors first before making a decision
    2 .   ORA-00406: COMPATIBLE parameter needs to be 11.0.0.0.0 or greater ORA-00722: 
    1 .   ORA-00722: Feature "Virtual columns" ORA-06512: at line 31 
    1 .   ORA-00722: Feature "Virtual columns" ORA-06512: at line 43 
    1 .   ORA-06512: at line 31 
    1 .   ORA-06512: at line 43

  • Bizarre Problem: Oracle 10g disconnected

    We are facing an bizarre problem in Oracle 10G. We are trying to compile a package specification. As long as there are 10 procedures(program units) in the package it compiles successfully, As soon as we add 11th program unit(come what may a simplest of procedure declaration), It disconnects the session immediately. We asked for alert logs & there is no relevant entry in alert log file.
    Please find below the error: -
    SQL> @D:\Package_Name.sql
    ERROR:
    ORA-03114: not connected to ORACLE
    create or replace PACKAGE PACKAGE_NAME
    ERROR at line 1:
    ORA-03135: connection lost contact
    Elapsed: 00:00:18.90
    ERROR:
    ORA-03114: not connected to ORACLE
    Elapsed: 00:00:00.00
    No errors.
    SQL>
    Please Help :-(

    create or replace PACKAGE SCHEMA_NAME.PACKAGE_NAME
    IS
    -- declare public types and/or object desriptions
    TYPE t_str_list IS TABLE OF varchar2(4000)
    index by binary_integer;
    TYPE rs_type IS REF CURSOR;
    global_pkg_name varchar2(30) := 'PACKAGE_NAME';
    -- get_formulations_list
    function GFL (p_request_id number)
    return varchar2
    PRAGMA RESTRICT_REFERENCES (GFL, WNDS);
    -- Read recordsets for Objects from database
    -- Getters for Record Sets (1. Lookup Tables)
    -- 1. Get_Countries -- + + +
    -- 2. Get_l_numbers -- + + +
    -- 3. Get_mk_numbers -- + + +
    -- 4. Get_licences -- + + +
    -- 5. Get_formulations -- + + +
    -- 6. Get_request_x_frm -- + + +
    -- 7. Get_generic_names -- + + +
    -- 8. Get_global_tm -- + + +
    -- 9. Get_local_tm -- + + +
    -- 10. Get_requests -- + + +
    -- 11. Read_request_data -- + + +
    -- 12. Get_Users -- + + +
    -- 13. Get_User_Roles -- + + +
    -- 14. Read_user_data -- + + +
    -- Internal functions
    -- 1. Get_User_Type -- +
    -- Read Hierarchies for Objects from database
    -- 1. Get_Country_Hier -- + + +
    -- 2. Get_l_number_Hier -- + + +
    -- 3. Get_mk_number_Hier -- + + +
    -- 4. Get_licence_Hier -- + + +
    -- 5. Get_formulation_Hier -- + + +
    -- 7. Get_generic_name_Hier -- + + +
    -- 8. Get_global_tm_Hier -- + + +
    -- 9. Get_local_tm_Hier -- + + +
    -- 10. Get_request_list -- + + +
    -- 1.1 Get_global_tm_HStr -- + + +
    -- 2.1 Get_Country_HStr -- + + +
    -- 3.1 Get_local_tm_HStr -- + + +
    -- 4.1 Get_l_number_HStr -- + + +
    -- 5.1 Get_mk_number_HStr -- + + +
    -- 6.1 Get_licence_HStr -- + - -
    -- 7.1 Get_formulation_HStr -- - - -
    -- 8.1 Get_generic_name_HStr -- - - -
    -- 1. Get_Countries
    -- Record set Structure
    -- country_id
    -- country_name
    -- is_active
    -- role_id (for non HQ users)
    PROCEDURE GC ( p_user_id varchar2
    , p_is_active CHAR DEFAULT 'Y'
    , r_rs out rs_type )
    -- 2. Get_l_numbers
    -- Record set Structure
    -- l_number_id
    -- l_number_desc
    -- is_active
    PROCEDURE GIN ( p_user_id varchar2
    , p_is_active CHAR DEFAULT 'Y'
    , r_rs out rs_type )
    -- 3. Get_mk_numbers
    -- Record set Structure
    -- mk_number_id
    -- mk_number_desc
    -- is_active
    PROCEDURE GMN ( p_user_id varchar2
    , p_is_active CHAR DEFAULT 'Y'
    , r_rs out rs_type )
    -- 4. Get_licences
    -- Record set Structure
    -- licesnce_id
    -- licesnce_name
    -- licesnce_abrv
    -- is_active
    PROCEDURE GL ( p_user_id varchar2
    , p_is_active CHAR DEFAULT 'Y'
    , r_rs out rs_type )
    -- 5. Get_formulations
    -- Record set Structure
    -- formulation_id
    -- formulation_name
    -- is_active
    PROCEDURE GF ( p_user_id varchar2
    , p_is_active CHAR DEFAULT 'Y'
    , r_rs out rs_type )
    -- 6. Get_request_x_frm
    -- Record set Structure
    -- formulation_id
    -- formulation_name
    -- request_id
    PROCEDURE GRX ( p_user_id varchar2
    , p_request_id number
    , r_rs out rs_type )
    -- 7. Get_generic_names
    -- Record set Structure
    -- generic_name_id
    -- generic_name_text
    -- l_number_id
    -- l_number_desc
    -- mk_number_id
    -- mk_number_desc
    -- is_active
    PROCEDURE GGN ( p_user_id varchar2
    , p_is_active CHAR DEFAULT 'Y'
    , r_rs out rs_type )
    -- 8. Get_global_tm
    -- Record set Structure
    -- gtm_name_id
    -- gtm_name_text
    -- generic_name_id
    -- generic_name_text
    -- l_number_id
    -- l_number_desc
    -- mk_number_id
    -- mk_number_desc
    -- is_active
    PROCEDURE GGT ( p_user_id varchar2
    , p_is_active char default 'Y'
    , r_rs out rs_type )
    -- 9. Get_local_tm
    -- Record set Structure
    -- ltm_name_id
    -- ltm_name_text
    -- request_id
    -- country_id
    -- country_name
    -- generic_name_id
    -- generic_name_text
    -- is_default
    -- is_active
    PROCEDURE GLT ( p_user_id varchar2
    , p_country_id number DEFAULT 0
    , p_is_default CHAR DEFAULT '*'
    , p_is_active CHAR DEFAULT 'Y'
    , r_rs out rs_type )
    -- 10. Get_requests
    -- Record set Structure
    -- request_id
    -- gtm_name_id
    -- ltm_name_id
    -- licesnce_id
    -- requestor_isid
    -- hq_isid
    -- request_status_id
    -- lanch_date
    -- change_status_date
    -- country_name
    -- gtm_name_text
    -- ltm_name_text
    -- generic_name_text
    -- licesnce_name
    -- licesnce_abrv
    -- l_number_id
    -- l_number_desc
    -- mk_number_id
    -- mk_number_desc
    -- is_active
    PROCEDURE GR ( p_user_id varchar2
    , p_country_id number DEFAULT 0
    , p_global_tm number DEFAULT 0
    , p_status number DEFAULT 0
    , p_is_active CHAR DEFAULT 'Y'
    , r_rs out rs_type )
    -- 11. Read_request_data
    -- Record set Structure
    -- request_id
    -- gtm_name_id
    -- ltm_name_id
    -- licesnce_id
    -- requestor_isid
    -- hq_isid
    -- request_status_id
    -- lanch_date
    -- change_status_date
    -- country_name
    -- gtm_name_text
    -- ltm_name_text
    -- generic_name_text
    -- licesnce_name
    -- licesnce_abrv
    -- l_number_id
    -- l_number_desc
    -- mk_number_id
    -- mk_number_desc
    -- is_active
    PROCEDURE RRD ( p_user_id varchar2
    , p_request_id number
    , r_rs out rs_type )
    END PACKAGE_NAME;
    /

  • Compatibility problem between 8.0.5 and 8.1.7

    We have a system that runs on 8.0.5 which we wish to move to 8.1.7 or 9i, however on both versions we experience problems with PRAGMA's
    Given the package spec:
    PACKAGE test IS
    FUNCTION error_text (I_ERROR_NO IN INTEGER) RETURN VARCHAR2;
    PRAGMA RESTRICT_REFERENCES (error_text, WNPS, WNDS);
    and the function 'error_text' :
    FUNCTION error_text(I_ERROR_NO IN INTEGER)RETURN VARCHAR2
    IS
    -- PL/SQL Block
    CURSOR c_err
    ( cp_error_no INTEGER
    ) IS
    SELECT description
    FROM ukl_error
    WHERE err_code = TO_CHAR(cp_error_no,'FM0000')
    r_err c_err%ROWTYPE;
    BEGIN
    OPEN c_err( i_error_no );
    FETCH c_err INTO r_err;
    CLOSE c_err;
    RETURN( r_err.description );
    END error_text;
    On compilation, it spits it out saying 'function error_text violates it's own pragma'
    By removing the pragma, and running the function, the session hangs and then eventually times out.
    This code works on versions 7.x, and up to 8.0.5 - are there any known issues for 8.1.x or higher which would explain why this doesn't work?
    Thanks

    No problems under 8.1.7.4 (only object name changes):
    sql>create or replace package test
      2  is
      3    function error_text (i_error_no in integer)
      4      return varchar2;
      5  end;
      6  /
    Package created.
    sql>create or replace package body test
      2  is
      3    function error_text(i_error_no in integer)
      4      return varchar2
      5    is
      6      cursor c_err(cp_error_no integer)
      7        is
      8        select object_name
      9          from user_objects
    10         where object_id = cp_error_no;
    11      r_err c_err%rowtype;
    12    begin
    13      open c_err(i_error_no);
    14      fetch c_err into r_err;
    15      close c_err;
    16      return(r_err.object_name);
    17    end error_text;
    18  end;
    19  /
    Package body created.
    sql>select test.error_text(13760) from dual;
    TEST.ERROR_TEXT(13760)
    EMP
    1 row selected.I would, however, recommend typing the parameter and return value to the columns and using an implicit instead of the explicit cursor.
    sql>create or replace package test
      2  is
      3    function error_text (i_error_no in user_objects.object_id%type)
      4      return user_objects.object_name%type;
      5  end;
      6  /
    Package created.
    sql>create or replace package body test
      2  is
      3    function error_text(i_error_no in user_objects.object_id%type)
      4      return user_objects.object_name%type
      5    is
      6      v_return  user_objects.object_name%type;
      7    begin
      8      select object_name
      9        into v_return
    10        from user_objects
    11       where object_id = i_error_no;
    12 
    13      return(v_return);
    14    end error_text;
    15  end;
    16  /
    Package body created.
    sql>select test.error_text(13760) from dual;
    TEST.ERROR_TEXT(13760)
    EMP
    1 row selected.

  • Pragma associated with the package BOMPCFGI

    Hi All,
    Oracle standard functionality creates the standard star part number with default sequence number appended
    But our Client requires the Star Part Number to be customised.As a result Oracle configurator is going to be implemented for Compression Product line.
    Inorder to do the technical changes for the same, I have to modify the package BOMPCFGI . It has a function called user_item_number
    As per the requirement, I need to call another function CTO_CUSTOM_CONFIG_NUMBER.user_item_number from the function BOMPCFGI.user_item_number
    But I'm not able to do it as there is a PRAGMA associated with the package BOMPCFGI which is as follows:
    PRAGMA RESTRICT_REFERENCES(user_item_number, WNDS);
    Please advise whether I can comment it or do I need to raise an SR with Oracle  for the same.

    Dear Sir,
             I am fine.
             Actually I can see the Maintenance Packages of the tasklist by navigating through Maintenance Order but my problem is I want to Print (create shop paper) the operation and the Maintenance package associated with the operation. Also when I check the operations in the tasklist there are 250 to 300 opertions with different frequency so it is difficult to find.
            Is there any solution whatever the operations copied in the Maintenance Order from the tasklist I can see the MAintenance Package.
    With best regards,
    Narendra

  • Select object member function problem

    I use RDBMS 10.2.0.1.0
    SQL> CREATE OR REPLACE TYPE foo AS OBJECT
    2 (
    3 dummy NUMBER,
    4 MEMBER FUNCTION to_str RETURN VARCHAR2,
    5 PRAGMA RESTRICT_REFERENCES(to_str, WNDS)
    6 );
    7 /
    Type created
    SQL>
    SQL> CREATE OR REPLACE TYPE BODY foo
    2 IS
    3 MEMBER FUNCTION to_str RETURN VARCHAR2
    4 IS
    5 BEGIN
    6 RETURN 'test';
    7 END;
    8 END;
    9 /
    Type body created
    SQL>
    SQL> CREATE TABLE test_foo
    2 (foo_field foo);
    Table created
    SQL>
    SQL> INSERT INTO test_foo
    2 VALUES (foo(1));
    1 row inserted
    SQL> select * from test_foo;
    FOO_FIELD
    <Object>
    SQL> SELECT foo_field.to_str FROM test_foo;
    SELECT foo_field.to_str FROM test_foo
    ORA-00904: "FOO_FIELD"."TO_STR": invalid identifier
    Where is a problem? What's wrong?

    SELECT t.foo_field.to_str() FROM test_foo t;Best regards
    Maxim

  • Problem in designer 6i with translated version of wsglm package

    By developing WEB-PL/SQL app
    after replacing wsglm package CGENW61\CVWETC\wsglm.pks,
    by CGENW61\CVWETC\wsglmsk.pks in my PL/SQL Toolkit schema,
    wsgl package compiles with errors,
    PLS-00452: Subprogram *** violates its associated pragma,
    what to do to run it correctly?
    Thanks a lot.

    Hi Abraham,
    On Metalink if found DocID: 119560.1:
    . fact: Oracle Designer 6.5.40
    . fact: CASEWSG - PL/SQL Web Generator
    . symptom: Installation of Designer Web PL-SQL Generator fails
    . symptom: PLS-00452: Subprogram 'BUILDWHERE' violates its associated pragma
    . symptom: Package body WSGL is invalid
    . symptom: Package body WSGJSL is invalid
    . symptom: This error does not occur when using the standard English WSGLM.PKS package.
    . cause: <Bug:1613863>
    - Missing PRAGMA RESTRICT_REFERENCES in WSGLM<lang>.pks
    fix:
    Find the file WSGLM<lang>.pks (e.g. WSGLME.pks in case of Spanish, WSGLMHU.pks in case of Hungarian language) in <ORACLE_HOME>\CGENW60\CVWETC directory and modify it by adding the following line at the bottom (before the 'END;' statement) :
    PRAGMA RESTRICT_REFERENCES(WSGLM, WNDS, WNPS, RNDS, RNPS);
    Please make sure there is always a safety copy of the original WSGLME.PKS in case a rollback is needed.
    Regards,
    Marcel

  • Function 'myfunc' may not be used in SQL Options

    <p>
    Hello,
    I have created a simple function in a packege for use in an update statement. The function is
    FUNCTION myfnc(p1 IN t1.c1%TYPE)
    RETURN VARCHAR2
    IS
    BEGIN
    IF p1 = 3 THEN
    RETURN 'A';
    ELSE
    RETURN 'B';
    END IF;
    END myfnc;
    I use it in a procedure which exists in the same package as the function as follows
    Update t1
    set c1 = myfnc(c2);
    I am getting the compliation error Function 'myfunc' may not be used in SQL.
    There is no db manipulation going on and I have tried using
    PRAGMA RESTRICT_REFERENCES (myfnc, WNDS, WNPS, RNDS, RNPS);
    but to no avail.
    One other thing is that I thought this was compiling OK but then I decided to put the function in the package specification so I could unit test it using a db call. Now if I drop and recreate the package without the declaration in the specification the compile error still occurs. Perhaps that's my mind playing tricks but maybe there is something here I am not aware of.
    Any suggestions?
    </p>

    Hi,
    You found the solution.
    Although it's allowed to say
    Update     t1
    set     c1 = local_var;in a package, where local_var is not defined outside of the procedure, let alone the package, and
    although it's legal to say:
    local_var = myfnc (some_other_var); inside the package where myfnc is a private function (included in the package body, but not in the package header), still
    it is not legal to say:
    Update     t1
    set     c1 = myfnc (c2); If there is a problem with putting myfnc in the package header (for example, you don't want people calling it directly, for some reason), you can make it a stand-alone function, like Someoneelse did, or put in a different package, and give the owner of your first package (and no one else) EXECUTE privileges on it.
    As William pointed out, if myfnc is really this simple, you might not need a function at all.

  • Using named constants in SQL rather than magic numbers

    We are running Oracle 7.3.4. In our system we have a number of
    tables that just store static data. For example, we have a table
    that stores the different types of statuses that a docket can
    have:
    Docket_Status: docket_status_id NUMBER(8), description VARCHAR
    (100)
    It has a small number of records as follows:
    docket_status_id description
    1 New
    2 Issued
    3 Completed
    4 Finalised
    and so on.
    When we want to select all of the dockets with a status of
    "New", we could do something like:
    select d.*
    from docket d
    where d.docket_status_id = 1
    However, this SQL statement is not particularly readable or
    maintainable since the "1" is meaningless unless you have
    memorised the id fields for the docket.
    So we defined constants for each of the static data tables, in a
    package of their own:
    PACKAGE DOCKET_STATUS_PL IS
    New_Id CONSTANT Docket_Status.Docket_Status_Id%TYPE := 1;
    Issued_Id CONSTANT Docket_Status.Docket_Status_Id%TYPE := 2;
    Completed_Id CONSTANT Docket_Status.Docket_Status_Id%TYPE := 3;
    and so on.
    Ideally you could directly reference these values in SQL as
    follows:
    select d.*
    from docket d
    where d.docket_status_id = Docket_Status_Pl.New_Id
    But SQL does not let allow this - an invalid column error is
    raised when this is parsed.
    So the package must then be changed to have functions pass back
    each of the constants.
    PACKAGE DOCKET_STATUS_PL IS
    FUNCTION New_Id RETURN NUMBER;
    PRAGMA RESTRICT_REFERENCES(New_Id, WNDS, WNPS);
    FUNCTION Issued_Id RETURN NUMBER;
    PRAGMA RESTRICT_REFERENCES(Issued_Id, WNDS, WNPS);
    FUNCTION Completed_Id RETURN NUMBER;
    PRAGMA RESTRICT_REFERENCES(Completed_Id, WNDS, WNPS);
    and so on.
    PACKAGE BODY DOCKET_STATUS_PL IS
    N_New_Id CONSTANT Docket_Status.Docket_Status_Id%TYPE := 1;
    N_Issued_Id CONSTANT Docket_Status.Docket_Status_Id%TYPE := 2;
    N_Completed_Id CONSTANT Docket_Status.Docket_Status_Id%TYPE := 3;
    FUNCTION New_Id RETURN NUMBER IS
    BEGIN
    RETURN N_New_Id;
    END;
    FUNCTION Issued_Id RETURN NUMBER IS
    BEGIN
    RETURN N_Issued_Id;
    END;
    and so on.
    Once these functions have been defined in the packages, they can
    be called in a SQL statement as follows:
    select d.*
    from docket d
    where d.docket_status_id = Docket_Status_Pl.New_Id
    This makes the SQL statement a lot more readable, but has the
    unfortunate by-product of having the Docket_Status_Pl.New_Id
    function called for every row in the docket table. Although it
    is very quick to call, once there are thousands of records in
    the docket table this can add up to a lot of extra
    time/processing.
    An alternative is to select the constant from the dual table as
    follows:
    select d.*
    from docket d
    where d.docket_status_id = (select Docket_Status_Pl.New_Id from
    dual)
    This works but is not really an ideal solution, since it
    decreases the readability of the SQL statement.
    Does anyone know of alternatives to this approach? Ideally
    package constants could be referenced from SQL, but this does
    not work under our version of Oracle. Do any later versions
    support this ability?
    Any suggestions would be much appreciated.
    null

    I don't understand why you cannot just select on the description
    column if you don't no the id. If speed is a problem create a
    unique not null index on the column description. Technically
    this should have been done since your id column is a is not
    the "REAL" primary key.
    Having said that you could also create a view on top of this
    table which mimics your package.
    CREATE OR REPLACE VIEW name_of_view AS
    SELECT DECODE(docket_status_id, 1, 'New_id',
    2, 'Issued_Id',
    3, 'Completed_Id',
    'OTHER') alt_description,
    docket_status_id description
    FROM name_of_table
    then select * from name_of_view
    where alt_description = 'New_id'
    Geoff Hardy (guest) wrote:
    : We are running Oracle 7.3.4. In our system we have a number of
    : tables that just store static data. For example, we have a
    table
    : that stores the different types of statuses that a docket can
    : have:
    : Docket_Status: docket_status_id NUMBER(8), description VARCHAR
    : (100)
    : It has a small number of records as follows:
    : docket_status_id description
    : 1 New
    : 2 Issued
    : 3 Completed
    : 4 Finalised
    : and so on.
    : When we want to select all of the dockets with a status of
    : "New", we could do something like:
    : select d.*
    : from docket d
    : where d.docket_status_id = 1
    : However, this SQL statement is not particularly readable or
    : maintainable since the "1" is meaningless unless you have
    : memorised the id fields for the docket.
    : So we defined constants for each of the static data tables, in
    a
    : package of their own:
    : PACKAGE DOCKET_STATUS_PL IS
    : New_Id CONSTANT Docket_Status.Docket_Status_Id%TYPE := 1;
    : Issued_Id CONSTANT Docket_Status.Docket_Status_Id%TYPE := 2;
    : Completed_Id CONSTANT Docket_Status.Docket_Status_Id%TYPE := 3;
    : and so on.
    : Ideally you could directly reference these values in SQL as
    : follows:
    : select d.*
    : from docket d
    : where d.docket_status_id = Docket_Status_Pl.New_Id
    : But SQL does not let allow this - an invalid column error is
    : raised when this is parsed.
    : So the package must then be changed to have functions pass back
    : each of the constants.
    : PACKAGE DOCKET_STATUS_PL IS
    : FUNCTION New_Id RETURN NUMBER;
    : PRAGMA RESTRICT_REFERENCES(New_Id, WNDS, WNPS);
    : FUNCTION Issued_Id RETURN NUMBER;
    : PRAGMA RESTRICT_REFERENCES(Issued_Id, WNDS, WNPS);
    : FUNCTION Completed_Id RETURN NUMBER;
    : PRAGMA RESTRICT_REFERENCES(Completed_Id, WNDS, WNPS);
    : and so on.
    : PACKAGE BODY DOCKET_STATUS_PL IS
    : N_New_Id CONSTANT Docket_Status.Docket_Status_Id%TYPE :=
    1;
    : N_Issued_Id CONSTANT Docket_Status.Docket_Status_Id%TYPE :=
    2;
    : N_Completed_Id CONSTANT Docket_Status.Docket_Status_Id%TYPE :=
    3;
    : FUNCTION New_Id RETURN NUMBER IS
    : BEGIN
    : RETURN N_New_Id;
    : END;
    : FUNCTION Issued_Id RETURN NUMBER IS
    : BEGIN
    : RETURN N_Issued_Id;
    : END;
    : and so on.
    : Once these functions have been defined in the packages, they
    can
    : be called in a SQL statement as follows:
    : select d.*
    : from docket d
    : where d.docket_status_id = Docket_Status_Pl.New_Id
    : This makes the SQL statement a lot more readable, but has the
    : unfortunate by-product of having the Docket_Status_Pl.New_Id
    : function called for every row in the docket table. Although it
    : is very quick to call, once there are thousands of records in
    : the docket table this can add up to a lot of extra
    : time/processing.
    : An alternative is to select the constant from the dual table as
    : follows:
    : select d.*
    : from docket d
    : where d.docket_status_id = (select Docket_Status_Pl.New_Id
    from
    : dual)
    : This works but is not really an ideal solution, since it
    : decreases the readability of the SQL statement.
    : Does anyone know of alternatives to this approach? Ideally
    : package constants could be referenced from SQL, but this does
    : not work under our version of Oracle. Do any later versions
    : support this ability?
    : Any suggestions would be much appreciated.
    null

  • In Ref cursor, user defined functions give "invalid column" error in EJB.

    Hello,
    I have written PL/SQL stored procedures/functions in Oracle 8i. They return the result set as a ref cursor.
    These procedures are accessed by EJB (weblogic) using Type 4 (100% Java) JDBC Driver.
    My problem is - if I use a user defined function to fetch a value in the select statement of the reference cursor, the EJB gives an error msg - invalid column name.
    If instead of using the function I get the value directly from the table, it works fine. Refer the code below :
    //In the PL/SQL function -
    //instead of writing :
    Open rc for
    Select empcode, empname
    from emp ;
    //If I write :
    Open rc for
    Select empcode, mypack.getempname(empcode)
    from emp ;
    //getempname(empcode) is a function in
    //in a package named 'mypack'
    //and returns name for empcode.
    //The java code gives error
    //error : invalid column name
    //While both are working fine and
    //returning currect result in SQL Navigator.
    Help me solve this mystery ?
    Thanks in advance.
    Swati.
    null

    Hi:
    When use inline Function to simplify the SQL statements, there is one thing that one should conside--Purity Level.
    if you create standalone stored pl/sql function. Oracle implicitly determines the PURITY level during compilation of the stored objects or at execution of an anonymous pl/sql block.
    if you implement Package inline Function( in your case),unlike standalone stored pl/sql functions, the PL?SQL Engine does not determine the purity level of package functions. Therefore, you must explicity assign the correct purity levels for the function to be called inline.
    the code like:
    create or replace package mypack is
    function getempname(empcode emp%empid%type)
    return varchar2;
    PRAGMA RESTRICT_REFERENCES(getempname,WNDS,WNPS,RNPS);
    end mypack;
    I think it can solve your problem if you use enough "pure"to be called inline function. Or you can create the standalone function to do it.
    good luck!
    Yali
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Swati Agrawal ([email protected]):
    Hello,
    I have written PL/SQL stored procedures/functions in Oracle 8i. They return the result set as a ref cursor.
    These procedures are accessed by EJB (weblogic) using Type 4 (100% Java) JDBC Driver.
    My problem is - if I use a user defined function to fetch a value in the select statement of the reference cursor, the EJB gives an error msg - invalid column name.
    If instead of using the function I get the value directly from the table, it works fine. Refer the code below :
    //In the PL/SQL function -
    //instead of writing :
    Open rc for
    Select empcode, empname
    from emp ;
    //If I write :
    Open rc for
    Select empcode, mypack.getempname(empcode)
    from emp ;
    //getempname(empcode) is a function in
    //in a package named 'mypack'
    //and returns name for empcode.
    //The java code gives error
    //error : invalid column name
    //While both are working fine and
    //returning currect result in SQL Navigator.
    Help me solve this mystery ?
    Thanks in advance.
    Swati.
    <HR></BLOCKQUOTE>
    null

  • How to order by a column not on the base table?

    Best explained by example:
    I have 1 block, base table is SALE. I would like to sort this block by PROD_DESCRIPTION which is not on SALE. I only have PROD_CODE (the primary key of PRODUCT which contains PROD_DESCRIPTION)
    I am not running Enterprise Edition so I cannot create a view and use Instead-of triggers.
    I would rather not have to re-write all my triggers because I want the default base table behaviour that forms provides.
    Any ideas?
    Cheers,
    Tim.

    Hey tim,
    I also had a similar problem.
    You need to create a function in the database with an associated
    pragma to specify the level of purity of the function
    WNDS (write no database state)
    WNPS (write no package state)
    PRAGMA RESTRICT_REFERENCES(fn_get_dname, WNDS, WNPS);
    Function fn_get_dname (p_empno in number) return varchar2 is
    v_dept_name varchar2(40);
    begin
    select dname into v_dept_name
    from dept, emp
    where dept.deptno = emp.deptno
    and emp.emp_no = p_emp_no;
    return v_dept_name;
    end;
    order by in a block based on the emp table (assuming you want a list of employees by department name)
    order by fn_get_dname(empno), empno
    Hope that will help you to solve your problem.
    Thanks
    Pranati

  • Error - remote stored procedure includes in a function

    Hi,
    I have a stored procedure, it runs properly
    ecos.GetCustTier@BSCSDEV in PL/SQL
    But after included into function F_GETCUSTTIER, it comes error.
    SQL> select f_getcusttier(585510,'20020808') from dual
    ORA-06571: Function F_GETCUSTTIER does not guarantee not to update database
    [Function F_GETCUSTTIER]
    create or replace FUNCTION f_getcusttier(
    Begin
    ecos.GetCustTier@BSCSDEV(i_customer_id, i_at_date, o_seqno, o_custcode, o_tier_id, o_tier_des, o_join_date, o_join_reason,
    o_renewal_date, o_next_review_date, o_last_review_amt_no, o_exit_date, o_exit_reason,
    o_input_by, o_input_date, o_update_by, o_update_date, o_expiry_date, o_next_job_review_date,
    o_status_id, o_return_code);
    RETURN o_tier_id;
    I also try to create a package for this function
    CREATE OR REPLACE PACKAGE abc AS
    FUNCTION f_getcusttier(i_customer_id number, i_at_date varchar2) RETURN NUMBER;
    PRAGMA RESTRICT_REFERENCES(f_getcusttier, WNDS);
    END abc;
    CREATE OR REPLACE PACKAGE BODY bwan AS
    FUNCTION f_getcusttier(
    i_customer_id in number,
    i_at_date in varchar2
    Begin
    ecos.GetCustTier@BSCSDEV(i_customer_id, i_at_date, o_seqno, o_custcode, o_tier_id, o_tier_des, o_join_date, o_join_reason,
    o_renewal_date, o_next_review_date, o_last_review_amt_no, o_exit_date, o_exit_reason,
    o_input_by, o_input_date, o_update_by, o_update_date, o_expiry_date, o_next_job_review_date,
    o_status_id, o_return_code);
    RETURN o_tier_id;
    But with Warning: Package Body created with compilation errors.
    2/1 PLS-00452: Subprogram 'F_GETCUSTTIER' violates its associated
    pragma
    How can I fixed it? Can function pack with remote stored procedure?
    DB version: 8.0.4.4.0
    I know that this problem is resolved in Release 8.1, is it no solution for release 8.0.4.4.0?

    First of all, please do not post three separate threads for the one problem. It simply clutters up the forum for the rest of us.
    Prior to 8i you need to explicitly guarantee that your function does not write to the database. You do this with the RESTRICT_REFERENCES pragma:
    CREATE PACKAGE yr_package AS  -- package specification
       FUNCTION whatever
             (pn IN NUMBER) RETURN NUMBER;
       PRAGMA RESTRICT_REFERENCES (whatever, WNDS);
    END yr_package;The following link goes to a page of helpful stuff assembeled by some of use regulars:Re: How to attach a java bean in forms6i
    It includes jumps to the Oracle online documentation. You may find the Application Developer's Guide - Fundamentals an instructive read.
    Regards, APC

Maybe you are looking for