PL/SQL Package with only Constants

We have created a PL/SQL package with a Spec and NO BODY with only constant values.
When a user logs onto the Database for the first time, and runs a program the first time the "Constants" package is called you get a ORA-06502, but every time after the first there is no issues. This only happens the first the user logs onto the database ( Session based ).
Cory

You have a wrong declaration in your package, some like c2 in the following example.
EDV@mtso> create or replace package xxx
  2  is
  3    c1 number := 1;
  4    c2 number := 'aa';
  5    c3 number := 3;
  6  end;
  7  /
Package created.
EDV@mtso> var t number
EDV@mtso> exec :t := xxx.c1;
BEGIN :t := xxx.c1; END;
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "EDV.XXX", line 4
ORA-06512: at line 1
EDV@mtso> print t
         T
EDV@mtso> exec :t := xxx.c1;
PL/SQL procedure successfully completed.
EDV@mtso> print t
         T
         1
EDV@mtso> exec :t := xxx.c3;
PL/SQL procedure successfully completed.
EDV@mtso> print t
         T
EDV@mtso> Note that constants declared before the errorous one have a value, constants declare after that one have no value.
Anton
Message was edited by:
ascheffer

Similar Messages

  • Creating PL/SQL Package with all the types

    CREATE OR REPLACE
    TYPE rec_type AS OBJECT (
    first_name VARCHAR2(20),
    last_name VARCHAR2(20)
    CREATE OR REPLACE
    TYPE REC_TYPE_TAB AS TABLE OF rec_type
    I am able to create the above types in oracle and used in PL/SQL packages. And like this I have somany types. I would like to if I can create a package with the types to make the life easier. Could you please tell me how to do it.
    your help is greately appreciated..
    --Krish                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    sb92075 wrote:
    TYPE add only aggravation, complexity, & should be avoidedI disagree.
    When used correctly types can be the simplest solution.
    For example when passing multiple values to a stored procedure. Avoiding the type in the below example would lead to further complexity and aggravation not lessen it.
    SQL> create or replace procedure p
      2      (
      3      p_object_list in sys.odcivarchar2list,
      4      p_result out sys_refcursor
      5      ) as
      6  begin
      7      open p_result for
      8          select owner, object_name, object_type
      9          from all_objects
    10          where object_name in
    11              (
    12              select column_value from
    13              table(p_object_list)
    14              )
    15          order by
    16              owner, object_name, object_type;
    17  end;
    18  /
    Procedure created.
    SQL> exec p(sys.odcivarchar2list('DUAL','ALL_OBJECTS'),:c)
    PL/SQL procedure successfully completed.
    SQL> print c
    OWNER                          OBJECT_NAME                    OBJECT_TYPE
    PUBLIC                         ALL_OBJECTS                    SYNONYM
    PUBLIC                         DUAL                           SYNONYM
    SYS                            ALL_OBJECTS                    VIEW
    SYS                            DUAL                           TABLE

  • (URGENT)Problem in PL/SQL package with date.

    Hi,
    When I am running this query
    "SELECT a.street_addr address, a.mailing_city_name city,
    d.pa_cust_name county, a.zip_cd zip,
    a.last_update_dt lastdate, a.status_cd status
    FROM CWT003_PEND_ADDR a,
    CWT004_ACTVITY_LOG b,
    CWT005_PUBLIC_AUTH c,
    CWT005_PUBLIC_AUTH d
    WHERE a.address_id = b.address_id(+)
    AND a.city_cust_num = c.pa_cust_num(+)
    AND c.parent_pa_num = d.pa_cust_num(+)
    AND (b.action_flag = 'A' OR b.action_flag = 'I')
    AND b.user_prof_id = NVL(NULL,b.user_prof_id)
    AND ( NVL (TO_DATE('01-oct-2006'),
    TO_DATE ('1-1-1900', 'MM-DD-YYYY')) =
    TO_DATE ('1-1-1900', 'MM-DD-YYYY')
    OR b.activity_tstmp >= TO_DATE('01-oct-2006')
    AND ( NVL (TO_DATE('01-nov-2006'),
    TO_DATE ('1-1-1900', 'MM-DD-YYYY')
    ) = TO_DATE ('1-1-1900', 'MM-DD-YYYY')
    OR b.activity_tstmp <= TO_DATE('01-nov-2006')
    AND ( NVL (NULL, -1) = -1
    OR a.district_no = ''
    AND a.city_cust_num IN (SELECT pa_cust_num
    FROM CWT005_PUBLIC_AUTH Y
                                       WHERE NVL(Y.parent_pa_num,-1) =
                                                 NVL(NULL,NVL(Y.parent_pa_num,-1)))
    AND NVL(a.city_cust_num,-1) = NVL(NULL,NVL(a.CITY_CUST_NUM,-1))"
    I am getting the desired o/p.
    But when I call the following package;
    CREATE OR REPLACE PACKAGE Test_Pkg_Dip
    AS
    PROCEDURE test_proc;
    END Test_Pkg_Dip;
    CREATE OR REPLACE PACKAGE BODY Test_Pkg_Dip
    AS
    PROCEDURE test_proc
    IS
    l_report_req_date CWT009_REPORT_RQST.report_req_dt%TYPE;
    l_report_type CWT009_REPORT_RQST.report_type%TYPE;
    l_req_user_prof_id CWT009_REPORT_RQST.req_user_prof_id%TYPE;
    l_rqst_city_num CWT009_REPORT_RQST.rqst_city_num%TYPE;
    l_rqst_county_num CWT009_REPORT_RQST.rqst_county_num%TYPE;
    l_rqst_from_dt VARCHAR2 (50);
    l_rqst_org_num CWT009_REPORT_RQST.rqst_org_num%TYPE;
    l_rqst_to_dt VARCHAR2 (50);
    l_rqst_user_prof_id CWT009_REPORT_RQST.rqst_user_prof_id%TYPE;
    l_city_cust_num CWT002_USR_CTY_REL.city_cust_num%TYPE;
    l_count NUMBER := 0;
    l_address CWT003_PEND_ADDR.street_addr%TYPE;
    l_city CWT003_PEND_ADDR.mailing_city_name%TYPE;
    l_county CWT005_PUBLIC_AUTH.pa_cust_name%TYPE;
    l_zip CWT003_PEND_ADDR.zip_cd%TYPE;
    l_last_worked_date CWT003_PEND_ADDR.last_update_dt%TYPE;
    l_status CWT003_PEND_ADDR.status_cd%TYPE;
    CURSOR cur_report_entries
    IS
    SELECT a.report_req_dt, a.report_type, a.req_user_prof_id,
    a.rqst_city_num, a.rqst_county_num,
    TO_CHAR (a.rqst_from_dt, 'DD-MON-YYYY'), a.rqst_org_num,
    TO_CHAR (a.rqst_to_dt, 'DD-MON-YYYY'), a.rqst_user_prof_id
    FROM (SELECT x.report_req_dt, x.report_type, x.req_user_prof_id,
    x.rqst_city_num, x.rqst_county_num, x.rqst_from_dt,
    x.rqst_org_num, x.rqst_to_dt, x.rqst_user_prof_id
    FROM CWT009_REPORT_RQST x
    ORDER BY report_type) a
    WHERE ROWNUM <= 1;
    CURSOR test_cur
    IS
    SELECT a.street_addr address, a.mailing_city_name city,
    d.pa_cust_name county, a.zip_cd zip,
    a.last_update_dt lastdate, a.status_cd status
    FROM CWT003_PEND_ADDR a,
    CWT004_ACTVITY_LOG b,
    CWT005_PUBLIC_AUTH c,
    CWT005_PUBLIC_AUTH d
    WHERE a.address_id = b.address_id(+)
    AND a.city_cust_num = c.pa_cust_num(+)
    AND c.parent_pa_num = d.pa_cust_num(+)
    AND (b.action_flag = 'A' OR b.action_flag = 'I')
    AND b.user_prof_id = NVL (l_rqst_user_prof_id, b.user_prof_id)
    AND ( NVL (TO_DATE (l_rqst_from_dt, 'DD-MON-YYYY'),
    TO_DATE ('01-JAN-1900', 'DD-MON-YYYY')
    ) = TO_DATE ('01-JAN-1900', 'DD-MON-YYYY')
    OR b.activity_tstmp >=
    TO_DATE (l_rqst_from_dt, 'DD-MON-YYYY')
    AND ( NVL (TO_DATE (l_rqst_to_dt, 'DD-MON-YYYY'),
    TO_DATE ('01-JAN-1900', 'DD-MON-YYYY')
    ) = TO_DATE ('01-JAN-1900', 'DD-MON-YYYY')
    OR b.activity_tstmp <=
    TO_DATE (l_rqst_to_dt, 'DD-MON-YYYY')
    AND (NVL (l_rqst_org_num, -1) = -1
    OR a.district_no = l_rqst_org_num
    AND a.city_cust_num IN (
    SELECT pa_cust_num
    FROM CWT005_PUBLIC_AUTH y
    WHERE NVL (y.parent_pa_num, -1) =
    NVL (l_rqst_county_num, NVL (y.parent_pa_num, -1)))
    AND NVL (a.city_cust_num, -1) =
    NVL (l_rqst_city_num, NVL (a.city_cust_num, -1));
    BEGIN
    DBMS_OUTPUT.put_line ('11111' || CHR (10));
    OPEN cur_report_entries;
    FETCH cur_report_entries
    INTO l_report_req_date, l_report_type, l_req_user_prof_id,
    l_rqst_city_num, l_rqst_county_num, l_rqst_from_dt,
    l_rqst_org_num, l_rqst_to_dt, l_rqst_user_prof_id;
    CLOSE cur_report_entries;
    DBMS_OUTPUT.put_line ( l_req_user_prof_id
    || '---'
    || l_report_req_date
    || '---'
    || l_report_type
    || '---'
    || l_rqst_user_prof_id
    || '---'
    || l_rqst_from_dt
    || '---'
    || l_rqst_to_dt
    || '---'
    || l_rqst_org_num
    || '---'
    || l_rqst_city_num
    || '---'
    || l_rqst_county_num
    DBMS_OUTPUT.put_line
    || CHR (10)
    IF l_rqst_city_num = 0
    THEN
    l_rqst_city_num := NULL;
    END IF;
    IF l_rqst_county_num = 0
    THEN
    l_rqst_county_num := NULL;
    END IF;
    IF l_rqst_user_prof_id = 0
    THEN
    l_rqst_user_prof_id := NULL;
    END IF;
    --l_rqst_from_dt := NULL;
    --l_rqst_to_dt   := NULL;
    l_count := l_count + 1;
    --FOR rec1 IN test_cur
    OPEN test_cur;
    LOOP
    BEGIN
    FETCH test_cur
    INTO l_address, l_city, l_county, l_zip, l_last_worked_date,
    l_status;
    EXIT WHEN test_cur%NOTFOUND;
    DBMS_OUTPUT.put_line
    || l_count
    || ' ] street_addr::'
    || l_address
    || CHR (10)
    || 'mailing_city_name::'
    || l_city
    || CHR (10)
    || 'pa_cust_name::'
    || l_county
    || CHR (10)
    || 'zip_cd::'
    || l_zip
    || CHR (10)
    || 'last_update_dt::'
    || l_last_worked_date
    || CHR (10)
    || 'status_cd::'
    || l_status
    || CHR (10)
    || '-------------------------------------------------------------------------------------------'
    || CHR (10)
    l_count := l_count + 1;
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line ( 'Inside Error::'
    || SQLCODE
    || '------'
    || SQLERRM
    END;
    END LOOP;
    CLOSE test_cur;
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line ('Error::' || SQLCODE || '------' || SQLERRM);
    END test_proc;
    END Test_Pkg_Dip;
    as
    BEGIN
    Test_Pkg_Dip.test_proc;
    END;
    I do not get any output. And also if I remove the date comparison from the query it works.
    Thanks & regards,
    Dipankar Kushari.

    Yeh.
    But the real error was "ERROR:
    ORA-06502: PL/SQL: numeric or value error: host bind array too small
    ORA-06512: at line 1"
    I found that it was coming due to more than 255 characters in a single line in dbms_output.put_line.
    Anyway, thanks for the answer.
    Dipankar.

  • Package with only user defined types

    I am creating packages and want to keep user defined types in one package only.
    I appreciate if any one can suggest me for this package, I include all types in the header portion then what should go in the package body?

    I guess these are VARRAY, TABLE, and RECORD types? Then you can put them in the package spec, and no package body is required.

  • How to declare a global variable from a PL/SQL package

    Hi All,
    Using a global variable is a bad practise for all language. However, in my case, I have a PL/SQL package defines all constants, and I want to use them directly via SQL statement, for instance,
    PACKAGE my_const
    IS
         DEFAULT_ZIP_CODE CONSTANT VARCHAR2(5) := '00000';
    END;And I cannot referrence this variable from my select statement as
    SELECT my_const.DEFAULT_ZIP_CODE from dual;I have to create a function via my package, as,
    FUNCTION get_default_zip_code RETURN VARCHAR2
    IS
    BEGIN
         RETURN DEFAULT_ZIP_CODE;
    END;and
    SELECT my_const.get_default_zip_code from dual;I don't want to create functions to referrence the default varaibles. Does anyone have any clues?
    thanks
    Edited by: user4184769 on Jul 19, 2010 8:36 AM

    riedelme wrote:
    thanks for the info. Your scope explanation makes sense even though it is not intuitive to me. I think the usage of package variables should be supported by SQL (they're just values to be copied) Maybe look at it from another language's perspective. You want to use a global PL package variable in Java/C#/Delphi/VB/etc. How would you do it?
    None of these languages can crack open the data segment of a PL code unit, inspect the variables in it, and extract a value from it. Instead, it needs to be done as follows:
    Using sqlplus as the client illustrates how all these languages will need to do it:
    SQL> var value varchar2(20);
    SQL> begin
      2>     :value := SomePackage.someVar;
      3> end;
      4> /So why should SQL behave differently? It is not the same as the PL language. It is not a subset of the PL language. Yeah, PL/SQL blurs the line between these 2 languages making it very simple for us to mix their source code. But PL/SQL is SQL integrated with PL - not PL integrated with SQL. PL has tight hooks into SQL, creating cursors for you, defining bind variables, binding variables and doing the whole Oracle Call Interface bit for you.
    But SQL has no need for PL code, just as it has no need for Java code, or Delphi code or VB code. Yes, it is possible for it to call Java stored procs. As it is possible for it to call PL procs. But these are via the formal call interface of those languages - not via tight integration hooks that blur the languages and make SQL and Java, or SQL and PL, look like a single integrated source code unit.
    Thus SQL has the pretty much the same constraints in calling the PL language as other languages do. What SQL can do is use the PL engine's call interface and tell it "+execute this function and return the result of the function+".

  • SQL developer with jre but no jdk

    Is there a way i can install sql developer with only jre installed in my windows system.
    Im trying to install to sql developer 64 bit and when i run the exe file it asks for java.exe file path.
    When i give it to the path to exe file in jre/bin it gives an error cannot find j2se sdk installed in jre directory.

    Normally SQLDeveloper requires a JDK and so will not accept a JRE.
    You can try to bypass this check by filling in the SetJavaHome property manually in the sqldeveloper.conf file usually located in
    SQLDEVELOPER_INSTALL_DIR/sqldeveloper/binby doing this you are not guaranteed to succeed, because some of the functions of SQLDeveloper specifically requires the JDK and so if you use these functions you will most probably incur in errors or unexpected behavior.
    The best thing to do IMHO is to install a proper JDK.
    If you do not have the right to do so you can also copy and already installed JDK from another machine and it usually works well enough.

  • Oracle PL/SQL Package - DB Adapter

    Hi All
    We have PL/SQL package with more than 20 procedures/functions. We prefer to use Oracle DB Adapter and host as webservices
    1. Is there a way to generate a single WSDL/XSD compatible to Oracle DB Adpater for a package ?
    2. Should we generate 20 WSDL/XSD for each of these procedures?
    Any idea on how could we achieve it cleaner and quicker. It is to make a decision whether we should stick with Oracle DB Adapter or host a simple Java Webservice.
    Any comments is appreciable.
    Regards
    Prasad Jayakumar
    Pls Note: I have posted this thread originally in
    Oracle PL/SQL Package - DB Adapter

    Sorry for the late reply. As you state there is no option to manage multiple operations in a DB Adapter.
    To explain my ESB example better, what I mean by this is that you can create a WSDL that has multiple operations, these operations will be based on the procedures in your packages. In your OSB process you can create multiple DB adapters calling the individual procedures of the package. Based on the operation being invoked you can route to the appropriate DB Adapter.
    Therefore the pros and cons
    PL/SQL Web Service
    One service to call multiple procedures in the PL/SQL package
    Lacks visibility through the management consoles
    If your PL/SQL changes will affect the Web Service implementation which may also all clients calling it.
    More of a point to point solution.
    OSB
    Able to add and remove procedures as required.
    Can add procedures and/or functions that are not part of a package
    Manage service endpoints if the PL/SQL changes. Meaning 3rd party objects can remain unchanged.
    If you have hundreds of procedures in your package it will take long time to create individual adapters.
    This is not an exhaustive list but to will get an idea.
    cheers
    James

  • PL/sql packages as webservices

    Is it possible to expose Pl/sql packages with procedures returning more than one ( multiple ) weakly defined refcursors as web services ? if so how ?
    Deepa

    Hi Deepa,
    Here is a document which discusses about returning RefCursors from a PL/SQL stored procedure published as a Web Service. You could look at that for ideas.
    Hope this helps.
    Sujatha.
    http://otn.oracle.com/sample_code/content.html

  • Package with sdo_geometry has become invalid

    I'm confused...
    I verified this package is the same as it was a month ago.. but now it is invalid and will not recompile.. no database upgrades/patches have happened.
    database is 11.2.0.2 patch level 12
    error is PLS-00905 Object sdo_geometry is invalid on:
    I recreated a test package with only this line and it still fails:
    CREATE OR REPLACE PACKAGE "GEOM_OP_TEST" AUTHID CURRENT_USER is
    FUNCTION GET_SIMPLIFIED_GEOMETRY(geom in SDO_GEOMETRY, tolerance in NUMBER) RETURN SDO_GEOMETRY DETERMINISTIC;
    end;
    I have followed ID:270588.1 and verified that spatial is valid and all objects are valid..
    this code does compile if I add MDSYS. in front of SDO_GEOMETRY.. but it has not been that way in the past..
    I verfied that MDSYS.SDO_GEOMETRY is still granted to public..
    I verfied that the public synonym for it still exists and is valid..

    figured it out.. someone created something in the current schema and called it SDO_GEOMETRY...
    dropped it and the issue went away...

  • Problems with PL/SQL packages

    Hello,
    I face the following problem with PL/SQL stored procedures. The Oracle
    version is 8.0.5 on Windows NT 4. The PL/SQL package has a set of procedures and functions.
    The main procedure of the PL/SQL package is triggered from VC++ executable. If for some reason,
    an exception is caught in the stored procedure (like no_data_found
    exception), then the following problem occurs.
    If we try to trigger the stored procedure again through the VC++ executable,
    the variables in the stored procedures have the values as in the previous
    execution. They are not getting initialised. (The same database connection
    is used in VC++ executable).
    Currently, only if a new connection to the database is used , the problem is
    solved.
    Also, change in the input parameters of the procedure is not reflected, once the procedure fails because of any exception. Only the input which was given during the time of execution when the procedure failed,is considered.
    What could be the reason for this problem and how can this be corrected?
    Please send in your suggestions.
    Thanks and Regards,
    Ramya Priya
    null

    Hi Keith,
    I am connecting to the database as the package owner..
    I have noticed earlier that I have problems when capturing triggers also.. The content of one large trigger contains 36371 characters and when capturing it from DB, the content was truncated to 28020 characters in Designer.
    Our ideas with capturing the DB packages/procedures were to use the Designer as version control system.
    We wanted to have all objects used in a project in Designer.. entities, tables, triggers, packages, procedures, Forms files, etc. in order to make a configuration for a project release.
    Thank you,
    Claudia

  • How could I replace hard coded value in my sql query with constant value?

    Hi all,
    Could anyone help me how to replace hardcoded value in my sql query with constant value that might be pre defined .
    PROCEDURE class_by_day_get_bin_data
         in_report_parameter_id   IN   NUMBER,
         in_site_id               IN   NUMBER,
         in_start_date_time       IN   TIMESTAMP,
         in_end_date_time         IN   TIMESTAMP,
         in_report_level_min      IN   NUMBER,
         in_report_level_max      IN   NUMBER
    IS
      bin_period_length   NUMBER(6,0); 
    BEGIN
      SELECT MAX(period_length)
         INTO bin_period_length
        FROM bin_data
         JOIN site_to_data_source_lane_v
           ON bin_data.data_source_id = site_to_data_source_lane_v.data_source_id
         JOIN bin_types
           ON bin_types.bin_type = bin_data.bin_type 
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time     >= in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time     <  in_end_date_time   + numtodsinterval(1, 'DAY')
         AND bin_data.bin_type            =  2
         AND bin_data.period_length       <= 60;
      --Clear the edr_class_by_day_bin_data temporary table and populate it with the data for the requested
      --report.
      DELETE FROM edr_class_by_day_bin_data;
       SELECT site_to_data_source_lane_v.site_id,
             site_to_data_source_lane_v.site_lane_id,
             site_to_data_source_lane_v.site_direction_id,
             site_to_data_source_lane_v.site_direction_name,
             bin_data_set.start_date_time,
             bin_data_set.end_date_time,
             bin_data_value.bin_id,
             bin_data_value.bin_value
        FROM bin_data
        JOIN bin_data_set
          ON bin_data.bin_serial = bin_data_set.bin_serial
        JOIN bin_data_value
          ON bin_data_set.bin_data_set_serial = bin_data_value.bin_data_set_serial
        JOIN site_to_data_source_lane_v
             ON bin_data.data_source_id = site_to_data_source_lane_v.data_source_id
            AND bin_data_set.lane = site_to_data_source_lane_v.data_source_lane_id
        JOIN (
               SELECT CAST(report_parameter_value AS NUMBER) lane_id
                 FROM report_parameters
                WHERE report_parameters.report_parameter_id    = in_report_parameter_id
                  AND report_parameters.report_parameter_group = 'LANE'
                  AND report_parameters.report_parameter_name  = 'LANE'
             ) report_lanes
          ON site_to_data_source_lane_v.site_lane_id = report_lanes.lane_id
        JOIN (
               SELECT CAST(report_parameter_value AS NUMBER) class_id
                 FROM report_parameters
                WHERE report_parameters.report_parameter_id    = in_report_parameter_id
                  AND report_parameters.report_parameter_group = 'CLASS'
                  AND report_parameters.report_parameter_name  = 'CLASS'
             ) report_classes
          ON bin_data_value.bin_id = report_classes.class_id
        JOIN edr_rpt_tmp_inclusion_table
          ON TRUNC(bin_data_set.start_date_time) = TRUNC(edr_rpt_tmp_inclusion_table.date_time)
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time     >= in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time     <  in_end_date_time   + numtodsinterval(1, 'DAY')
         AND bin_data_set.start_date_time >= in_start_date_time
         AND bin_data_set.start_date_time <  in_end_date_time
         AND bin_data.bin_type            =  2
         AND bin_data.period_length       =  bin_period_length;
    END class_by_day_get_bin_data;In the above code I'm using the hard coded value 2 for bin type
    bin_data.bin_type            =  2But I dont want any hard coded number or string in the query.
    How could I replace it?
    I defined conatant value like below inside my package body where the actual procedure comes.But I'm not sure whether I have to declare it inside package body or inside the procedure.
    bin_type     CONSTANT NUMBER := 2;But it does't look for this value. So I'm not able to get desired value for the report .
    Thanks.
    Edited by: user10641405 on May 29, 2009 1:38 PM

    Declare the constant inside the procedure.
    PROCEDURE class_by_day_get_bin_data(in_report_parameter_id IN NUMBER,
                                        in_site_id             IN NUMBER,
                                        in_start_date_time     IN TIMESTAMP,
                                        in_end_date_time       IN TIMESTAMP,
                                        in_report_level_min    IN NUMBER,
                                        in_report_level_max    IN NUMBER) IS
      bin_period_length NUMBER(6, 0);
      v_bin_type     CONSTANT NUMBER := 2;
    BEGIN
      SELECT MAX(period_length)
        INTO bin_period_length
        FROM bin_data
        JOIN site_to_data_source_lane_v ON bin_data.data_source_id =
                                           site_to_data_source_lane_v.data_source_id
        JOIN bin_types ON bin_types.bin_type = bin_data.bin_type
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time >=
             in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time <
             in_end_date_time + numtodsinterval(1, 'DAY')
         AND bin_data.bin_type = v_bin_type
         AND bin_data.period_length <= 60;
      --Clear the edr_class_by_day_bin_data temporary table and populate it with the data for the requested
      --report.
      DELETE FROM edr_class_by_day_bin_data;
      INSERT INTO edr_class_by_day_bin_data
        (site_id,
         site_lane_id,
         site_direction_id,
         site_direction_name,
         bin_start_date_time,
         bin_end_date_time,
         bin_id,
         bin_value)
        SELECT site_to_data_source_lane_v.site_id,
               site_to_data_source_lane_v.site_lane_id,
               site_to_data_source_lane_v.site_direction_id,
               site_to_data_source_lane_v.site_direction_name,
               bin_data_set.start_date_time,
               bin_data_set.end_date_time,
               bin_data_value.bin_id,
               bin_data_value.bin_value
          FROM bin_data
          JOIN bin_data_set ON bin_data.bin_serial = bin_data_set.bin_serial
          JOIN bin_data_value ON bin_data_set.bin_data_set_serial =
                                 bin_data_value.bin_data_set_serial
          JOIN site_to_data_source_lane_v ON bin_data.data_source_id =
                                             site_to_data_source_lane_v.data_source_id
                                         AND bin_data_set.lane =
                                             site_to_data_source_lane_v.data_source_lane_id
          JOIN (SELECT CAST(report_parameter_value AS NUMBER) lane_id
                  FROM report_parameters
                 WHERE report_parameters.report_parameter_id =
                       in_report_parameter_id
                   AND report_parameters.report_parameter_group = 'LANE'
                   AND report_parameters.report_parameter_name = 'LANE') report_lanes ON site_to_data_source_lane_v.site_lane_id =
                                                                                         report_lanes.lane_id
          JOIN (SELECT CAST(report_parameter_value AS NUMBER) class_id
                  FROM report_parameters
                 WHERE report_parameters.report_parameter_id =
                       in_report_parameter_id
                   AND report_parameters.report_parameter_group = 'CLASS'
                   AND report_parameters.report_parameter_name = 'CLASS') report_classes ON bin_data_value.bin_id =
                                                                                            report_classes.class_id
          JOIN edr_rpt_tmp_inclusion_table ON TRUNC(bin_data_set.start_date_time) =
                                              TRUNC(edr_rpt_tmp_inclusion_table.date_time)
         WHERE site_to_data_source_lane_v.site_id = in_site_id
           AND bin_data.start_date_time >=
               in_start_date_time - numtodsinterval(1, 'DAY')
           AND bin_data.start_date_time <
               in_end_date_time + numtodsinterval(1, 'DAY')
           AND bin_data_set.start_date_time >= in_start_date_time
           AND bin_data_set.start_date_time < in_end_date_time
           AND bin_data.bin_type = v_bin_type
           AND bin_data.period_length = bin_period_length;
    END class_by_day_get_bin_data;

  • Are PL/SQL Package Body Constants in Shared Area or Private Area

    Based on this it not clear to me if PL/SQL Package Body Constants are stored in shared area or private area.
    http://docs.oracle.com/cd/B28359_01/server.111/b28318/memory.htm
    "PL/SQL Program Units and the Shared Pool
    Oracle Database processes PL/SQL program units (procedures, functions, packages, anonymous blocks, and database triggers) much the same way it processes individual SQL statements. Oracle Database allocates a shared area to hold the parsed, compiled form of a program unit. Oracle Database allocates a private area to hold values specific to the session that runs the program unit, including local, global, and package variables (also known as package instantiation) and buffers for executing SQL. If more than one user runs the same program unit, then a single, shared area is used by all users, while each user maintains a separate copy of his or her private SQL area, holding values specific to his or her session.
    Individual SQL statements contained within a PL/SQL program unit are processed as described in the previous sections. Despite their origins within a PL/SQL program unit, these SQL statements use a shared area to hold their parsed representations and a private area for each session that runs the statement."
    I am also curious what are the fine grained differences from a memory and performance perspective (multi-session) for the two examples below. Is one more efficient?
    Example 1.
    create or replace
    package body
    application_util
    as
    c_create_metadata constant varchar2(6000) := ...
    procedure process_xxx
    as
    begin
    end process_xxx;
    end application_util;
    vs.
    Example 2.
    create or replace
    package body
    application_util
    as
    procedure process_xxx
    as
    c_create_metadata constant varchar2(6000) := ...
    begin
    end process_xxx;
    end application_util;

    >
    What i am asking is fairly granular, so here it is again, let's assume latest version of oracle..
    In a general sense, is the runtime process able to manage memory more effectively in either case, one even slightly more performant, etc
    ie does example 1 have different memory management characteristics than example 2.
    Specifically i am talking about the memory allocation and unallocation for the constant varchar2(6000)
    Ok, a compiler's purpose is basically to create an optimized execution path from source code.
    The constant varchar2(6000) := would exist somewhere in the parse tree/execution path (this is stored in the shared area?).
    I guess among the things i'm after is
    1) does each session use space needed for an additional varchar2(6000) or does runtime processor simply point to the constant string in the parse tree (compiled form which is shared).
    2) if each session requires allocation of space needed for an additional varchar2(6000), then for example 1 and example 2
    at what point does the constant varchar allocation take place and when is the memory unallocated.
    Basically does defining the constant within the procedure have different memory characteristics than defining the constant at the package body level?
    >
    Each 'block' or 'subprogram' has a different scope. So the 'constant' defined in your example1 is 'different' (and has a different scope) than the 'constant' defined in example2.
    Those are two DIFFERENT objects. The value of the 'constant' is NOT assigned until control passes to that block.
    See the PL/SQL Language doc
    http://docs.oracle.com/cd/E14072_01/appdev.112/e10472/fundamentals.htm#BEIJHGDF
    >
    Initial Values of Variables and Constants
    In a variable declaration, the initial value is optional (the default is NULL). In a constant declaration, the initial value is required (and the constant can never have a different value).
    The initial value is assigned to the variable or constant every time control passes to the block or subprogram that contains the declaration. If the declaration is in a package specification, the initial value is assigned to the variable or constant once for each session (whether the variable or constant is public or private).
    >
    Perhaps this example code will show you why, especially for the second example, a 'constant' is not necessarily CONSTANT. ;)
    Here is the package spec and body
    create or replace package pk_test as
      spec_user varchar2(6000);
      spec_constant varchar2(6000) := 'dummy constant';
      spec_constant1 constant varchar2(6000) := 'first constant';
      spec_constant2 constant varchar2(6000) := 'this is the second constant';
      spec_constant3 constant varchar2(6000) := spec_constant;
      procedure process_xxx;
      procedure change_constant;
    end pk_test;
    create or replace package body pk_test as
    procedure process_xxx
    as
      c_create_metadata constant varchar2(6000) := spec_constant;
    begin
      dbms_output.put_line('constant value is [' || c_create_metadata || '].');
    end process_xxx;
    procedure change_constant
    as
    begin
      spec_constant := spec_constant2;
    end change_constant;
    begin
      dbms_output.enable;
      select user into spec_user from dual;
      spec_constant := 'User is ' || spec_user || '.';
    end pk_test;The package init code sets the value of a packge variable (that is NOT a constant) based on the session USER (last code line in package body).
    The 'process_xxx' procedure gets the value of it's 'constant from that 'non constant' package variable.
      c_create_metadata constant varchar2(6000) := spec_constant;The 'change_constant' procedure changes the value of the package variable used as the source of the 'process_xxx' constant.
    Now the fun part.
    execute the 'process_xxx' procedure as user SCOTT.
    SQL> exec pk_test.process_xxx;
    constant value is [User is SCOTT.].Now execute 'process_xxx' as another user
    SQL> exec pk_test.process_xxx;
    constant value is [User is HR.].Now exec the 'change_constant' procedure.
    Now exec the 'process_xxx' procedure as user SCOTT again.
    SQL> exec pk_test.process_xxx;
    constant value is [this is the second constant].That 'constant' defined in the 'process_xxx' procedure IS NOT CONSTANT; it now has a DIFFERENT VALUE.
    If you exec the procedure as user HR it will still show the HR constant value.
    That should convince you that each session has its own set of 'constant' values and so does each block.
    Actually the bigger memory issue is the one you didn't ask about: varchar2(6000)
    Because you declared that using a value of 6,000 (which is 2 ,000 or more) the actual memory allocation not done until RUN TIME and will only use the actual amount of memory needed.
    That is, it WILL NOT pre-allocate 6000 bytes. See the same doc
    http://docs.oracle.com/cd/E14072_01/appdev.112/e10472/datatypes.htm#CJAEDAEA
    >
    Memory Allocation for Character Variables
    For a CHAR variable, or for a VARCHAR2 variable whose maximum size is less than 2,000 bytes, PL/SQL allocates enough memory for the maximum size at compile time. For a VARCHAR2 whose maximum size is 2,000 bytes or more, PL/SQL allocates enough memory to store the actual value at run time. In this way, PL/SQL optimizes smaller VARCHAR2 variables for performance and larger ones for efficient memory use.
    For example, if you assign the same 500-byte value to VARCHAR2(1999 BYTE) and VARCHAR2(2000 BYTE) variables, PL/SQL allocates 1999 bytes for the former variable at compile time and 500 bytes for the latter variable at run time.
    >
    So when you have variables and don't know how much space is really needed do NOT do this:
    myVar1 VARCHAR2(1000);
    myVar2 VARCHAR2(1000);
    myVar3 VARCHAR2(1000);The above WILL allocate 3000 bytes of expensive memory even if it those variables are NEVER used.
    This may look worse but, as the doc states, it won't really allocate anything if those variables are not used. And when they are used it will only use what is needed.
    myVar1 VARCHAR2(2000);
    myVar2 VARCHAR2(2000);
    myVar3 VARCHAR2(2000);

  • Designer 9.0.2.7 - problems with capturing PL/SQL packages

    Hello,
    I would appreciate any help regarding the following issue:
    We tried to capture in Designer 9.0.2.7 the existing PL/SQL packages from an Oracle 9i database and we have met some problems.
    Even the package has a body containing two public procedures, when capturing, the Designer generates warnings that say the PL/SQL package body is empty. Therefore, the Designer capture the body content and write it in the PL/SQL Block of the PL/SQL Definition property, but the content of the body is preceded with the " character.
    This makes problem when generating the "ddl" for the package (the package is not created correctly in the DB).
    In addition, when generating the "ddl", the "END package_name" is added twice.
    Other problem is that the package specification information from Designer is just "END package_name;"
    For some of the packages containing only a list of public procedures, without any other variables declarations, the Designer does not capture these procedures as separate subprograms in the package definition, as it does other times. In this case, the package body is entirely captured in the PL/SQL Block and with the " character before content.
    Is it some settings that can be done or some rules about the format of the PL/SQL procedures in order for Designer to capture all packages in same manner and correctly?
    Thank you,
    Claudia

    Hi Keith,
    I am connecting to the database as the package owner..
    I have noticed earlier that I have problems when capturing triggers also.. The content of one large trigger contains 36371 characters and when capturing it from DB, the content was truncated to 28020 characters in Designer.
    Our ideas with capturing the DB packages/procedures were to use the Designer as version control system.
    We wanted to have all objects used in a project in Designer.. entities, tables, triggers, packages, procedures, Forms files, etc. in order to make a configuration for a project release.
    Thank you,
    Claudia

  • Pl/sql package for use with workflow will not return a value

    hi all,
    just trying to intercept a requisition being turned into an order if it uses a certain cost code. so i have amended the workflow and created a package to check what cost centre a requisition is using. how over the workflow stops on the function that calls the package witha a status of complete as if the package is not returning any values.
    the package is as below:
    CREATE OR REPLACE PACKAGE APPS.xxhccWFcapitalcheck AS
    procedure XXHCC_CHECK_CAPITAL(itemtype in varchar2,
    itemkey in varchar2,
    actid in number,
    funcmode in varchar2,
    resultout out NOCOPY vARCHAR2);
    END xxhccWFcapitalcheck;
    CREATE OR REPLACE PACKAGE BODY APPS.xxhccWFcapitalcheck AS
    procedure XXHCC_CHECK_CAPITAL(itemtype in varchar2,
    itemkey in varchar2,
    actid in number,
    funcmode in varchar2,
    resultout out NOCOPY varchar2 ) is
    x_progress varchar2(100);
    x_resultout varchar2(30);
    l_doc_mgr_return_val VARCHAR2(1);
    l_doc_string varchar2(200);
    l_preparer_user_name varchar2(100);
    doc_manager_exception exception;
    p_test varchar2(100);
    l_req_id varchar2(30);
    CURSOR p_line_id IS
    SELECT
    codes.segment2 cost_center
    FROM
    po_requisition_headers_all headers,
    po_requisition_lines_all lines,
    po_req_distributions_all dist,
    gl_code_combinations_v codes
    WHERE
    headers.requisition_header_id = lines.requisition_header_id
    AND
    lines.requisition_line_id = dist.requisition_line_id
    AND
    dist.code_combination_id = codes.code_combination_id
    AND
    headers.segment1 = l_req_id;
    line_rec p_line_id%rowtype;
    BEGIN
    -- Do nothing in cancel or timeout mode
    --if (funcmode <> wf_engine.eng_run) then
    -- resultout := wf_engine.eng_null;
    -- return;
    -- end if;
    l_req_id := wf_engine.GetItemAttrNumber (itemtype => itemtype,
    itemkey => itemkey,
    aname => 'DOCUMENT_NUMBER');
    --FOR line_rec in p_line_id
    ---loop
    open p_line_id;
    fetch p_line_id into l_doc_string;
    close p_line_id;
    IF p_line_id= 'Q9DEF'
    dbms_output.put_line p_line_id;
    Then resultout := 'COMPLETE:F';
    return;
    p_test := 'USE DIFFERENT CODE';
    ELSE
    resultout := 'COMPLETE:T';
    return;
    END IF;
    END LOOP;
    end;
    END xxhccWFcapitalcheck;
    any help would be great!

    Hi Community,  first of all, english is not my native language and im not sure to use the correct terms for PowerCenter - so if im wrong please help me correct and make clear what we need. We have a kind of 3-steps ToDo. First step: Load data from an external source into a "local" datastore (its an oracle db on a server in our "hands")Second step: Check data against several verifications, this is done with a PL/SQL Package. The PL/SQL Package shall be called with an Interfacename who is set in the First PowerCenter Mapping. Our current thoghts are to do this via a stored procedure, which runs as "Target Post Load" and gets a variable "Interface Name".Is that possible? Im not quite sure about it. About the last part its even more unclear how we can solve it:Third part should be switch back to PowerCenter now - and the package (or to be correct a function in the package) should return a value for "okay everything fine => workflow continue" or "something happened => workflow is stopped" Im not sure how i can handle this. I hope my explanations are good enough so you can provide some help?!If there are any questions please ask!  Thank you alot, best regards, Christian

  • Running a SSIS package with SQL Job and Linked Server

    I have a SSIS 2008 package. In one of the Script task I am calling a stored procedure which is  using Openquery using linked server. I deployed this package with protection level as "EncryptWithPassword" and gave a password to the package.
    Created a SQL job and edited its command line to include the password. If I login to SQL Server Mgmt Studio with Windows Authentication and run the job manually it runs fine. But when I schedule it then I get an error that "The Communication link to Linked
    server failed".
    Please help 

    Hi Vivek.B,
    The issue should occur because the SQL Server Agent Service Account or SQL Agent Proxy account under which the job step runs doesn’t have sufficient permissions on the linked server.
    If the job owner is the sysadmin fixed server role, the job can be run under the SQL Server Agent Service Account or a proxy account, then please make sure the SQL Agent Service Account or the proxy account has corresponding login on the linked server. If
    the job owner is not a sysadmin fixed server role, the job must run under a proxy account. In this case, make sure the proxy account has a corresponding login on the linked server.
    Reference:
    http://blogs.msdn.com/b/dataaccesstechnologies/archive/2009/10/13/who-owns-my-job-and-who-runs-it.aspx
    Regards,
    Mike Yin
    TechNet Community Support

Maybe you are looking for

  • Is there a way to create still jpegs from video clips in iMovie?

    I shot some video on Christmas day and imported them to iMovie 9. I want to creat some jpegs from the video clips and print them as photos. Is there a way to create a jpeg from a video clip and save the file? Thanks for the info! Len

  • Setup won't detect the router

    Every time i run setup(on both my PCs), it won't recognzie the router. I have all the cables hooked up correctly,and even my USB adapter on my other PC is on the network. The problem is that one cannot access the internet. The router i bought is lega

  • I forgot my apple password  and i forgot the security q , and i think somebody hacks my email . please help

    i forgot my apple password  and i forgot the security q , and i think somebody hacks my email . please help!!! this is it ([email protected])

  • Bookmark issues In Acrobat Pro!

    Hi everyone, Over the past month we have been having issues where a customer of our's when she is creating PDF files from Word, she isn't able to add bookmarks to certain paragraphs or link any of the document to Acrobat Pro X after the document is c

  • No sound on AVI output

    When outputing an AVI from AE I don't get any sound even when the audio output is selected., However it does work on Mpeg Files. Running window 7 professional 64bit AE CS6 Please help