unique id extraction for the session call

A stored procedure can be called by any of the 200 threads say leave within a java connection pool that all sign with say User1. Another similar pool can call the same da that are signed with USER2. Inside of the proc, I need to store some info SYS_CONTEXT and retrieve in the same call. I can't use a package header variable, because it is private to the thread. I can't use a global variable in the package BODY because between the value stored in the global variable BDY and recover another thread can call the same procedure and access the global variable of the BODY.

I decide to keep in the ina SYS_CONTEXT info using a unique identifier for this thread as the ATTRIBUTE and the VALUE info. To compose the unique id for this thread, I issue the following SQl code. What combo will ensure me a unique id for the thread of tis that called the stored proc calls are synchronous meaning once a thread gets a connection from the pool to call the stored procedure, that he does not give up until the process finishes and returns a result to the thread.
SELECT
SYS_CONTEXT ('USERENV', 'SESSIONID')
SYS_CONTEXT ('USERENV', 'SESSION_USER')
SYS_CONTEXT ('USERENV', 'SESSION_USERID'),
SYS_CONTEXT ('USERENV', 'SID')
SYS_CONTEXT ('USERENV', 'HOST')
SYS_CONTEXT ('USERENV', 'INSTANCE'),
IN
v_sessionid
v_session_user
v_session_userid
v_host
v_instance
Of
DOUBLE
;

Hello

A variable packed, a declared in the header or the body outside of any procedure or function, is unique in the database session. Each session will retain a value of each variable is used and the value will persist for the duration of the session. The availability of a variable will depend on where it is declared. A variable declared in the header of the packet will be available outside this package, because it can be called and used by any other package, procedure and function during the session. A variable declared in the body is local for the package only, but for the entire session. Note that a package and the body may be declared as a reusable series, which means that calls to the package to reset the State of the package and its variables.

So in your case, the variable v_global_var will persist during the session, but will be available for the package pkg1. If you want this variable to be available outside the package, it must be declared in the header.

Concerning
André

Tags: Database

Similar Questions

  • What are the hours for the sessions from tomorrow

    What are the schedules for the sessions from the 'tomorrow' or how to plan my own schedule?

    The materials for each week, starting March 31, will be available on the main page at 12:00 (midnight) GMT/UTC.

    The complete schedule is here: Details of the schedule for the MOOC (March)

  • Geocoding takes VERY long for the first call in each session

    Hello

    We are moving to a system of very short response time where the user sends a query via mobile phone to our based Oracle server and the response THAT SMS must return a list of points of interest at a certain distance from the mobile phone.

    Previously we were using Oracle 9i, now we went to 10g (EE 10.2.0.4.0). Given that 10g supports geocoding out of the box, we intend to use it. What we are experiencing, this is when we create a new session, and then the first geocoding/reverse_geocode call takes about 1 minute in our test environment (that means 100% CPU load on the side of Oracle Server), the following calls are in the [http://0.1.. 0.6] second intervals. We only use sdo_gcdr.reverse_geocode () and sdo_gcdr.geocode () procedures.

    In a space book, we found:
    + "Note: the first call to a function of geolocation in a session requires several time (is longer) than subsequent calls." +
    "+ Is because the function must load and analyze arrays of profile". +

    Profile of tables do not change, why is he not analyzed at the start of the RDBMS and only once, not for each session?

    Is there a solution?

    Kind regards
    Tamas Szecsy

    Published by: Tamas Szecsy on March 7, 2009 10:30

    Published by: Tamas Szecsy on March 7, 2009 10:30

    Published by: Tamas Szecsy on March 7, 2009 10:41

    The patch that I suggest is precisely to allow the geocoder to work effectively in many countries. Its effect is to only load the profile for the country being geocoded. If profiles are loaded progressively as needed, avoiding the High overload at the beginning. With this patch, the first geocode a meeting is second.

    The time you specify (a minute for the first geocoded in a session) clearly indicate a problem. If this problem is not with bad indexes on the table of the region, you can check the box caching (CACHED_ADMIN_AREA_LEVEL in GC_COUNTRY_PROFILE should be 0).

    I think yiou need to capture a complete SQL trace of this first geocoded, so we can diagnose accurately what is happening.

    Albert

  • Problem with cursor Max for the PLSQL called by OAF Page

    All,

    We developed a custom and Self Service OFA this page page, we call PLSQL package to validate and insert the data into the database tables. It worked well, but when we deployed this form throughout the Organization (meaning more users), we reach the limits of MAX cursor for a session.

    This for allows Manager to update all their coordinated under, so in a session, a Manager may work on more than one employee so reach the limit of MAX cursor.

    Please help on how we can solve this problem, I checked all of the cursors used in the PLSQL package are closed properly.

    Ex PLSQL Call:

    String createRow = null;

    try {}

    OADBTransaction oadbtransaction = (OADBTransaction) pageContext.getApplicationModule (webBean) .getTransaction ();

    java.sql.Connection connection = oadbtransaction.getJdbcConnection ();

    CallableStatement callablestatement = oadbtransaction.createCallableStatement ("start: 1: = xxx_hr_multiple_rates_pkg.is_create_job_row (pc_job_name = >: 2);") end; ", 1);

    callablestatement.setString (2, primaryJob.getText (pageContext));

    callablestatement.registerOutParameter(1,Types.VARCHAR);

    CallableStatement.Execute ();

    createRow = callablestatement.getString (1);

    String [] retVals = am.invokeMethod ("createWFMJob", parameter1) (String []);

    System.out.println("CreateRow:"+CreateRow);

    CallableStatement.Close ();

    }

    catch (Exception e) {}

    e.printStackTrace ();

    pageContext.writeDiagnostics (this, try (), 1);

    }

    Thank you

    A

    Ankit,

    Please attach your PL/SQL code, so that we can have a look that the issue could be in that.

    In addition,

    Why do you call the code inside this test below? What is the link?

    String [] retVals = am.invokeMethod ("createWFMJob", parameter1) (String []);

    Why do you need the code below? Delete this.

    java.sql.Connection connection = oadbtransaction.getJdbcConnection ();

    Move the callablestatement.close ();  outside of try catch.

    See the link, if you need some examples below:

    Advice from the Oracle Johny: OAF: sample code to call the function PL/SQL of OA Framework

    See you soon

    AJ

  • Would like to know where I could buy packs of cards for the PC for the game Call of Duty.

    Hi all

    I would like to know where I could buy packs of cards for PC. It would be for Call of Duty: World at war, Black Ops, Black Ops II, war in advance and maybe even Black Ops III. Please leave a few links below if you have an answer. I thank very you much for your time.

    Hi Alex,

    You may need to use your favorite search engine to know the best site to buy packs of cards for the mentioned games.

    Kind regards

  • SSL in the APEX for the LDAP call

    Hi all

    I have to call my Ldap server for the login process. The team of LDAP, asking me to activate the SSL mode in the APEX. They provided the SSL certificate.

    Now, my question is what exactly I need to do to activate the SSL authentication mode in the APEX? Do I need to install any certificate to the server database or Web server to allow this SSL?

    How its work? Any idea would be appreciated. Lack of experience in the networking functionality.

    My Version of Apex: APEX 4.0

    Database: Oracle 10G

    See you soon,.

    San.

    Yes you are right. Configure the SSL certificate in the oracle portfolio.

    Thank you

    Lacombe

  • Is there a way to test for the first call of a function?

    Hello

    I created a function (using other functions I created) to generate a dynamic hierarchy tree menu based on parentID and itemID etc etc - I'm sure you are familiar with this concept. It works very well, and there is no problem.

    However, I do all this build in a string, and then dumped on the page. Again, this works very well. However, because the function is called recursively, my class, the class = 'tree' repeat itself in each occurrence of the opening UL tag.

    I want to only this class to be applied to the first UL, but because it is recursive, I don't know how to detect if the function is called for the first time or 5th time, etc.. I mean something like:

    < cfif myFunction is called the first time >
    Add the class
    < cfelse >
    do not add the class
    < / cfif >

    Please see my attached code. It is fully functional. Please don't worry that all the other functions do etc, they work very well, but I need a way or a variable to test against.

    Any ideas?

    Thank you very much
    Michael.

    Kapitaine wrote:
    > Hmmm, I bet that the solution is simple, but my mind is frazzled! Haha.
    >

    Yes, it's simple, you test the Boolean value and it will be true if it is
    set to true for a recursion.






    #somethingStupid(5,true) #.

  • I use Hotmail on Mac and don't know how to increase the font size for my mails etc. You use the zoom + is only temp for the session. Suggestions please.

    I use Hotmail on a new Mac and don't know how to increase the font size for the display of my email. you use the zoom + is only one temp. Suggestions please.

    According to the format your help,.

    Hotmail format,

    Click Options at the top right,

    Then more options.

    Writing e-mail / click on fonts and signatures.

    Make you choices and save.

    New format for Outlook.com,

    Click on the gear in the top right, symbol

    Click Options,

    The options are almost the same.

    For more entries change your question and move it to the section of Hotmail, Messenger, and skydrive.

    Search by all subjects,

    Section Outllook.com or hotmail.com.

  • How to activate PRHT for the session active

    Hi all

    Help us to trace the current session

    We now have a functioning around 2 hours qurey, we want to draw this session then please post the steps to find the session

    Thank you

    Read
    http://www.gplivna.EU/papers/oracle_trace.htm

  • Best practices for the CFC call

    Hello

    In a web application, if I need to call a method on a different CFC CFCS, which would be considered as the best way to do it?

    For example, let's say I have two components: Customer and Product.  A method functionA to the customer, I want to call product Featureb.  I can do one of the following values, but how is recommended and why?

    1. create an object produced in functionA and use it to call Featureb

    < cfproperty name = "Customer" >

    < cffunction name = "functionA" >

    < cfset productObj = createObject ("component", "Product") >

    < cfset productObj.functionB () >

    < / cffunction >

    < / cfproperty >

    2 pass a product object when we initialize a Customer object and use it to call Featureb

    < cfproperty name = "Customer" >

    < cffunction name = "init" >

    < cfargument name = "productObj" >

    < cfset variables.productObj = arguments.productObj >

    < / cffunction >

    < cffunction name = "functionA" >

    < cfset variables.productObj.functionB () >

    < / cffunction >

    < / cfproperty >

    3. place the assumption that Customer object has access to the object in the scope

    < cfproperty name = "Customer" >

    < cffunction name = "functionA" >

    < cfset application.productObj.functionB () >

    < / cffunction >

    < / cfproperty >

    Thank you very much.

    I would like to use method 1 because it gives you the flexibility of most.  While your known current requirements may dictate that it be necessary to call the cfc 100% of the time product you call customer support CFCs, something might happen in the future when it is not.  Method 2 would be ineffective because it running unnecessary code.

  • activation of aging of password for the Sessions hosted by device

    Hello

    I want to configuration of devices cisco Ganymede authentication password aging.

    The problem is that in the configuration of groups of GBA, I don't have the section password aging (as described in the help topic).

    I use ACS v3.3

    Thank you very much for your help!

    Hello

    It's gr8.

    change of password is supported by SSHv2. SSHv1 does not support the necessary

    types of message to initiate a password change the sequence.

    There is also a default bound to it. However, it works with recent versions of IOS.

    CSCin91851: support the keyboard-interactive authentication method

    found in 1st: 12.4 T

    Fixed in:

    12.4 (10.1) T

    12.2 (33) SXI

    12.4 (17.9) M

    12.2 (32.8.11) SX142

    12.2 (33.1.10) SXH

    12.4 M (13f)

    12.2 (33) SXH2

    12.2 (32.8.11) XJC153.1

    12.2 (32.8.1) YCA172.24

    12.4 (22.3.4) PIC1

    HTH

    JK

  • Help: How do reset you default values for the session and the time-out at the admin level

    Hello

    The DBA was trying to save the settings of time-out value by following the instructions and it kept him setting a default off 28800 timeout of Session Timeout and Idle of 3600.

    He saved the value 1, and now we cannot get to change.

    How do reset you the default preferences?

    Bill,

    Sorry, I missed your point. To undo this damage, try this:

    Connect as SYS

    ALTER session set current_schema = apex_030200
    /
    wwv_flow_platform.set_preference (p_preference_name-online 'MAX_SESSION_IDLE_SEC', p_preference_value-online 3600)
    /
    wwv_flow_platform.set_preference (p_preference_name-online 'MAX_SESSION_LENGTH_SEC', p_preference_value-online 28800)
    /
    Commit
    /

    Adjust 3600 and 28800 as you like.

    Scott

  • How to use the session ip phone 9971 call from speed dial

    Hello

    How can I use IP phone 9971 session call buttons to be used for line speed dial or intercom?

    Your help will be appreciated.

    Thank you

    You can not, you can only assign one of the 6 buttons line as another option, the session call buttons are dedicated to call the session.

  • maintain the same identifier of session for several sessions

    This problem started as a matter of (secondary java) at the end of fonts, but I need to understand the side Oracle. So I raise here.

    Let's say that a user makes the call to Oracle in two (or more) connections. Each connection will begin a new session.

    On the first call, the user connects to the DB and then run a stored procedure to insert data in the parent table, which then returns a primary key.

    Then the user makes another call to Oracle (where a new session), run another stored procedure and pass the primary key, so that a line can be inserted into the child table (dependence).

    In doing so, I need the second connection to share the same session as the first. So for the first and second connections, I coded to perform the following duties

    DBMS_session. Set_Identifier('100');
    DBMS_session.set_Context ('ACCOUNT_CTX', 'ID_compte', ' 0');

    But the second call (one to insert a row in the child table) does not always complain that the foreign key does not exist in the parent table.

    This indicates that the system considered the second connection as a distinct and different session, so the primary key inserted into the parent table (by the first call) is not seen by the second call.


    I can keep the two connections in the same session, which could be the solution (side Oracle) or a suggestion?


    Thank you.

    Published by: scottjhn on December 2, 2012 19:30

    >
    This problem started as a matter of (secondary java) at the end of fonts, but I need to understand the side Oracle. So I raise here.
    >
    Yes he did - and I answered it there.
    When you cross-post, you must at least provide cross-cutting for other threads links so that people can follow what is being discussed.
    JDBC mutiple inserts on the side of java (to keep the same session)

    Will change your other thread and provide the link to this one.
    >
    I can keep the two connections in the same session, which could be the solution (side Oracle) or a suggestion?
    >
    As I said in the other thread: the same session to insert parent records and child needs either, you must commit after insertion of the parent record.
    >
    On the first call, the user connects to the DB and then run a stored procedure to insert data in the parent table, which then returns a primary key.

    Then the user makes another call to Oracle (where a new session), run another stored procedure and pass the primary key, so that a line can be inserted into the child table (dependence).
    >
    The second call should not be a new session. You can use the same connection that you used for the first call. But if you use two connections or two sessions of the first session was committing its work or the second session will not see it.

  • Session for the Validation of the region variables

    Hi guys,.

    I made the dashboard in OBIEE answers. First of all, I created dimension region in my structure. I used this dimension to validate users who log on the dashboard.
    Then, all the fact will be displayed depending on the region of the user. To do this, I used in the administration tool session variables, with the following query in the inizialitation block:
    Region_name SELECT FROM user_region WHERE user_name = LOWER(':USER')

    In the answer of dashboard, I used region_name filter with the value of the session variable to show the fact according to the region of the user.

    The problem arises when I log in as an administrator. I want if you connect administrator, does everything will be shown in all regions. But user_region table, that I created, there is no user "administrator." And the fact appears as an error because there is no rated for administrator.

    I don't know how to beat this case. I hope you guys could help me.

    Concerning

    Hello

    Initialization block; "getRegion" returns a single value for the Session Variable; "userRegion" right? A region for a user_name of the user_region of the table as you already have. If the 'Administrator' user connects, the table of user_region returns nothing. In this case the Table double (if you are on Oracle) will return; "All regions".

    Region_name SELECT FROM user_region WHERE user_name = LOWER(':USER')
    UNION ALL
    SELECT 'all regions' OF THE double WHERE LOWER(':USER') = 'administrator '.

    So far so good?

    In response OBIEE, I'll add the filter as follows:
    Column: Name of the region
    Operator: is equivalent to / in
    Session variable: userRegion

    That's ok. Convert the run in SQL. Add a 'or Clause' for the 'all regions' - part. It will be as follows:

    Region name = userRegion
    OR userRegion = 'all regions '.

    Good luck

    Daan Bakboord
    http://obibb.WordPress.com

Maybe you are looking for