Anonymous PL/SQL vs procedure inside package

It's probably quite simple problem but I'm not able to figure it out.
If I make an anonymous PL/SQL block
declare
l_counter number(4);
begin
SELECT *
into l_counter
FROM (SELECT count(*)
FROM SYS.all_objects
WHERE owner IN ('USER1', 'USER2')
AND object_type IN ('TABLE', 'VIEW')
minus
SELECT count(*)
FROM SYS.dba_tab_privs
WHERE grantee = 'TESTERS');
DBMS_OUTPUT.PUT_LINE(l_counter);
end;
then it works. The result is 2 which is correct because select statement returns 2 rows.
If I make procedure with the same code
create or replace PROCEDURE grant_privileges2
IS
l_counter NUMBER (4);
BEGIN
SELECT COUNT (*)
INTO l_counter
FROM (SELECT owner, object_name
FROM SYS.all_objects
WHERE owner IN ('USER1', 'USER2')
AND object_type IN ('TABLE', 'VIEW')
MINUS
SELECT owner, table_name
FROM SYS.dba_tab_privs
WHERE grantee = 'TESTERS);
DBMS_OUTPUT.put_line (l_counter);
END;
result is 0 which is not correct becuase select statement is the same as in anonymous pl/sql and it has to return 2 rows.
What I'm doing wrong?

If the queries are the same then it works for me...
SQL> ed
Wrote file afiedt.buf
  1  declare
  2  l_counter number(4);
  3  begin
  4  SELECT *
  5  into l_counter
  6  FROM (SELECT count(*)
  7  FROM SYS.all_objects
  8  WHERE owner IN ('CRISP_ADMIN', 'CRISP_INTELL')
  9  AND object_type IN ('TABLE', 'VIEW')
10  minus
11  SELECT count(*)
12  FROM SYS.dba_tab_privs
13  WHERE grantee = 'SYSTEM');
14  DBMS_OUTPUT.PUT_LINE(l_counter);
15* end;
SQL> /
431
PL/SQL procedure successfully completed.
SQL> ed
Wrote file afiedt.buf
  1  create or replace procedure mytest is
  2  l_counter number(4);
  3  begin
  4  SELECT *
  5  into l_counter
  6  FROM (SELECT count(*)
  7  FROM SYS.all_objects
  8  WHERE owner IN ('CRISP_ADMIN', 'CRISP_INTELL')
  9  AND object_type IN ('TABLE', 'VIEW')
10  minus
11  SELECT count(*)
12  FROM SYS.dba_tab_privs
13  WHERE grantee = 'SYSTEM');
14  DBMS_OUTPUT.PUT_LINE(l_counter);
15* end;
SQL> /
Procedure created.
SQL> exec mytest;
431
PL/SQL procedure successfully completed.

Similar Messages

  • Getting the metadata of procedures defined inside packages...

    Dear All,
    i want to extract the metadata for procedures and functions in my db.
    i am using the DBMS_METADATA.GET_DDL(ObjectType,ObjectName) to get the metadata of certain objects (PROCEDURES,FUNCTIONS and PACKAGE_BODY)
    however this method is not quiet usefull when my target is to get the metadata for a single procedure/function defined inside package's body', where i dont need
    the whole package body to be returned only the specific Procedure/ Function defined in it...
    it seems that the Package Body is defined as one object regardless of how many Procedures / Functions are defined in it...
    isnt there any place/repository that stores the procedures and functions defined inside a package body along with their metadata explicitly one bye one , so i can
    extract them and search them one bye one...
    Thank you
    Basem Sayej...

    The whole point about defining procedures inside package bodies is that they are private. They are only exposed to those who have the necessary privileges to view the body's source code.
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Pl/sql stored procedure as data source

    Hi I am a newbie
    I have a pl/sql stored procedure inside a package which uses a SYS_REFCURSOR as it returns a result set.
    Can I use this procedure as a Data Source using the wizard?
    When I use the Data source configuration wizard I get a list with only the tables and views.I don't see any stored procedures
    Thanks

    Here is a sample procedure..
    CREATE OR REPLACE PROCEDURE TEST_USER.TEST_PROCEDURE1 ( p_cursor OUT SYS_REFCURSOR)
    AS
    BEGIN
    OPEN p_cursor FOR
    SELECT C1,C2
    FROM TEST_USER.test_table4procedure;
    END;
    When I execute the procedure, I see the results. The goal is to put the results of the procedure into a different table.
    Unfortunately I have close to 0 zero knowledge in both java and jython.
    Please help.
    NOTE: For the life of me, I have no clue why the "other" system wants it to be a stored procedure, when we can use a view/table and make everybody's life easier (aka K.I.S.S.)
    Regards,
    Dave Null

  • How to call PL-SQL/stored procedure in Creator

    Anybody can tell how to call PL-SQL/Stored procedures inside creator...

    Hi!!!
    You can see this topic http://forum.sun.com/jive/thread.jspa?threadID=106046
    There is how to call oracle stored procedures. Also I put a lot of links in these topic doing reference stored procedures. I have one that it tells specially how to call oracle stored procedures from java, is in spanish but you can understand the code.;-)
    http://yoprogramador.vampisol.com/index.php?title=pl_sql_oracle_desde_java&more=1&c=1&tb=1&pb=1
    Byeee

  • Display invalid pattern name while calling the procedure inside the package

    Hi ,
    I'am trying to call a package which is having procedure ,from JDBC in which one of the return type is Varray from the procedure.When i'am calling the procedure inside the package
    from java showing invalid name pattern name.Just i'am placing the code snippet for package and calling java through package.
    Package body
    create or replace package body Rewards_Summary_Package as
    PROCEDURE Rewards_Summary_Procedure
    (v_Tot_Earned_Points OUT NUMBER, v_TOT_REDEEMED OUT NUMBER, v_TOT_PTS_EXP OUT NUMBER,
    v_TOT_AVAILABLE OUT NUMBER, v_TIER_NAME OUT VARCHAR2,VA OUT t_varray,V_PR_CON_ID IN VARCHAR2) AS
    v_ACCRUALED_VAL NUMBER := 0;
    v_USED_VAL NUMBER := 0;
    /*v_TOT_ACCRUALED_VAL NUMBER := 0;
    v_TOT_USED_VAL NUMBER := 0;
    V_PR_TIER_ID VARCHAR2(30);
    V_PR_CON_ID VARCHAR2(30);
    V_EXPIRY_DT DATE;
    v_month varchar2(30);
    v_date date;
    v_next_month_date date;
    v_TIER_NAME VARCHAR2(50);
    v_TOT_AVAILABLE NUMBER := 0;
    v_EARNED NUMBER := 0;
    v_TOT_EARNED NUMBER := 0;
    v_TOT_REDEEMED NUMBER := 0;
    v_TOT_EXPIRED NUMBER := 0;
    v_EARNED_TOTAL NUMBER := 0;
    v_TOT_EXPIRED_MONTH NUMBER := 0;
    v_TOT_PTS_EXP NUMBER := 0;
    v_TOT_RDMD_CANCELLED NUMBER :=0;
    v_TOT_EARNED_POINTS NUMBER :=0;*/
    v_FIRST_DT DATE;
    v_LAST_DT DATE;
    v_MEMBER_ID VARCHAR2(30);
    V_EXPIRED_VAL Number;
    v_TOT_PRDPTS_RDMD NUMBER := 0;
    v_TOT_PTS_RDMD NUMBER := 0;
    v_CAN_ACCRUAL_POINTS NUMBER := 0;
    BEGIN
    /*TotalRwdPoints and Tier Name*/
    SELECT TR.NAME,MEM.POINT_TYPE_A_VAL,MEM.ROW_ID INTO v_TIER_NAME,v_TOT_AVAILABLE,v_MEMBER_ID
    FROM SIEBEL.S_LOY_MEMBER MEM, SIEBEL.S_LOY_TIER TR WHERE MEM.PR_DOM_TIER_ID=TR.ROW_ID
    AND MEM.PR_CON_ID=V_PR_CON_ID;
    vTotPrdPtsRdmd
    SELECT NVL(SUM(A.VALUE),0) INTO v_TOT_PRDPTS_RDMD from SIEBEL.S_LOY_RDM_ITM A,SIEBEL.S_LOY_ATTRDEFN B
    WHERE A.MEMBER_ID = v_MEMBER_ID AND A.ATTRB_DEFN_ID = B.ROW_ID AND b.INTERNAL_NAME = 'Point 1 Value' AND A.TYPE_CD='Product'
    AND A.TXN_ID IS NOT NULL;
    vTotPtsRdmd
    SELECT NVL(SUM(A.VALUE),0) INTO v_TOT_PTS_RDMD from SIEBEL.S_LOY_RDM_ITM A,SIEBEL.S_LOY_ATTRDEFN B
    WHERE A.MEMBER_ID = v_MEMBER_ID AND A.ATTRB_DEFN_ID = B.ROW_ID AND b.INTERNAL_NAME = 'Point 1 Value' AND (A.TYPE_CD='Product' or A.TYPE_CD='Transfer')
    AND A.TXN_ID IS NOT NULL;
    vTotRewardPtExp
    SELECT NVL(SUM(A.VALUE),0) INTO v_TOT_PTS_EXP FROM SIEBEL.S_LOY_RDM_ITM A,SIEBEL.S_LOY_ATTRDEFN B
    WHERE A.MEMBER_ID = v_MEMBER_ID AND A.ATTRB_DEFN_ID = B.ROW_ID AND b.INTERNAL_NAME = 'Point 1 Value' AND A.TYPE_CD='Expired'
    AND a.TXN_ID IS NULL;
    vCanAccrualPoints
    SELECT NVL(SUM(A.ACCRUALED_VALUE),0) INTO v_CAN_ACCRUAL_POINTS from SIEBEL.S_LOY_ACRL_ITM A,SIEBEL.S_LOY_ATTRDEFN B
    WHERE A.MEMBER_ID = v_MEMBER_ID AND A.ATTRIB_DEFN_ID = B.ROW_ID AND b.INTERNAL_NAME = 'Point 1 Value' AND A.TYPE_CD='Cancellation';
    v_Tot_Earned_Points := v_TOT_AVAILABLE+v_TOT_PRDPTS_RDMD+v_TOT_PTS_EXP-v_CAN_ACCRUAL_POINTS;
    v_TOT_REDEEMED := v_TOT_PTS_RDMD-v_CAN_ACCRUAL_POINTS;
    DBMS_OUTPUT.PUT_LINE(' Total Earned: '|| v_Tot_Earned_Points || ' Total Redeemed: '|| v_TOT_REDEEMED || ' Total Expired: '|| v_TOT_PTS_EXP
    || ' Balance Points: '|| v_TOT_AVAILABLE || ' Tier Name: '|| v_TIER_NAME);
    select trunc(sysdate,'MONTH') INTO v_FIRST_DT from dual;
    va:= t_varray(Null,Null,Null,Null,Null,Null);
    FOR a in 1 .. 6 LOOP
    select trunc(last_day(v_FIRST_DT)) INTO v_LAST_DT from dual;
    SELECT SUM(AI.ACCRUALED_VALUE),SUM(AI.USED_VALUE) INTO v_ACCRUALED_VAL,v_USED_VAL from SIEBEL.S_LOY_ACRL_ITM AI,SIEBEL.S_LOY_ATTRDEFN A
    WHERE AI.MEMBER_ID = v_MEMBER_ID AND A.ROW_ID = AI.ATTRIB_DEFN_ID AND A.INTERNAL_NAME = 'Point 1 Value'
    AND trunc(AI.EXPIRATION_DT) >= v_FIRST_DT AND trunc(AI.EXPIRATION_DT) <= v_LAST_DT;
    V_EXPIRED_VAL := NVL(v_ACCRUALED_VAL-v_USED_VAL,0);
    va(a):=V_EXPIRED_VAL;
    v_FIRST_DT := add_months(v_FIRST_DT,1);
    End loop;
    END;
    end;
    Package declaration
    create or replace package Rewards_Summary_Package as
    TYPE t_varray IS VARRAY(6) OF NUMBER;
    PROCEDURE Rewards_Summary_Procedure
    (v_Tot_Earned_Points OUT NUMBER, v_TOT_REDEEMED OUT NUMBER, v_TOT_PTS_EXP OUT NUMBER,
    v_TOT_AVAILABLE OUT NUMBER, v_TIER_NAME OUT VARCHAR2,VA OUT t_varray,V_PR_CON_ID IN VARCHAR2);
    end;
    java code
    I had tried using java types and Oracle types
    conn=SiebelServiceDatasource.getConnection(SSBConstants.REWARDS_PROP_LOG_SUFIX);
    // ArrayDescriptor.TYPE_VARRAY
    ocstmt=(OracleCallableStatement)conn.prepareCall(" {call REWARDS_SUMMARY_PACKAGE.REWARDS_SUMMARY_PROCEDURE(?,?,?,?,?,?,?)}");
    //ocstmt=(OracleCallableStatement)conn.prepareCall(" call Test_Array(?,?)");
    ocstmt.registerOutParameter(1,OracleTypes.INTEGER);
    ocstmt.registerOutParameter(2,OracleTypes.INTEGER);//1-616BH
    ocstmt.registerOutParameter(3,OracleTypes.INTEGER);
    ocstmt.registerOutParameter(4,OracleTypes.INTEGER);
    ocstmt.registerOutParameter(5,OracleTypes.VARCHAR);
    ocstmt.registerOutParameter(6,OracleTypes.ARRAY,"SIEBEL.T_VARRAY");
    ocstmt.setString(7,contactSiebelRowId);
    ocstmt.execute();
    Showing the following invalid name pattern SIEBEL.T_VARRAY
    Please help
    Thanks in advance
    Kiran

    create or replace package Rewards_Summary_Package as
        TYPE t_varray IS VARRAY(6) OF NUMBER;
    end;You've declared your type inside the package. You need to declare it as a SQL type, which is not part of a PL/SQL package.

  • How to re-execute anonymous PL/SQL block in package definition ?

    Hi all,
    I implemented a package which contains procedures and an anonymous PL/SQL block.
    This anonymous PL/SQL block is executed only once when the package is called.
    and charge in-memory the content of table to avoid multiple SQL access each
    time one procedure is called.
    As my application open many sessions to the Oracle database, I would like to try
    a solution to signal all sessions to reload the content of table when the content
    of table is modified. The solution to stop and to restart the connection is not
    acceptable.
    Best regards
    Sylvain

    > .. to avoid multiple SQL access each time one procedure is called.
    As I understand your posting, this is the actual technical requirement. You want to force serialisation of PL/SQL code. Correct? (only one session at a time can run the procedure)
    This feature typically used to accomplish this in o/s code is called a semaphore. PL/SQL does not specifically support semaphores. However, it supports a range of IPC (Inter Process Communication) methods - from message queues to pipes.
    One of these IPC interfaces is DBMS_LOCK - which allows a unique lock to be defined and processes to manage their resource usage/execution/etc via this lock using the DBMS_LOCK API.
    I've found this a pretty clean and manageable solution to enforce serialisation. Of course, it is even better not to enforce serialisation. Rather design the code to be thread safe and capable of multi-processing/parallel processing.
    Personally, I would not use a table as an IPC mechanism as Oracle already provides better IPC mechanisms for PL/SQL code. As for "signalling sessions to re-load the table" - not possible as Oracle sessions cannot register callbacks to handle events. Oracle sessions are not event driven processes from a PL/SQL (application development) perspective.

  • How Execute a very long SQL in a Storep Procedure inside a String?

    How Execute a very long SQL in a Storep Procedure inside a String?
    I have a very very long sql in a String , How can I run this SQL?
    Thaks in advance.

    Xavi wrote:
    I have a very very long sql in a String , How can I run this SQL? Version? If you are on 11g, dynamic SQL can be a CLOB. If you are on older versions us DBMS_SQL package.
    SY.

  • Sql Developer - View source code of procedures, functions & packages in another schema

    Our developers need the ability to view procedures, function, packages etc. in the production database (using SQL DEVELOPER).  They don't have access to sign on as the owner of these
    objects in Production.  They must use their own limited access UserID for this purpose.
    This limited access UserID has been granted select privilege on DBA_SOURCE & DBA_OBJECTS.  The developers need the ability to view the source of these object via
    the tree view in SQL DEV.  They should be able to click on "other users" in the SQL DEV tree view and see a listing of the owner schema objects.  Then they should
    be able to select the desired object and view the source code.  These developers are used to using GUI interfaces.  Selecting from DBA_SOURCE would not be an
    option for them.
    I understand that if the limited user is granted SELECT ANY DICTIONARY or SELECT_CATALOG_ROLE then this functionality will work.  The problem is those
    privileges/roles  provide much more access than should be granted to these limited access users. Granting DBA to these users is also not an option.
    In TOAD and other end-user tools this functionality works when only select privilege on DBA_SOURCE & DBA_OBJECTS has been granted.  We need this same functionality
    in SQL DEV.
    While searching this forum and the internet, I see that other installations have this same issue.
    Please enhance SQL Developer with this functionality. 
    Thank you, ellen

    Just to double check that I'm interpreting the problem correctly, is the following true:
    select * from all_objects where object_name = 'DBA_SOURCE'
    returns nothing
    select * from dba_source where name = your PL/SQL module
    returns all the code

  • Query for getting all function and procedure inside the packages

    hi All
    Please provide me Query for getting all function and procedure inside the packages
    thanks

    As Todd said, you can use user_arguments data dictionary or you can join user_objects and user_procedures like below to get the name of the packaged function and procedure names.
    If you are looking for the packaged procedures and functions source then use user_source data dictionary
    select a.object_name,a.procedure_name from user_procedures a,
                  user_objects b
    where a.object_name is not null
    and a.procedure_name is not null
    and b.object_type='PACKAGE'        
    and a.object_name=b.object_name

  • Pl/sql procedure in package with out parameter

    Hi all,
    my need is to run procedure in package and return 0 or 1 as out parameter depending on data selection.
    How do I return value?
    My first guess is to use raise_application_error, but maybe some other decision can be found here.
    Looking forward to see your reply.
    Thanks ahead.

    Hi,
    marco wrote:
    Hi all,
    my need is to run procedure in package and return 0 or 1 as out parameter depending on data selection.
    How do I return value? Assign the desired value to the OUT parameter.
    My first guess is to use raise_application_error, but maybe some other decision can be found here. You can do it in an EXCEPTION handler, if that makes sense.
    Here's an example:
    CREATE OR REPLACE PROCEDURE     dept_comm
    (     in_deptno     IN     scott.emp.deptno%TYPE     -- Department of interest
    ,     out_comm     OUT     scott.emp.comm%TYPE     -- Total comm in that department
    ,     out_flag     OUT     NUMBER               -- 0 means there were no rows in table, 1 means there were
    AS
    BEGIN
         SELECT     SUM (comm),     COUNT (*)
         INTO     out_comm,     out_flag     -- See note (1) below
         FROM     scott.emp
         WHERE     deptno     = in_deptno;
         IF  out_flag  > 0     -- 0 and 1 are the only possible values for out_flag
         THEN
             out_flag := 1;               -- See note (2) below
         END IF;
    END     dept_comm;
    /This shows out_flag getting set 2 different ways:
    (1) in a SELECT ... INTO statement
    (2) in a normal assignment statement
    Any other way that you can use to assign a value to out_flag (such as passing it as an OUT argument to another procedure) would work as well.
    Edited by: Frank Kulash on Jan 31, 2012 1:27 PM

  • PL/SQL Stored procedures vs C# code.

    Hi All
    We are going to start designing a kind of transactional application with huge volume of data (150 million records per month). Our selected DB engine is Oracle 10.g while C# is selected development language.
    Because of big volume of data performance is one of the most important factors for us, and the technical design should gain the best level of performance.
    What i'm looking for and studing for it is to define which kind of operation shall be done by Stored Procedure which will be written by PL/SQL or by C# classes?
    I don't interested in to handle complicated and complex jobs using PL/SQL stored procedures while the performance really deserve it.

    Hello,
    Well, my philosophy is to leverage the database as much as possible. I have worked with applications that had no "select", "insert", "update" or "delete" statements in them. Instead, stored procedures and functions inside of PL/SQL packages and bodies were used. Some people will argue strongly against that, but I belong to the "thick database" group rather than the "the database is just a persistence layer that I have to deal with" group. To me it makes sense to co-locate the code that works on the data with the data. If you are working with large volumes of data, I find the bulk operations available via PL/SQL to be very handy.
    Here's an AskTom thread that deals with this general issue:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:12083187196917
    Whilst the thread is primarily about Java, you can substitute just about any other language and the meaning will still carry over.
    Regards,
    Mark

  • Execute immediate of Anonymous pl/sql block stored in a VARCHAR2 DB Column

    Hi Guys,
    I really hope someone can help me with this.
    I have the following pl/sql anonymous block stored in a varchar2 database column.
    declare
        l_my_val varchar2(32767);
                cursor c_activity is
                SELECT
                      l.DESCRIPTION || decode(l2.DESCRIPTION,null,'',l2.description,  '-' || l2.description) || decode(a.DT,'Y',' - Distributed Training','N',null,null) as value1
                FROM   ACTIVITY a
                      ,MOUNTAINEERING m
                      ,LOV l
                      ,LOV l2
                WHERE  a.JSATFA_ID = 82
                AND    a.SPECIFIC_ACTIVITY_LOV_ID = l.LOV_ID
                AND    m.ACTIVITY_ID(+) = a.ACTIVITY_ID
                AND    m.CLASSIFICATION_LOV_ID = l2.LOV_ID(+);
    begin
    for each_row in c_activity loop
      l_my_val := l_my_val ||  ', ' || each_row.value1;
    end loop;
    :l_value := ltrim (l_my_val, ', ');
    end;  The code is select out of the database and assigned to a local variable within my pl/sql package. The following code should demonstrate what I'm trying to achieve:
    declare
      l_sql varchar2(32767);
      l_value varchar2(32767);
    begin
      select query_sql into l_sql from lov where lov_id = 100;
      execute immediate l_sql using out :l_value;
      dbms_output.put_line(l_value);
    end;However Oracle (10.2.0.2) seems to be doing something funny with the single quotes. and gives the following error:
    ORA-06550: line 1, column 1:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
       begin case declare exit for function goto if loop mod null
       package pragma procedure raise return select separate type
       update while with <an identifier>
       <a double-quoted delimited-identifier> <a bind variable> <<
       form table call close current define delete fetch lock insert
       open rollback savepoint set sql execute commit forall merge
       library OPERATOR_ pipe
    errorIf I embed the code I'm trying to execute within the package i.e
    declare
      l_sql varchar2(32767);
      l_value varchar2(32767);
    begin
      l_sql := q'~declare
        l_my_val varchar2(32767);
                cursor c_activity is
                SELECT
                      l.DESCRIPTION || decode(l2.DESCRIPTION,null,'',l2.description,  '-' || l2.description) || decode(a.DT,'Y',' - Distributed Training','N',null,null) as value1
                FROM   ACTIVITY a
                      ,MOUNTAINEERING m
                      ,LOV l
                      ,LOV l2
                WHERE  a.JSATFA_ID = 82
                AND    a.SPECIFIC_ACTIVITY_LOV_ID = l.LOV_ID
                AND    m.ACTIVITY_ID(+) = a.ACTIVITY_ID
                AND    m.CLASSIFICATION_LOV_ID = l2.LOV_ID(+);
    begin
    for each_row in c_activity loop
      l_my_val := l_my_val ||  ', ' || each_row.value1;
    end loop;
    :l_value := ltrim (l_my_val, ', ');
    end; 
      ~';
      execute immediate l_sql using out :l_value;
      dbms_output.put_line(l_value);
    end;It works perfectly. Notice I have used the q syntax when embedding the sql directly into the package.
    I have tried
    - appending the q syntax directly to query_sql stored in the database
    - escaping the quotes i.e. ' become ''
    Neither method seem to work. We are running 10.2.0.2 on Windows Server 2003. If anyone has any suggestions I would love to hear from you as this has me stumped.
    Regards
    Kris
    - http://kristianjones.blogspot.com

    If you do:
    declare
    l_sql varchar2(32767);
    l_value varchar2(32767);
    begin
    select query_sql into l_sql from lov where lov_id = 100;
    dbms_output.put_line(l_sql);
    end;
    You'll see something like that:
    SELECT
    l.DESCRIPTION || decode(l2.DESCRIPTION,null,'',l2.description, '-' || l2.description) || decode(a.DT,'Y',' - Distributed Training','N',null,null) as value1
    FROM ACTIVITY a
    ,MOUNTAINEERING m
    ,LOV l
    ,LOV l2
    WHERE a.JSATFA_ID = 82
    AND a.SPECIFIC_ACTIVITY_LOV_ID = l.LOV_ID
    AND m.ACTIVITY_ID(+) = a.ACTIVITY_ID
    AND m.CLASSIFICATION_LOV_ID = l2.LOV_ID(+);
    you need to duplicate the '
    you can do many things like:
    CTH@> select * from sqls;
    C
    select first_name || ' ' || last_name as value1 from employees where rownum=1
    1 fila seleccionada.
    CTH@>
    CTH@> ;
    1 declare
    2 l_sql varchar2(32767);
    3 l_value varchar2(32767);
    4 type generic_cursor is ref cursor;
    5
    6 c generic_cursor;
    7
    8 begin
    9 select replace(c, ''', ''''') into l_sql from sqls;
    10
    11 execute immediate l_sql into l_value;
    12 dbms_output.put_line(l_value);
    13* end;
    CTH@> /
    Ellen Abel
    Procedimiento PL/SQL terminado correctamente.
    CTH@>

  • Executing procedure in package problem

    Hi, i have a procedure called Newcar. i have now created a package and put the Newcar procedure inside the package body. but when i want to invoke it (to put data) by running execute packageTest.Newcar('Ferrari', 007) i get ORA-00900: invallid sql statement. what is wrong? the package spec and body gets created ok:
    CREATE OR REPLACE PACKAGE packageTest IS
    PROCEDURE Newcar(vname IN VARCHAR2, vreg IN NUMBER);
    END packageTest;
    CREATE OR REPLACE PACKAGE BODY packageTest IS
    PROCEDURE Newcar
    (vname IN VARCHAR2, vreg IN NUMBER)
    IS
    l_vreg NUMBER;
    BEGIN
    l_vreg := vreg;
    IF vreg > 999 THEN
    l_vreg := 999;
    END IF;
    INSERT INTO CARS (carname, carreg)
    VALUES
    (vname, l_vreg);
    END Newcar;
    END packageTest;
    /

    Worked for me. Are there other details that might be relevant? The table definition perhaps? Triggers? Can you post similar output from your SQL*Plus session?
    SQL> CREATE OR REPLACE PACKAGE packageTest IS
      2  PROCEDURE Newcar(vname IN VARCHAR2, vreg IN NUMBER);
      3  END packageTest;
      4  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY packageTest IS
      2  PROCEDURE Newcar
      3  (vname IN VARCHAR2, vreg IN NUMBER)
      4  IS
      5  l_vreg NUMBER;
      6  BEGIN
      7  l_vreg := vreg;
      8  IF vreg > 999 THEN
      9  l_vreg := 999;
    10  END IF;
    11
    12  INSERT INTO CARS (carname, carreg)
    13  VALUES
    14  (vname, l_vreg);
    15  END Newcar;
    16  END packageTest;
    17  /
    Package body created.
    SQL> execute packageTest.Newcar('Ferrari', 007)
    PL/SQL procedure successfully completed.
    SQL> select * from cars;
    CARNAME                                                CARREG
    Ferrari                                                     7
    SQL>

  • Debugging Anonymous PL/SQL Block

    Does sql developer allow you to debug an anonymous PL/SQL block or is the debugging restricted to compiled procedures/functions? Am a TOAD user but am looking at SQL Developer. Thanks

    As you can only set breakpoints inside a code editor, you'll have to wrap your code in a stored procedure.
    You could request this at the SQL Developer Exchange, but I guess it'll be too much work to add vs. the relative ease of using a stored proc.
    Regards,
    K.

  • How to find the name of calling procedure or package?

    Hi all..
    Is it possible to find the name of the calling procedure or package?
    I mean..if proc_1 is calling proc_2 How can i find in proc_2 that proc_1 is calling?
    Proc_2 is being called from different procedures? I need to write to small code which needs to fire depends on the Proc it is calling?
    Please help me to solve this.
    Thanks

    Not sure, if this is what you're looking for
    SQL> create or replace procedure p0 as
      2  begin
      3    dbms_output.put_line(dbms_utility.format_call_stack);
      4  end;
      5  /
    Procedure created.
    SQL> create or replace procedure p1 as
      2  begin
      3    p0;
      4  end;
      5  /
    Procedure created.
    SQL> create or replace procedure p2 as
      2  begin
      3    p1;
      4  end;
      5  /
    Procedure created.
    SQL> set serveroutput on
    SQL> begin
      2    p2;
      3  end;
      4  /
    ----- PL/SQL Call Stack -----
      object      line  object
      handle    number  name
    3a7f2d618         3  procedure INV_ADM.P0
    39abfeef0         3  procedure INV_ADM.P1
    39c5ae7a0         3  procedure INV_ADM.P2
    3a0f3a538         2  anonymous block
    PL/SQL procedure successfully completed.
    SQL>

Maybe you are looking for

  • Filter not working, Please help

    Hi all, I have BI Answers report based on two fact tables. First Fact has Invoice_ID and few other columns. Second fact has Invoice_ID and few different columns. First report based on first fact table will display all invoices. Second report (which i

  • SJS Web Server 6.1SP3 certificate install in VIP

    Hi there, I have just tried to install a server certificate into SJS Web Server 6.1SP3 which resides in a VIP on a clustered machine (I believe). We created the database and certificate whilst the machine was sitting at a certain "node" (machine_name

  • Who will sync who?

    My G5 died a few weeks ago but luckily all my music was saved via Time machine. I imported it back into iTunes but it didn't have info such as play count, dated added. My ipod still has all that info on it as it was was synced with my old G5. If I hi

  • MacBook Air battery life/standby time destroyed by Lion!

    My girlfriend's 2010 MBA used to be able to be in standby mode forever (for weeks, if not the advertised month) and still maintain a charge with Snow Leopard. After upgrading to Lion, the battery drains overnight. Anyone else have this issue? And doe

  • Re:Resetting Apple 20' display to factory

    I am trying to calibrate my monitor. The Spyder software asks me to reset the brightness to factory settings. I don't know how to do this on the 20' cinema display. Please help. Thanks. Jon