Positional Notation vs Named Notation

Hello,
Can we use named notation while calling a stored procedure in Oracle 9i SQL*PLUS?
Can we use named notation while calling a stored function from a SQL statement in Oracle 9i SQL*PLUS?
Thanks much,
Manoja

Easy enough to test.
SQL> CREATE PROCEDURE p (p_one IN VARCHAR2 DEFAULT 'One',
  2                      p_two IN VARCHAR2 DEFAULT 'TWO') AS
  3  BEGIN
  4     DBMS_OUTPUT.Put_Line ('p_one is '||p_one||' and p_two is '||p_two);
  5  END;
  6  /
Procedure created.
SQL> exec p(p_one => 'Not one');
p_one is Not one and p_two is TWO
PL/SQL procedure successfully completed.
SQL> exec p(p_two => 'Not two');
p_one is One and p_two is Not two
PL/SQL procedure successfully completed.
SQL> CREATE FUNCTION f (p_one IN VARCHAR2 DEFAULT NULL,
  2                     p_two IN VARCHAR2 DEFAULT NULL) RETURN VARCHAR2 AS
  3  BEGIN
  4     IF p_one IS NULL THEN
  5        RETURN p_two;
  6     ELSIf p_two IS NULL THEN
  7        RETURN p_one;
  8     END IF;
  9  END;
10  /
Function created.
SQL> SELECT f(p_one => 'One') from dual;
SELECT f(p_one => 'One') from dual
ERROR at line 1:
ORA-00907: missing right parenthesis
SQL> SELECT f(p_one => NULL, p_two => 'Two') FROM dual;
SELECT f(p_one => NULL, p_two => 'Two') FROM dual
ERROR at line 1:
ORA-00907: missing right parenthesis
SQL> SELECT f(NULL, 'Two') FROM dual;
F(NULL,'TWO')
TwoSo, yes and no.
TTFN
John

Similar Messages

  • Named Notation Vs Positional Notation...

    Hi,
    There are 2 ways of passing parameter to the procedure in pl,sql .
    1. Named Notation
    2, Positional Notation,
    my question is can the use of positional notation cause performance degradation ?
    or which one is better named or positional notation ?
    kindly give me your fb
    Regards
    nic

    Thanks elic,
    and can it be other way round, can named notation cause performance delay,,,
    create or replace procedure proce1(para 1 number default null,
                                        para 2 number default null,
                                        para 3 number default null
                                        -- and so on) is
    begin
    null;
    end;
    proce1(para 1 -> 1, para 2 -> 2, para 3 -> 3);
    proce 1(para 2 -> 2);
    proce1(para 3 -> 1);Message was edited by:
    Nicloei W

  • Positional vs. named parameter passing

    Is named parameter passing always better than positional when calling a PL/SQL stored procedure? What are the benefits and pitfalls of each method. Are there instances where you prefer one over the other?

    Hi Roger,
    I personally prefer named notation due to its much enhanced clarity. It greatly helps a subsequent developer by not forcing him/her to look up the spec of the procedure or function each time they see it referenced in the code which calls it (I have a terrible short-term memory - so this is particularly frustrating to me).
    Additionally, if some whacko comes by and changes the order (but not the names) of the parameters to the referenced procedure or function - named notation protects you from having to change your code - with positional notation - you MUST change your code.
    Of course, named notation is not supported in normal SQL which calls a function, only positional is. But for PL/SQL I say use named notation all the way.
    I've never tested a comparison of performance, but I would take an educated guess that it is roughly equivalent (within a few microseconds) between the approaches.
    One example I think will show you the benefits of named over positional is a call to DBMS_STATS.GATHER_TABLE_STATS. This packaged procedure is used all of the time, but it has a large number of arguments. Changing a call to it can be challenging with positional notation if you don't remember the parameter order.
    Here's the named notation call:
    BEGIN
       DBMS_STATS.gather_table_stats (ownname               => 'SCOTT'
                                    , tabname               => 'EMP'
                                    , partname              => NULL
                                    , estimate_percent      => DBMS_STATS.auto_sample_size
                                    , block_sample          => FALSE
                                    , method_opt            => 'FOR ALL INDEXED COLUMNS SIZE 254'
                                    , DEGREE                => NULL
                                    , granularity           => 'ALL'
                                    , CASCADE               => TRUE
                                    , no_invalidate         => FALSE
    END;
    /Here's the positional notation call:
    BEGIN
       DBMS_STATS.gather_table_stats ('SCOTT'
                                    , 'EMP'
                                    , NULL
                                    , DBMS_STATS.auto_sample_size
                                    , FALSE
                                    , 'FOR ALL INDEXED COLUMNS SIZE 254'
                                    , NULL
                                    , 'ALL'
                                    , TRUE
                                    , FALSE
    END;
    /I strongly prefer to support code with the first example over the 2nd.
    Hope this helps...
    Message was edited by:
    PDaddy
    Message was edited by:
    PDaddy

  • Positional and named procedure

    CREATE OR REPLACE PROCEDURE
    add_dept ( p_name departments.department_name%TYPE DEFAULT ‘unknown‘, p_loc departments.location_id%TYPE DEFAULT 1700) IS
    BEGIN
    INSERT INTO departments(department_id, department_name, loclation_id) VALUES (dept_seq.NEXTVAL,p_name, p_loc);
    END add_dept;
    You created the add_dept procedure above, and you now invoke the procedure in SQL *Plus. Which four are valid invocations? (Choose four)
    A. EXECUTE add_dept(p_loc=>2500)
    B. EXECUTE add_dept( ‘Education’, 2500)
    C. EXECUTE add_dept( .2500 , p_loc =>2500)
    D. EXECUTE add_dept(p_name=> ‘Education’, 2500)
    E. EXECUTE add_dept(p_loc=>2500, p_name=> ‘Education’)
    (answer: A, B, C,E)
    Please explain how answer "C" is also correct.
    Regards
    Rajani

    CREATE OR REPLACE PROCEDURE
    add_dept ( p_name departments.department_name%TYPE
    DEFAULT ‘unknown‘, p_loc departments.location_id%TYPE
    DEFAULT 1700) IS
    BEGIN
    INSERT INTO departments(department_id,
    department_name, loclation_id) VALUES
    (dept_seq.NEXTVAL,p_name, p_loc);
    END add_dept;
    You created the add_dept procedure above, and you now
    invoke the procedure in SQL *Plus. Which four are
    valid invocations? (Choose four)
    A. EXECUTE add_dept(p_loc=>2500)
    B. EXECUTE add_dept( ‘Education’, 2500)
    C. EXECUTE add_dept( .2500 , p_loc =>2500)
    D. EXECUTE add_dept(p_name=> ‘Education’, 2500)
    E. EXECUTE add_dept(p_loc=>2500, p_name=>
    ‘Education’)
    (answer: A, B, C,E)
    Please explain how answer "C" is also correct.
    Regards
    RajaniI think Answer C is correct cause you are using positional notation as well named
    notation.
    Khurram

  • Named Parameters in Functions: Possible?

    I want to use named parameters to call PL/SQL functions using JDBC, as is best practice and necessary for default values to work. Unfortunatley all the examples I found are for procedures only. Using a positional registerOutParameter with named register / get methods on the CallableStatement does not work, obiviously.
    Is there any proper way to use named parameters with functions ? Proper does not include writing wrapper procedures nor turning functions into procedures.

    Hi Avi,
    as far as I know the return value of a PL/SQL function does not have a name, as oposed to the parameters of a PL/SQL function, which must have a name. One could argue that the return value of a function is called the same as the function itself. I have tried that option but it does not work.
    Unfortunatley the method OraclePreparedStatement.registerReturnParameter refers to something else than the return value of a PL/SQL function. Is it possible that the developers of the driver have forgotten something?

  • Native TopLink named query with named parameters

    Hello,
    Defining my metadata in native TopLink xml and using the native TopLink's Session interface I can access and successfully execute a named query using positional parameters (parameters passed to match the ?1 ?2 etc). I used for this the Session.executeQuery(String, Class, List) method e.g.
    select p from Person p where p.name = ?1
    Now, how can I get the same Session to execute named queries using named parameters? None of the Session.executeQuery methods seem suitable ... Am I missing anything here? e.g.
    select p from Person p where p.age = :age
    I can't find in Session http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/b13698/oracle/toplink/sessions/Session.html a good match for this use-case. I would expect something like:
    Session.executeQuery(String queryName, Class target, List argNames, List argValues)
    or
    Session.executeQuery(String queryName, Class target, Map argsKeyedByName)
    but can't find any good match, can anyone please enlighten me?
    Thanks in advance,
    Best regards,
    Giovanni

    Hello Chris,
    Many thanks for your response. I am sorry if I did not explain my problem properly.
    Suppose I already defined a named query in the metadata XXXProject.xml using the <opm:querying ... this JPQL named query "customFinder" already exists and would look something like:
    select p from Person p where p.firstname=:firstname and p.lastname=:lastname and p.birthdate=:birthdate
    now say you want to execute this query from the Session:
    Vector args = new Vector();
    // how do you know the order? you shouldn't know the order!
    // you know only the parameter names and that's what I mean
    // about named parameters
    // This args setup is wrong ... I need a way to specify to which
    // parameter name each argument corresponds to. In other words
    // if the named query where criteria order of parameters is modified
    // perhaps because of pruning composite keys etc you won't break the
    // existing code ...
    args.add(new Date());
    args.add("Azua");
    args.add("Giovanni");
    Session session = ...
    session.executeQuery("customFinder", Person.class, args);
    JPA supports both type of queries positional parameters and named parameters. Your explanation above is only for the first, my question refers to the later.
    I have not yet found the api for this ... though I am investigating along the lines of:
    Query query = session.getQuery("customFinder");
    and then try to assign the arguments in the same order that the parameters are defined in query or?
    Thanks in advance,
    Best regards,
    Giovanni
    Edited by: bravegag on 29.05.2009 08:06

  • Calling a stored procedure with default parameters

    Dear all,
    I am trying to call a stored procedure that has not all the parameters compulsory, and indeed, there are some I am not interested in. Therefore, I would like to call the stored procedure initializing only some of the parameters but if I miss some of them, I have an SQLException thrown. Is there any way to do that?
    Thanks
    Marie

    Hi
    One way to do it is ---
    By using Default Parameters you can miss few parameters while calling a procedure.
    =================================================================
    As the example below shows, you can initialize IN parameters to default values. That way, you can pass different numbers of actual parameters to a subprogram, accepting or overriding the default values as you please.
    Moreover, you can add new formal parameters without having to change every call to the subprogram.
    PROCEDURE create_dept (
    new_dname VARCHAR2 DEFAULT 'TEMP',
    new_loc VARCHAR2 DEFAULT 'TEMP') IS
    BEGIN
    INSERT INTO dept
    VALUES (deptno_seq.NEXTVAL, new_dname, new_loc);
    END;
    If an actual parameter is not passed, the default value of its corresponding formal parameter is used.
    Consider the following calls to create_dept:
    create_dept;
    create_dept('MARKETING');
    create_dept('MARKETING', 'NEW YORK');
    The first call passes no actual parameters, so both default values are used.
    The second call passes one actual parameter, so the default value for new_loc is used.
    The third call passes two actual parameters, so neither default value is used.
    Usually, you can use positional notation to override the default values of formal parameters.
    However, you cannot skip a formal parameter by leaving out its actual parameter.
    For example, the following call incorrectly associates the actual parameter 'NEW YORK' with the formal parameter new_dname:
    create_dept('NEW YORK'); -- incorrect
    You cannot solve the problem by leaving a placeholder for the actual parameter.
    For example, the following call is illegal:
    create_dept(, 'NEW YORK'); -- illegal
    In such cases, you must use named notation, as follows:
    create_dept(new_loc => 'NEW YORK');
    ===============================================================
    For more details refer URL http://technet.oracle.com/doc/server.804/a58236/07_subs.htm#3651
    Hope this helps
    Regards
    Ashwini

  • Error in PL/SQL Language Reference .... could be that possible ?

    I use Oracle 10g ....... but when I used that function in :-
    Oracle® Database
    PL/SQL Language Reference
    11g Release 1 (11.1)
    B28370-02
    September 2007
    page 252
    CREATE OR REPLACE FUNCTION compute_bonus (emp_id NUMBER, bonus NUMBER)
    RETURN NUMBER
    IS
    emp_sal NUMBER;
    BEGIN
    SELECT salary INTO emp_sal
    FROM employees
    WHERE employee_id = emp_id;
    RETURN emp_sal + bonus;
    END compute_bonus;
    The following equivalent SELECT statements invoke the PL/SQL subprogram in
    Example 8–5 using positional, named, and mixed notation:
    SELECT compute_bonus(120, 50) FROM DUAL; -- positional
    SELECT compute_bonus(bonus => 50, emp_id => 120) FROM DUAL; -- named
    SELECT compute_bonus(120, bonus => 50) FROM DUAL; -- mixed
    ====================================
    and than executed first select statement ..... it pass successfully
    but in second and third select ...... I found this errors :-
    SQL> SELECT compute_bonus(120, 50) FROM DUAL;
    COMPUTE_BONUS(120,50)
    8050
    SQL> SELECT compute_bonus(bonus => 50, emp_id => 120) FROM DUAL;
    SELECT compute_bonus(bonus => 50, emp_id => 120) FROM DUAL
    ERROR at line 1:
    ORA-00907: missing right parenthesis
    SQL> SELECT compute_bonus(120, bonus => 50) FROM DUAL;
    SELECT compute_bonus(120, bonus => 50) FROM DUAL
    ERROR at line 1:
    ORA-00907: missing right parenthesis
    is there any relation between that I use oracle 10g and those errors ???
    or the code wrote wrong in oracle reference 11g ( I hope not ) ???

    yes, you are correct. the "what's new" section of the 11g pl/sql manual states
    "Before Release 11.1, a SQL statement that invoked a PL/SQL subprogram had to specify the actual parameters in positional notation. As of Release 11.1, named and mixed notation are also allowed. This improves usability when a SQL statement invokes a PL/SQL subprogram that has many defaulted parameters, and few of the actual parameters must differ from their default values."

  • Unable to call a Packaged function in SQL statement??

    I have written a package & overloaded a function 3 times. I am using different parameter name for overloading & call as follows:
    my_pkg.ovrld_func(p_1 => v_val)
    my_pkg.ovrld_func(p_2 => v_val)
    my_pkg.ovrld_func(p_3 => v_val)
    When i use this statement in a sql or DML statement i get the following error.
    ORA-00907: missing right parenthesis
    I searched for limitations on packages but couldn't find this issue.
    FYI: I am using Oracle 9i Rel2
    Thanks

    I think its a bug as Oracle didn't report this limitation anywhere in the documentation & i should open a TAR.Well, it's documented limitation in fact.
    Quote "Oracle9i Application Developer’s Guide - Fundamentals Release 2 (9.2)"
    In a chapter entitled "Syntax for SQL Calling a PL/SQL Function"
    p. 9-53.
    Arguments
    To pass any number of arguments to a function, supply the arguments within the
    parentheses. You must use positional notation; named notation is not currently
    supported. For functions that do not accept arguments, use ().Regards.

  • 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

  • Getting error in gather schema status

    Hi All,
    i am using oracle 10g database. when i am trying to gather stats i am gettin the below error.
    do we need to give all the options other than ownname ? can anyone help me with the right command?
    SQL> exec DBMS_STATS.GATHER_SCHEMA_STATS(ownname=>'CLINICOPIA_USER','CLINICOPIA','CLINICOPIA_PORTAL',DBMS_STATS.AUTO_SAMPLE_SIZE);
    BEGIN DBMS_STATS.GATHER_SCHEMA_STATS(ownname=>'CLINICOPIA_USER','CLINICOPIA','CLINICOPIA_PORTAL',DBMS_STATS.AUTO_SAMPLE_SIZE); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'GATHER_SCHEMA_STATS'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    There are wrong number of parameters that you are passing. Thats why there is an error. More over note the following:
    SQL> exec DBMS_STATS.GATHER_SCHEMA_STATS(ownname=>'CLINICOPIA_USER','CLINICOPIA','CLINICOPIA_PORTAL',DBMS_STATS.AUTO_SAMPLE_SIZE);
    Mixed notation. You specify the first parameters with positional notation, then switch to named notation for the last parameters.
    You can use this notation to call procedures that have some required parameters, followed by some optional parameters.
    Vice versa not allowed!
    http://download.oracle.com/docs/cd/B13789_01/appdev.101/b10807/08_subs.htm#i4072

  • Information about package sys.dbms_obfuscation_toolkit

    While using this package procedure DesEncrypt , we are facing error i.e
    too many declarations of 'DesEncrypt ' match this call......
    According to me, overloading of procedure has been performed based on datatypes of same family(i.e varchar2 and raw), which to me is not correct.
    Please suggest how to resolve this problem.
    Please give this work as urgent priority.

    You will need to use named notation (reference the parameter names in the call) instead of the normal positional notation because of the implicit conversions possible between varchar2 and raw.
    dbms_obfuscation_toolkit.DESEncrypt
      (input_string => v_string, key_string => v_key, encrypted_string=> v_encrypted_string);

  • Any idea on  this store procedure

    Hi,
    I was testing a procedure (call it sp_kirk) today and Oracle generate a test that had syntax like this:
    declare
    xxx varchar2(10);
    Begin
    xxx := 'yyy';
    sp_kirk( xxx => xxx);
    end;
    I was puzzled by the xxx => xxx syntax, and in fact, it worked just as well if I replaced it with just xxx.
    Any idea what the xxx => xxx means?
    Any thoughts would be hightly appreciated ..!
    Thanks
    JP

    Oracle generate a testPresumably you mean Oracle SQL Developer generated a test?
    The '=>' is used for the 'named notation' form of parameter passing which involves passing values to explicitly named parameters as opposed to the more common 'positional notation' which involves passing all the parameters in order.
    In simple cases (such as yours) there is little benefit to named notation other than explicitly documenting the parameter names in the call. For more complex situations involving overloading and defaulted (non-mandatory) parameters named notation gives increased flexibility.

  • IN clause with ORDER BY clause in sub-queries

    Hello,
    We generate dynamic queries with the following statement pattern (could be many union/intersect sub-queries):
    select my_col
    from my_table
    where my_col IN
    select table_2.my_col , x_col from table_2 where x_col > 10
    UNION
    select table_3.my_col , y_col from table_3 where y_col > 20
    INTERSECT
    select table_4.my_col , z_col from table_4 where z_col is between 30 and 50
    I know that I can do just the sub-queries w/ an ORDER BY clause as follows (as long as the 2nd parameter in the select stmts are of the same type):
    select table_2.my_col , x_col from table_2 where x_col > 10
    UNION
    select table_3.my_col , y_col from table_3 where y_col > 20
    INTERSECT
    select table_4.my_col , z_col from table_4 where z_col is between 30 and 50
    order by 2 desc
    But my questions are:
    1. What is (if there is) the syntax that will ensure that the result set order will be that of the ordering of the sub-queries?
    Or does my SQL stmt have to have syntactically (but not semantically) change to achieve this?
    Thanks,
    Jim

    Randolf Geist wrote:
    just a minor doubt - I think it is not officially supported to have separate ORDER BYs in a compound query with set operators (e.g. UNION / UNION ALL subsets). Of course one could use inline views with NO_MERGE + NO_ELIMINATE_OBY hints, but I think the only officially supported approach is to use a single, final ORDER BY (that needs to use positional notation as far as I remember).
    Randolf,
    You're right, of course, about the separate "order by" clauses.
    Interestingly the following type of thing does work though (in 10.2.0.3, at least):
    with v1 as (
        select * from t1 where col1 = 'ABC' order by col2
    v2 as (
        select * from t1 where col1 = 'DEF' order by col2
    select * from v1
    union all
    select * from v2
    ;A quick check the execution plan suggsts that Oracle appears to be convering this to the following - even though its technically not acceptable in normal circumstances:
    select * from t1 where col1 = 'ABC' order by col2
    union all
    select * from t1 where col1 = 'DEF' order by col2
    ;Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • This should be easy ;O) How do I read the exif info in a JPG file?

    Hey all...
    I have been googling this for awhile now with not much luck.
    !st... Hi... I am a Flex AS3 newbie....  but... not a programming newbie...
    My learning project is to create my photoart gallery as a Before and After gallery. Part one is a Flex/Air app to gather the images, scale them to consistant display and thumbnail sizes and build and edit XML data files for the images and galleies. I have actually gotten most of that done..
    I am currently working on editing the XML files for the image information (photographer info, copywrite info, descriptions, gallery...etc.) and pulling in as much information that I can find in the image file itself. That being EXIF data.
    I have found a couple of examples but for the XResolution and Yresolution I just keep getting 72dpi... now the Jpg files that I am using from my camera.. when I look at the properties with Windows XP... it say 300dpi... when I load the image in Photoshop and look at image size it says 300dpi.. in Photoshop if I look at file information the EXIF says 300dpi....
    How can I access that data with Flex/AS3????? After all this is "Adobe" Flex Builder...
    This just seems like it should have been solved ages ago... Please.. point to the right path  ;O)
    I have searched this forum and have found one or two EXIF references, but no answers.
    Thanks for any guidance on the subject.
    Bob Galka

    Jean-Pierre
    Thanks very much for your quick response.
    One last point and we should drop this in favor of other more urgent issues we both ahve to deal with.
    The data is coming from a comma delimited (CSV) file using a comma ',' and optional quotes (") as field separators.
    The first column of 'good' data is read as an INTEGER EXTERNAL because of course it is a number. However, the 'bad' rows I want to eliminate have character text in them where I would normally find numbers and they all start with 'D','M' or 'S'.
    I don't have an actual column in the data file or resulting table definition that represents that first character that I'm trying to test on. Hence my use of (1) to reporesent the 1st character of data on the line regardless of whether its numeric or character.
    As I stated, the syntax works fine in SQL*Loader when I typed the WHEN clause in manually.
    I guess if there was a way to define a pseudo column that could be defined using the POSITION notation and everything else using the variable length delimited notation I could test on that psuedo column. I don't want the pseudo column to appear in my resulting table so that seems to be an issue. Enough.
    Since I've worked around it using external tables for this issue I'm not going to spend any more time on it today.
    As usual, many thanks for your help.
    Have a great day! I'll be back soon with another issue :-)>
    Gary

Maybe you are looking for