Management of literal values in PL/SQL

Running on Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit Production with the partitioning, and OLAP options jserver 9.2.0.8.0 - Production release

We need manipulate some specific values when running and decided on storing them in a table. Our PL/SQL code retrieves these values to use in queries various etc. such as limiting a cursor to a number of lines, or change a constant in a package, etc.

I looked in the best site of Steven Feuerstein practices regarding the management of the "magic values" in PL/SQL. We have implemented a solution based on his column: http://apex.oracle.com/pls/otn/f?p=2853:4:271093498565934:NO:P4_QA_ID:16382

Essentially a table support our "literal" value of data, with a packaged function to retrieve a value given by its name since another PL/SQL package.

Now to avoid multiple calls to literal value get functions, I create a global variable in the package body and retrieve literal value given in it. I then use this global variable throughout the body pacakge.

For example:
g_bulk_mailer_email            VARCHAR2 (255)
      := pkg_application_constant.varchar2_value ('BULK_MAILER_EMAIL_ADDRESS');
The problem I'm facing is, when I change the literal value of BULK_MAILER_EMAIL_ADDRESS in the database table, it does not apply to my global variable g_bulk_mailer_email in my package body. I guess because the package is already initialized and pinned in the UGA?

Is this a case for the SERIALLY_REUSABLE pragma, or the poor implementation/design on my part?

An alternative that I thought is all simply do not use the global variable and simply make several local calls required in my package routines, so it still gets the last values of the literal value table.

PS once we move to 11g, I intend on using the function result cache...

Thanks for any tips/advice

Stéphane

I think it's the downside of caching of values - you're caching them if you have not used it refresh the. It of one or the other, until (as you mentioned) you get to 11g and can use the result cache and have Oracle manage in memory. I don't think that there is a way to implement the cache of result of 11g in 9i PL/SQL.

The only thing that comes to mind is to have your code refers to a function rather than the global variable directly, and have the capture sysdate function when it meets the global variable, and then each time it is called could check against present and update the value if more than 10 minutes passed, otherwise return the cached value. If the arithmetic mean of date cost you more CPU resources than you save in research of repeat I don't know, if.

Tags: Database

Similar Questions

  • Calculation for cutting the first part of the string in the Manager list item values

    Hello

    Please help me with a calculation after submit pl/sql function process for cutting the first part of the string (CQ.) within the values of list manager. For example the list manager support contains values such as

    CQ... SAMPLE1... TEST1

    CQ... SAMPLE2... TEST2

    CQ... SAMPLE1... TEST2

    The calculation process should cut the first part(CQ..) and must return to the list of values of Manager as

    SAMPLE1... TEST1

    SAMPLE2... TEST2

    SAMPLE1... TEST2

    Oracle APEX 4.0.2 is the version and Oracle 10 g r2 is the database.

    Please help me with possible approaches in the development of the service. Thanks in advance.

    Thank you

    Orton

    orton607 wrote:

    But when I insert/update Manager list item values I don't want the first part of the string in the database.

    I still don't understand why you can't change the LOV or create a new...

    The LOV should be:

    SELECT original_value  AS HUMAN_SEES_THIS_VALUE
        ,LTRIM (SUBSTR ( original_value, INSTR (original_value, '..') + 2))
          AS DATABASE_GETS_THIS_VALUE
    FROM (
      -- place original SQL for LOV here
    )
    
  • Execution plan will change if I use the variable binding instead of the literal value?

    Hi guys,.

    Suppose I have a select "... Of... WHERE ID = 2 and... "if I go to use the variable binding instead of the literal value 2," SELECT... " Of... WHERE ID =: p_id and... ", the execution plan change?
    I test multiple statements, the plan does not change, but I don't know if it would even as well as in some other cases.
    Someone at - it ideas?

    Thank you very much.

    Anneso wrote:
    Hi, sorry for the unclear post, it's 11 GR 2.

    As Sybrand already mentioned, there are a lot of change that came in the implementation of the bind variable in some versions of Oracle db. Since you're on 112, it is still true with the introduction of Adaptive Cursor Sharing . Please have a read on it since the post below written by the development of Oracle optimizer group.
    http://blogs.Oracle.com/optimizer/entry/why_are_there_more_cursors_in_11g_for_my_query_containing_bind_variables_1

    Aman...

  • How to return the value of the SQL in the text element

    Hi friends

    I need you to guide me how I can print the return value of the SQL in a text element

    Suppose it's your function
    create or replace function get_value
    return number
    is
    begin
    return 3*2;
    end;
    /
    any help that I enjoyed

    Thank you

    >

    http://i46.Tinypic.com/11l0s5h.jpg

    This is ORA-06502: PL/SQL: digital error or value.

    Check the data type and size for items of text or any other variables or fields in the service.

  • Generation of a dynamic value through pl/sql in shell.

    Hi all


    Generation of a dynamic value through pl/sql in shell.

    host_command ("echo" Insert into CUSTOM (FIRSTNAME) VALUES ("| v_temp |");) « ») ;


    Output current:

    Insert into CUSTOMERS (FIRSTNAME) VALUES (John);

    power required:

    Insert into CUSTOMERS (FIRSTNAME) VALUES ('John');

    Thank you.

    Your request must so->

    host_command ('echo " Insert into CUSTOM (FIRSTNAME) VALUES ('||chr(39)||v_temp||chr(39)||');" ');
    

    Kind regards.

    LOULOU.

  • Looking for example of the Manager to OBTAIN with the PL/SQL source type

    Hello

    I currently have a Manager GET job with a running QUERY source type in ADR 3.0.  The call returns the number of records (hundreds, or even thousands of 10) in JSON and allows the user to navigate through the results.

    The call accepts several parameters that I convey just in the place where the clause of the query in the Manager.  Data is retrieved by the beach date (s).

    To prevent queries runaway with ranges for a long time, I've implemented a logic in the sql statement to limit the applicant.  The applicant requested an error thrown instead.  There are other limits that I'm imposing on other entries I need to provide useful errors for example.

    I would like to change the call GET use PL/SQL type instead of the type of REQUEST so that I can do validation on entries and send useful return error messages if necessary, however I can't find examples online.

    Are there any examples (or alternatives) would be greatly appreciated.

    Thank you

    Anthony

    Hello

    You can use the Pipelined functions to generate your recordset plsql and then just use a select statement of the function in the pipeline in the service definition.

  • Error 1406: could not write to key \software value when installing SQL Server 2014 on win 8

    I could not find an appropriate category to post this question to

    I have problems installins SQL Server management Studio

    I tried different steps from

    Change the permissions of the local user during execution of the registry editor and the installer with administrator

    I checked more similar posts here in the forums and followed their steps, but no progress

    This is the error message

    I could not resolve so far, I am in this problem for 4 days, until now tried various suggestions but no progress, I'm in a hurry, so please help me

    Kind regards

    Omar

    This issue is beyond the scope of this site and must be placed on Technet or MSDN

    http://social.technet.Microsoft.com/forums/en-us/home

    http://social.msdn.Microsoft.com/forums/en-us/home

  • Preserve Bind values in the SQL worksheet

    Hello

    When you run the SQL statements with var/binding settings, SQLD can persist values entered the tool reboots?

    Is there a preference that controls this?

    Java (TM) Platform1.7.0_71
    Oracle IDE4.0.3.16.84
    Support for versioning4.0.3.16.84

    Thank you

    Manish

    Never mind. Found, he looked at me, but I was blind.

    Under the worksheet, check 'Save the Bind Variables on the disc to the output'.

  • Passing the value of the SQL query select list

    Hello

    In my application users have in their homepage to a region which has two simple things, a part of LIST SLECT lov function and a BUTTON

    There is also another page which has a normal life to report which shows the employees.


    Homepage the user can select certain number of Department in its 'SLECT-LIST' and click 'open '.


    For example: If the user has selected a DEP_NUM_5 and click on the BUTTON it will be redirected to the page of a report and gets only showed the employees belonging to the Department 5.


    The report page contains a simple SQL query, and I understand that somehow I must pass the value in the SELECT LIST, where I now have the '?


    How can I do this, where should I start?

    Of course I would really appreciate an example of code, if anyone has time to do a.

    
    select "EMP_ID", 
    "EMP_FORNAME",
    "EMP_SURNAME",
    "DEP_NUMBER"
    from EMP E
    where E.DEP_NUMBER = ????????
    
    

    Hi Sozua,

    1. create an item hidden on the page where you have the report.

    I say P2_DEPT_NO

    2 assign to that in your sql query

    select "EMP_ID",
        "EMP_FORNAME",
        "EMP_SURNAME",
        "DEP_NUMBER"
        from EMP E
        where E.DEP_NUMBER = :P2_DEPT_NO
    

    below the area source ther is also an option

    Elements of page to submit-> put this element in this.

    for example;

    Page to submit items: P2_DEPT_NO

    3. change your button

    Action: Redirecting to page of this application

    Page: 2 / / assuming that page 2 is the report page

    Place these items: P2_DEPT_NO

    with these values: & P1_SELECT_LIST.  assuming that selection list is on page 1

    Hope this helps you,

    Kind regards

    Jitendra

  • Dynamic action with multiple values of PL/SQL Expression as a condition

    Hel

    I am currently using Apex 4.0 for a schoolproject.

    I have two selectlists (P8_BUSINESSRULETYPE - which has al businessruletypes) and (P8_OPERATOR) that has a select statement based on the businessruletype.

    I want to hide the selectlist operator when P8_BUSINESSRULETYPE = 7,8,9 and 10 or P8_OPERATOR = 9

    When: change

    SelectionType article (s)

    Elements P8_BUSINESSRULETYPE

    condition: equal to 10

    Real actions: hide items p8_operator

    False actions: show p8_operator items

    ConditionType PL/SQL EXPRESSION

    : P8_BUSINESSRULETYPE = 10 OR: P8_BUSINESSRULETYPE = 8 OR: P8_BUSINESSRULETYPE = 7 OR: P8_BUSINESSRULETYPE = 9

    What is the problem with my dynamic action? Because he does not hide the operatorfield when businessruletype 10 or 9 are selected in the selectlist. Sessions has also said operator = 9 and Businessruletype = 10

    I hope you guys can help out me.

    Thank you very much.

    2843640 wrote:

    Please update your forum profile with a real handle instead of '2843640 '.

    I am currently using Apex 4.0 for a schoolproject.

    I have two selectlists (P8_BUSINESSRULETYPE - which has al businessruletypes) and (P8_OPERATOR) that has a select statement based on the businessruletype.

    I want to hide the selectlist operator when P8_BUSINESSRULETYPE = 7,8,9 and 10 or P8_OPERATOR = 9

    When: change

    SelectionType article (s)

    Elements P8_BUSINESSRULETYPE

    condition: equal to 10

    Real actions: hide items p8_operator

    False actions: show p8_operator items

    ConditionType PL/SQL EXPRESSION

    : P8_BUSINESSRULETYPE = 10 OR: P8_BUSINESSRULETYPE = 8 OR: P8_BUSINESSRULETYPE = 7 OR: P8_BUSINESSRULETYPE = 9

    What is the problem with my dynamic action? Because he does not hide the operatorfield when businessruletype 10 or 9 are selected in the selectlist. Sessions has also said operator = 9 and Businessruletype = 10

    The first thing is that a Condition that is applied to a control of dynamic action if the dynamic action is made the see page. She has therefore no impact on the question of whether the actions of true or false are performed. Control conditions which are those defined in the when the properties of the dynamic action. As they are evaluated in the browser, they must be specified as JavaScript.

    Secondly, this expression is not valid because it is a space between the colon and the identifiers. Link the names of rating, the colon and the variable element must be contiguous:

    :P8_BUSINESSRULETYPE = 10 OR :P8_BUSINESSRULETYPE = 8  OR :P8_BUSINESSRULETYPE = 7 OR :P8_BUSINESSRULETYPE = 9
    

    However the latter is only of academic interest, in this case you need to remove the condition of dynamic action.

    In the dynamic of change when action section, P8_BUSINESSRULETYPE, P8_OPERATOR, Condition of JavaScript Expressionand value to the value of the item (s)

       ($v('P8_BUSINESSRULETYPE') == '7')
    || ($v('P8_BUSINESSRULETYPE') == '8')
    || ($v('P8_BUSINESSRULETYPE') == '9')
    || ($v('P8_BUSINESSRULETYPE') == '10')
    || ($v('P8_OPERATOR') == '9')
    

    If you are using a browser that supported, this can be simplified to

       (['7', '8', '9', '10'].indexOf($v('P8_BUSINESSRULETYPE')) >= 0)
    || ($v('P8_OPERATOR') == '9')
    
  • ORA-06502 error digital or value of PL/SQL.

    Hi experts,

    Oracle Apex 4.2, 11g database, using windows 7.

    I created a form and trying to create automatically generated # (sequence of not) with logic and SQL.

    My requirement is to generate the good good exercise only and exercise begin from 01 July and ends 30 June each year. This means if the 07/01/2015 start it will create a new voucher No.

    The table name is GL_PV and the columns are:

    Number of PV_No

    Date of PV_Date

    Number of CC_code

    number amount

    Remarks varchar2 (100)

    What I did: -.

    Created a process to submit before the calculations and validations.

    Code are

    IF TO_NUMBER (TO_CHAR (: P15_pv_date, 'MM')) < = 6 THEN

    SELECT MAX (to_number (nvl(pv_no,0))) + 1

    IN: P15_pv_no

    OF GL_PV

    WHERE pv_date

    BETWEEN

    TO_DATE ('01 - JUL' |) ' -'|| (TO_NUMBER (TO_CHAR(:P15_pv_date,'YYYY'))-1), 'DD-MON-YY')

    AND

    TO_DATE (30 - JUN'|) ' -'|| To_char(:P15_pv_date,'YYYY'), 'DD-mon-YY')

    and cc_code =: P15_cc_code;

    ON THE OTHER

    SELECT MAX (to_number (nvl(pv_no,0))) + 1

    IN: P15_pv_no

    OF GL_PV

    WHERE pv_date

    BETWEEN

    TO_DATE ('01 - JUL' |) ' -'|| To_char(:P15_pv_date,'YYYY'), 'DD-mon-YY')

    AND

    TO_DATE (30 - JUN'|) ' -'|| (TO_NUMBER (TO_CHAR(:P15_pv_date,'YYYY')) + 1), 'DD-MON-YY')

    and cc_code =: P15_cc_code;

    END IF;

    If: P15_pv_no is null then

    : P15_pv_no: = 1;

    end if;

    and press the button when Conditions = Generate_Button

    I have the default assign to pv_date = sysdate, when I launched the point Pv_date form shows the current date and I click on Generate_button now show error.

    Error ORA-06502 PL/SQL digital or value. Conversation number character.

    One last thing, I checked this code already in TOAD, type I assigned as DATE-value = 10/11/2014 (today's date) works fine without error.

    Please guide what this evil is stated.

    Best regards

    : P15_pv_date is probably not a date but a varchar2 in Apex

    Try this

    NVL SELECT (MAX (to_number (nvl(pv_no,0))) + 1, 1)

    IN: P15_pv_no

    OF GL_PV

    WHERE pv_date

    BETWEEN to_date (' 01-07-' |) (extract (year of to_date (: P15_pv_date, "dd-mm-yyyy")) + case when extracted (months to_date (: P15_pv_date, "dd-mm-yyyy")))<= 6="" then="" -1="" else="" 0="" end="" ),="" 'dd-mm-yyyy'="">

    AND to_date (30 - 06-' |) (extract (year of to_date (: P15_pv_date, "dd-mm-yyyy")) + case when extracted (months to_date (: P15_pv_date, "dd-mm-yyyy")))<= 6="" then="" 0="" else="" 1="" end="" ),="" 'dd-mm-yyyy'="">

    and cc_code =: P15_cc_code;

  • Import excel should allow space in a column during the use of media: the value class coldfusion.sql.QueryColumn can not be converted to a date

    I followed the pretty good learncfinaweek and can see no error in my code.   Here is the error, that should solve and the page with the code.  Any help is appreciated.  This should be quite simply like this: < cfset blogPost.dateposted = importData ["posted Date"] / >, which allows the column in excel with a space between words.

    Good: dateposted - the coldfusion.sql.QueryColumn class value cannot be converted to a date.

    Root cause: org.hibernate.HibernateException: property: dateposted - the coldfusion.sql.QueryColumn class value cannot be converted to a date



    "< cfimport taglib ="... /... "/ customTags" prefix = "ct" / >

    < ct:securityCheck redirectPage = "#cgi.script_name #" / >

    < name = "cfparam form.submitted" default = "0" / > "

    "< name =" cfparam form.importFile"default =" "/ >

    < cfif form.submitted >

    <! - Download file - >

    < cffile action = "upload" destination = "#getTempDirectory ()" # "filefield ="importFile"nameconflict ="makeunique"/ >"

    <!--> reading spreadsheet

    "< cfspreadsheet action = 'read' src="#cffile.serverDirectory#/#cffile.serverfile# ' query = headerrow "importData" = "1" excludeheaderrow = "true" / >

    <!--> Import data

    < cfloop query = "importData" >

    < cfset blogPost = entityNew ('blogPost') / >

    < cfset blogPost.title = importData.title / >

    < cfset blogPost.summary = importData.summary / >

    < cfset blogPost.body = importData.body / >

    < cfset blogPost.dateposted = importData ["posted Date"] / >

    < cfset EntitySave (blogPost) / >

    < / cfloop >

    < cfset ormFlush() / >

    < cflocation url = "listblogpost.cfm? message = #urlencodedformat ('Blog Posts Imported Successfully')" # "addtoken ="false"/ >"

    < / cfif >

    < cfoutput >

    < section ct:layout = "Summary" >

    < section = 'blog' active 'post' = ct:navigation / >

    < div class = "span10" >

    The Blog posts to download < h2 > < / h2 >

    < form class = "form-horizontal" action = "" #cgi.script_name # "method ="post"enctype =" multipart/form-data">"

    < div class = "control group" >

    < class label = 'label control' for 'importFile' = > import file < / label >

    < div class = "orders" >

    < input type = "file" id = "importFile" name = "importFile" value = "#form.importFile #" >

    < / div >

    < / div >

    < div class = "control group" >

    < div class = "orders" >

    < button type = 'submit' class = "btn, btn-primary" > download < / button >

    < / div >

    < / div >

    < input type = "hidden" name = "subject" value = "1" / >

    < / make >

    < / div >

    < / ct:layout >

    < / cfoutput >


    DavidSCarlisle55 wrote:

    I changed the date to 'YYYY-MM-DD' in the xls file by changing to the UK format within excel.

    It is still giving an error.  ?

    Odd. Then there can be only one solution to the riddle: what you read is a column name, and not the date value stored in the column.

    See what happens when you replace this line by

    or, perhaps better,.

  • ADD VALUES IN PL/SQL?

    My PL/SQL statement does not return the expected results.

    below the variables A, B and C are declared as VARCHAR2 data type.

    D is declared as a Number data type.

    Select (to_number (A) + to_number (B) + (C) to_number IN double D;

    I expect to have the sum of A, B and C

    However, the value of D is always 0.

    Help, please...

    v_comprate: = to_number (v_comp1) + to_number (v_comp2) + to_number (v_comp3);

    If v_comp1, v_comp2, v_comp3 one of the variable is null, then v_comprate will be null.

    Why not use the NVL function.

    v_comprate: = TO_NUMBER (NVL(v_comp1,'0')) + TO_NUMBER (NVL(v_comp2,0)) + TO_NUMBER (NVL(v_comp3,'0'));

  • management of NULL values in a statement PIVOT 11 g

    Hi all

    In the following code, how can I get the cell showing 80001_sum_sales for employee 234567 as a zero instead of a NULL value?
    with t1 as 
    (
     select 123456 as emp_id, 80000 as category, 10 as sales from dual union all 
     select 123456 as emp_id, 80001 as category, 20 as sales from dual union all
     select 234567 as emp_id, 80000 as category, 10 as sales from dual 
    )
    select *
      from t1 pivot ( sum(nvl(sales,0)) as sum_sales for category in (80000, 80001));
    I tried NVL in various parts of the application, but the problem is that the line does not actually exist to apply the NVL to. I also tried to add another level of subquery factoring to wrap each column in an NVL, something like:
    with t1 as 
    (
     select 123456 as emp_id, 80000 as category, 10 as sales from dual union all 
     select 123456 as emp_id, 80001 as category, 20 as sales from dual union all
     select 234567 as emp_id, 80000 as category, 10 as sales from dual 
    ), 
     t2 as (select *
            from t1 pivot ( sum(sales) as sum_sales for category in (80000, 80001)) )
    select emp_id,
           nvl(80000_sum_sales, 0) as "80000"
           nvl(80001_sum_sales, 0) as "80001"
           from t2;
    but Oracle has a problem with the fact that the column name starts with a number and get ORA-00911. Something like:
    with t1 as 
    (
     select 123456 as emp_id, 80000 as category, 10 as sales from dual union all 
     select 123456 as emp_id, 80001 as category, 20 as sales from dual union all
     select 234567 as emp_id, 80000 as category, 10 as sales from dual 
    ), 
     t2 as (select *
            from t1 pivot ( sum(sales)  for category in (80000, 80001)) )
    select emp_id,
           nvl(80000, 0) as "80000",
           nvl(80001, 0) as "80001"
           from t2;
    shows just the values 80000 and 80001 rather than actual sales amounts. Unfortunately, my requirement is that these column headers must be digital, as is an interface in another system. I try to avoid a full outer join a list of categories to all employees, as my employee table has 180 m files in there.

    Are there SQL gurus out there who can see a way around this problem, before I attempt an outer join complete?

    Thank you
    Matt

    Hello

    Try this

    with t1 as
    (
     select 123456 as emp_id, 80000 as category, 10 as sales from dual union all
     select 123456 as emp_id, 80001 as category, 20 as sales from dual union all
     select 234567 as emp_id, 80000 as category, 10 as sales from dual
    ),
     t2 as (select *
            from t1 pivot ( sum(sales)  for category in (80000, 80001)) )
    select emp_id,
           nvl("80000", 0) as "80000",
           nvl("80001", 0) as "80001"
           from t2;
    

    see you soon

    VT

  • Using literal values in AD Trusted reconciliation

    Hello experts,

    I work on a reconciliation done AD trust and creating the user, I don't then reconcile AD mandatory values 'Body' and "User Type" (they do not exist in my ad).
    I thought about creating some literary values ("End user" / "Xellerate User"), but I can't find any way to insert literal as values: ideas?

    Thank you

    You can set the values of these fields in your Planner Recon approved AD user.

Maybe you are looking for

  • By getting only 10% of the speed of download of airport Ex

    My local ISP offers service of 1 Gbps, and actually, I always get 700 + Mbps when connected directly to the wall outlet. But once I connect it with an Apple Airport Express (model A1392, bought Dec 2015), the speed drops under 100 Mbps (connected via

  • Satellite L855-B511 - after that upgrade Win8 ODD DVD read only

    After upgrading my TOSHIBA Satellite L855 B511 to 8.1 of Windows... Optical discs (GT80N) now can only read and write DVD only... any other CD appears empty.I tried to reinstall windows 8... the driver works correctly.Still... after the second time t

  • Is it possible to install minPCI WLAN on Satellite A60 Pro

    Hello I have a Satellite Pro A60 which was purchased for me around 2002/03. [Satellite Pro Model A60EN number PSA65E] I have always used the net via a USB dongle, which is really annoying and often unrealible. So I was wondering if there are any Wire

  • Upload pictures on computer

    Today I tried to upload a few photos from my phone to my computer with the USB connection for the first time. I was disappointed that the images were so tiny, only about 408 x 230. I had the camera set on big screen setting. Later, I decided to try t

  • Trigger oscilloscope return value

    Hello I'm under Labview 8.2.1 to control the Wavesurfer oscilloscope optionx/IP 64xs. The drivers are downloaded from OR http://sine.ni.com/apps/utf8/niid_web_display.model_page?p_model_id=14665. The oscilloscope acquires burst signals, and I need to