Setting a session ID in PL/SQL

Hello
I am currently trying to download the contents of a clob into notepad from Apex. So I have a link like this to call the package on the database:
<a href="#OWNER#.species_upload.download_error_txt?p_session_id=&APP_SESSION.">Download to Notepad</a> And as you can see I am passing in the session id as I want to use the v function to get at some application items. Here is the code for the function:
   PROCEDURE download_error_txt(p_session_id IN NUMBER)
   IS
   v_err_filename               VARCHAR2(1000);
   v_err_clob                   CLOB;
   v_err_user                   VARCHAR2(100);
   BEGIN
        --First of all we will get the file name and append error to it.
        wwv_flow_api.set_security_group_id(2178813262660915);
        APEX_CUSTOM_AUTH.set_session_id(p_session_id);
        v_err_filename := v('F157_SPECIES_FILE_NAME');
        v_err_filename := SUBSTR(v_err_filename,0,LENGTH(v_err_filename) -4)
                       || '_error.txt';
        --We will convert all the <br /> tags in the clob to chr10||chr13 to
        --force a new line feed in windows.       
        v_err_clob := V('F157_SPECIES_ERROR');
        v_err_clob := REPLACE(v_err_clob, '<br />', chr(13));
        v_err_user := V('APP_USER');
        select v('APP_USER') INTO v_err_user from dual;
        --Set the MIME type.
        OWA_UTIL.MIME_HEADER('text/plain',FALSE);
        --Set the name of the file
        HTP.p('Content-Disposition: attachment; filename="'||v_err_filename||'"');
        --Close the HTTP header,
        OWA_UTIL.HTTP_HEADER_CLOSE;
        HTP.p('Below is a detailed list of why the '|| v_err_filename || 'did not upload.');
        HTP.p(chr(13));
        HTP.p('Paul Test');
        HTP.p(chr(13));
        HTP.p(v_err_user);
        HTP.p(chr(13));
        HTP.p(v_err_clob);
   END download_error_txt;Now it opens up the notepad fine and displays the values that I have hardcoded but none of the values that the v function returns. As you can see I am using set_session_id in my code but I don't think that is enough.
So thats why I am wondering if I can tell this procedure what apex session it is and get the values from that session.
Cheers,
Paul.

If you use the application process approach like in this example (at the end), you can get the session id within the package using v('APP_SESSION').
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------------------

Similar Messages

  • Setting v$session.program with javax.sql.DataSource unsing JNDI

    I am trying to set v$session's program column while connecting to database.
    It works like charm when i use :
    java.util.Properties params = new java.util.Properties();
    params.put("v$session.program", "MyApp");
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    conn = DriverManager.getConnection("jdbc:oracle:thin:user/[email protected]:1521:myDB",params);
    It just doesn't SET anything when i use, JNDI :
    java.util.Properties params = new java.util.Properties();
    params.put("v$session.program", "MyApp");
    Context ctx = new InitialContext(params);
    DataSource ds = (DataSource)ctx.lookup(datasourceName);
    conn = ds.getConnection(userName,password);
    Just couldn't figure out why its not setting in the 2nd Case. Any ideas ??

    Valid..
    But then, even if i set v$session.program in my JDev environment or even on app server's connection pool Its NOt getting set.
    Am i doing something worng.
    Btw, i am using jdbc thin 10.1.0.3 driver. I read somewhere that this was a bug and its fixed with jdbc thin driver 10.2.x versions.
    Has anyone tried on 10.2.x versions ?

  • Can I set a Session Variable from a Dashboard Prompt, using values that are

    Hi All
    Trying to set a Session Variable to an integer value, by letting users select a text value from the drop-down list on a Dashboard Prompt. The goal is to set the input parameter to the IndexCol function, but to provide the end users with a text description of what they are setting.
    Select Value Set Variable Value
    My 0
    My Team 1
    My Companies 2
    My Teams Companies 3
    Any suggestions on how to accomplish this? Certainly we could populate the drop-down from a data source, however I don't see how to populate a variable with something other than the values on the screen.
    The IndexCol function is referenced in a Filter in Answers, and I'm thinking to populate a Session variable using the (Presentation) variable value set from the prompt. But how to do this? I see a reference to a function NQSSetSessionValue(), but cannot find documentation on how it works.
    Any clue will be greatly appreciated.
    Thanks

    Hi kishore..
    Looks like the link u have sent uses advanced SQL tab to set session variables. I want to know if I can use "set variable NQ_SESSION.myvar= @something" in the "SQL results" -while creating a dashboard prompt-.
    Purpose: I want the session variable to be set based on whatever report that im currently in.
    And i dont want to use presentation variables because im using a reset button in my page.
    My reset script resets presentation variables and NOT session variables.
    Thanks in advance
    Loy

  • How to set an Application Item from PL/SQL

    I am attempting to set an Application Item
    After login to my app, I want to retrieve a row from my SETTINGS table and populate some Application Items with the settings information so that I can
    display some of that settings information on every page.
    Just to start, I created one Application Item named F106_YEAR
    I then created a Shared Components Application Process which executes on New Session: After Authentication
    I created this process as an Anynomous PL/SQL block.
    declare
    aucyr varchar(4);
    begin
    select year into auctyr
    from settings;
    :F106_YEAR := aucyr;
    end;
    I've tried a couple of other Syntax tricks attempting to reference the Application Item F106_YEAR from within PL/SQL (like V('F106_YEAR') but nothing seems to be working.
    I'm sure that I am missing something simple. Can someone tell me how to set an Application Item from PL/SQL?
    Thanks in advance.

    I'm still doing something wrong because this is not working for me.
    I've tried both of the following versions as an Application Process set to run on New Session after Authentication:
    declare
    auction_year varchar(4);
    begin
    select year into auction_year
    from PBUUC.SETTINGS where rownum < 2;
    :F106_AUCTION_YEAR:=auction_year;
    end;
    and I also tried:
    declare
    auction_year varchar(4);
    begin
    select year into auction_year
    from PBUUC.SETTINGS where rownum < 2;
    APEX_UTIL.SET_SESSION_STATE (p_name, p_value);
    end;
    F106_YEAR is a global Item (shared components).
    The select statement works just fine in SQL*PLUS so I know that it is correct.
    If I run the debugger and log into the application, here is the output. Shouldn't I see my Application Process get called if it is set to run on New Session after Validation?
    My Application process is named RETRIEVE_AUCTION_SETTINGS
    0.01: A C C E P T: Request="P101_PASSWORD"
    0.01: Metadata: Fetch application definition and shortcuts
    0.01: alter session set nls_language="AMERICAN"
    0.01: alter session set nls_territory="AMERICA"
    0.01: ...NLS: Set Decimal separator="."
    0.01: ...NLS: Set NLS Group separator=","
    0.01: ...NLS: Set date format="DD-MON-RR"
    0.01: ...Setting session time_zone to -04:00
    0.01: NLS: wwv_flow.g_flow_language_derived_from=0: wwv_flow.g_browser_language=en-us
    0.01: Fetch session state from database
    0.02: ...Check session 695371898690095 owner
    0.02: ...Check for session expiration:
    0.02: ...Metadata: Fetch Page, Computation, Process, and Branch
    0.02: Session: Fetch session header information
    0.02: ...Metadata: Fetch page attributes for application 106, page 101
    0.03: ...Validate item page affinity.
    0.03: ...Validate hidden_protected items.
    0.03: ...Check authorization security schemes
    0.03: Session State: Save form items and p_arg_values
    0.03: ...Session State: Save "P101_USERNAME" - saving same value: "jps"
    0.03: Processing point: ON_SUBMIT_BEFORE_COMPUTATION
    0.03: Branch point: BEFORE_COMPUTATION
    0.03: Computation point: AFTER_SUBMIT
    0.03: Tabs: Perform Branching for Tab Requests
    0.03: Branch point: BEFORE_VALIDATION
    0.03: Perform validations:
    0.03: Branch point: BEFORE_PROCESSING
    0.03: Processing point: AFTER_SUBMIT
    0.03: ...Process "Set Username Cookie": PLSQL (AFTER_SUBMIT) begin owa_util.mime_header('text/html', FALSE); owa_cookie.send( name=>'LOGIN_USERNAME_COOKIE', value=>lower(:P101_USERNAME)); exception when others then null; end;
    0.04: ...Process "Login": PLSQL (AFTER_SUBMIT) wwv_flow_custom_auth_std.login( P_UNAME => :P101_USERNAME, P_PASSWORD => :P101_PASSWORD, P_SESSION_ID => v('APP_SESSION'), P_FLOW_PAGE => :APP_ID||':1' );
    0.06: ...Process "Clear Page(s) Cache": CLEAR_CACHE_FOR_PAGES (AFTER_SUBMIT) 101
    0.06: Nulling cache for application "106" page: 101
    0.00:
    0.00: S H O W: application="106" page="1" workspace="" request="" session="695371898690095"
    0.01: alter session set nls_language="AMERICAN"
    0.01: alter session set nls_territory="AMERICA"
    0.01: ...NLS: Set Decimal separator="."
    0.01: ...NLS: Set NLS Group separator=","
    0.01: ...NLS: Set date format="DD-MON-RR"
    0.01: ...Setting session time_zone to -04:00
    0.01: NLS: wwv_flow.g_flow_language_derived_from=0: wwv_flow.g_browser_language=en-us
    0.01: Application 106, Authentication: CUSTOM2, Page Template: 2904114531488186
    0.01: ...Session ID 695371898690095 can be used
    0.01: ...Application session: 695371898690095, user=JPS
    0.01: ...Determine if user "JPS" workspace "1040027630222986" can develop application "106" in workspace "1040027630222986"
    0.01: ...Check for session expiration:
    0.01: Session: Fetch session header information
    0.01: ...Metadata: Fetch page attributes for application 106, page 1
    0.01: Fetch session state from database
    0.02: Branch point: BEFORE_HEADER
    0.02: Fetch application meta data
    0.02: Computation point: BEFORE_HEADER
    0.02: Processing point: BEFORE_HEADER
    0.03: Show page template header
    0.03: Computation point: AFTER_HEADER
    0.03: Processing point: AFTER_HEADER     
    0.04: Computation point: BEFORE_BOX_BODY
    0.04: Processing point: BEFORE_BOX_BODY
    0.04: Region: Auction_Title F106_AUCTION_YEAR

  • Can we change the DB character set at session level

    hi,
    Please help me
    when iam giving the alter session command iam getting the error:
    SQL> ALTER SESSION set NLS_CHARACTERSE
    T =WE8MSWIN1252;
    ALTER SESSION set NLS_CHARACTERSET =WE8MSWIN1252
    ERROR at line 1:
    ORA-00922: missing or invalid
    i need to enter Arabic names in using the xml file.
    here i have two questions
    1)is it is possible to set character set at session level. because my client is not allowing to bounce the database. DB version is 10.2.0.4
    Right now my DB is in US7ascii
    2)is this "WE8MSWIN1252" set supports Arabic.
    Regards,
    Naresh

    You cannot change the characterset at the session level. If you want to store ARABIC characters in your database then you should change the characterset of your database to any other characterset that supports Arabic characters or to a Unicode characterset like UTF8 or AL32UTF8.
    If you try to insert Arabic characters with your present US7ASCII charancterset then the characters would be stored as junk.

  • Session Variable in PL/SQL

    hi All,
    I want to set a session variable in Web PL/Sql or PL/Sql procedure
    & i want to retrieve in ProcessFormRequest() in my controller...
    Can it be done in some ways ???
    Please help....

    Hi,
    I am trying to get the parameter from pg1(OAPage) to pg2(web pl/sql page) but i can't do it ...
    The link OAPage is :OA_HTML/OA.jsp?_rc=HR_P_RATE_TOP_SS&_ri=800&OAFunc=HR_NEWHIRE_SS&_ti=713401982&retainAM=Y&addBreadCrumb=N&dialogAction=NEXT&oapc=11...
    here i need to pass _ti, retainAM and other parameters to web pl/sql procedure.
    i can't decalare a procedure staring ti like procedure(ti varchar2) coz while executing i am getting error... if i do with this procedure(ti varchar2) i am unable to get _ti parameter in web pl/sql.
    i can get the value of ti from the table(ICXTransactions,icx_sessions) but this is not the feasible to do.
    what is the expansion of parameter &oapc and &oas...
    Please Help....

  • How can I set a Session bean timeout

    Hello !
    How can I set a Session bean to time out eg. 48 hours ?
    Thanks
    Uiloq Slettemark

    For stateful session beans you can use the timeout attribute in the orion-ejb-jar e.g.
    <session-deployment timeout=1800 ..>
    this is specified in seconds and Default Value: 30 (minutes)
    regards
    Debu

  • Set maximum server memory by using sql scripts

    Dear all
    How to set maximum server memory by using sql scripts in sql server 2014? Thx a lot
    Best regards,
    Wallace

    You can use
    sys.Sp_Configure to set max server memory
    Here are some recommendation for Max Server memory based on RAM size
    GB
    MB
    Recommended Setting
    Command
    16
    16384
    14745
    EXEC sys.sp_configure 'max server memory (MB)', '14745'; RECONFIGURE;
    32
    32768
    29491
    EXEC sys.sp_configure 'max server memory (MB)', '29491'; RECONFIGURE;
    64
    65536
    58982
    EXEC sys.sp_configure 'max server memory (MB)', '58982'; RECONFIGURE;
    128
    131072
    117964
    EXEC sys.sp_configure 'max server memory (MB)', '117964'; RECONFIGURE;
    256
    262144
    235929
    EXEC sys.sp_configure 'max server memory (MB)', '235929'; RECONFIGURE;
    512
    524288
    471859
    EXEC sys.sp_configure 'max server memory (MB)', '471859'; RECONFIGURE;
    1024
    1048576
    943718
    EXEC sys.sp_configure 'max server memory (MB)', '943718'; RECONFIGURE;
    2048
    2097152
    1887436
    EXEC sys.sp_configure 'max server memory (MB)', '1887436'; RECONFIGURE;
    4096
    4194304
    3774873
    EXEC sys.sp_configure'max server memory (MB)', '3774873'; RECONFIGURE;
    Hope this will help
    Glad to help! Please remember to accept the answer if you found it helpful. It will be useful for future readers having same issue.

  • Returning a set of registers in a PL/SQL function

    Does anybody knows if there is some way to return a set of registers (like a cursor) in a PL/SQL function without using a temporary table?
    Thank you

    To: [email protected]
    Sub: Returning a set of registers in a PL/SQL function
    Hi: Nei S
    Create a Package first:
    CREATE OR REPLACE PACKAGE sp_xxxPKG AS
    TYPE RT1 IS RECORD (
    sp_col1 emp.emp_no%TYPE,
    sp_col2 emp.emp_name%TYPE);
    TYPE RCT1 IS REF CURSOR RETURN RT1;
    END;
    Then Create a Procedure:
    CREATE OR REPLACE PROCEDURE sp_xxx (
    RC1 IN OUT sp_xxxPKG.RCT1) AS
    BEGIN
    OPEN RC1 FOR
    SELECT emp_no, emp_name FROM emp;
    RETURN;
    END;
    null

  • Trouble setting the session state of a select item.

    Hi,
    I have a requirement whereby I need to change the session state of a select list item in my form without the need to submit. I am using Application Express 4.1.0.00.32. I thought this would be straight forward using a dynamic action or javascript and calling an on demand process for example.
    P1_MY_SELECT onchange="set_option();"
    function set_option() {
    var l_option=$f_SelectValue('P1_MY_SELECT');
    alert( 'My new value is ' + l_option );
    // ON DEMAND Set the new session state value
    var lRequest = new apex.ajax.ondemand
    ('SET_P1_MY_SELECT',function()
    {  /* start the return function */
    var l_s = p.readyState;
    if(l_s == 1||l_s == 2||l_s == 3)
    else if(l_s == 4)
    { gReturn = p.responseText;
         (gReturn)?json_SetItems(gReturn):null;
    else{return false;}
    /* end the return function */
    lRequest.ajax.addParam('x01', l_option );
    lRequest._get()
    My on demand application process
    DECLARE
    l_options varchar2(2000) := wwv_flow.g_x01;
    BEGIN
    APEX_UTIL.SET_SESSION_STATE('P1_MY_SELECT',l_options);
    apex_util.json_from_items('P1_MY_SELECT');
    END;
    Is there a better method to set the session state of my P1_MY_SELECT other than what I am doing as above or can you tell me why the session state of P1_MY_SELECT is not changed?
    Thanks.
    Edited by: 968358 on 01-Nov-2012 08:40

    if you are on 4.1 why don't you use a dynamic action instead of writing the code again?
    create a dynamic action like this
    Event: Change
    Source Type: Item
    Item: P1_MY_SELECT
    True Action:
    =========
    Action: Execute Plsql Code
    Plsql Code: null;
    Page Items to Submit: P1_MY_SELECT
    Page Items to Return: P1_MY_SELECT (this is optional)
    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21674/advnc_dynamic_actions.htm#HTMDB27020

  • Configure no. of session handled for same sql

    hi, experts,
    hi, if there is one report (only fire 1 sql by this report).
    if only one internet explorer to run this report , it use 3 minutes to get it.
    I use 3 internet explorers to run the same report but not running the report at the same time.
    firstly, I run the report on first internet explorer.
    then after 10 seconds, I run the report on 2nd internet explorer.
    then after 10 seconds, I run the report on 3rd internet explorer.
    after result on all internet explorer came, I check the sessions on the "Manage Sessions"
    there are 2 sessions for same report.
    How to configure no. of session handled for same sql on OBIEE?
    thank you very much!

    shipon_97 wrote:
    Here I see that at a particular time of the database , the number of session from v$session is "271" where as the number of session in the "v$resource_limit" is "280" . Here I get some differ among these parameters .
    Would anybody plz tell why the no of sessions differ between v$session and v$resource_limit parameters .
    The v$session views shows current sessions (which change rapidly), while the v$resource_limit shows the maximum resource utilization, like a high-water mark.
    http://download-east.oracle.com/docs/cd/A97630_01/server.920/a96536/ch3155.htm

  • How to set no archive log in MS SQL

    Dear Gurus,
    I'll already did the support package upgrade and need to run the SGEN.But before that I'll need to set the archive log in MS SQL 2005 database.
    Kindly please help me,how to set "no archive log " in MS SQL .Then I can run the SGEN.After that how to revert back to "enable archive log mode".
    All the posting told about the archive log with Oracle.
    Thanks
    /Shah

    Hi Shah,
    In MS SQL Server, Transaction log is used to write log files.
    For eg., Intially if you allocate 10GB to the Tr.Log and can set the limit based on your requirement, say as 11GB. It means it wont grow beyond the point 11GB.
    If you take a transactional log backup, the data present in the 10GB file is freed up, but the size of the file would remain same.
    This can be truncated by shrinking the log file.
    1. Open SQL Mgmt studio.
    2. Right click on the DB(SID)> Tasks>Shrink-->Files.
    3. Choose "Log" in the file type and "Log File Name" in the Filename column.
    4. Shrink Action should be "Release Unused Space"
    5. Then Click Ok. The unused space will be released.
    The Transaction log can be switched off by changing the Recovery Model to "SIMPLE"
    1. Click on the DB(SID)
    2. Properties>Options>Recovery Model.
    3. If the recovery model is set to Simple, the Transaction log wont be written.
    Hope this would help you. Revert for any other clarification.
    Regards,
    Kamesh

  • How to set keyword automatic to capital in SQL Developer?

    for example:
    when type 'select' , the keyword change to 'SELECT'. :)

    You can set capitalisation preferences in Tools -> PReferences ->SQL Formatter.
    This takes effect when you hit ctrl-b to format sql. It doesn't happen automatically.

  • How to set a session variable

    Hi,
    I would like to know how to set a session variable for the following purpose.
    At the top of my application I have a "Welcome <username>" I'd like it instead to have "Welcome <firstname> <lastname>".
    So the concept would be after the user logs in succesfully this session variable is dynamically set so it can be displayed.

    Hi Scott,
    I realize that I can set items etc in pages. The case I'm referring to is a reference in a template. My template has a "Welcome <user name>" ... so the code looks like "Welcome &APP_USER." Anyway to make it say "Welcome first_name last_name" in the template? Note I'll have to get the first/last names from a query
    Thanks,
    Marty

  • Setting a session bean

    How do i set a session bean in my JSF action? I have defined this session bean in my faces-config.xml file:
    <managed-bean>
    <managed-bean-name>SelectedHistoryRecord</managed-bean-name>
    <managed-bean-class>com.myco.nps_history.model.NPSHistoryRecord</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    And so far I know how to retrieve it's value ...
    javax.faces.application.Application app = ctx.getApplication();
    NPSHistoryRecord selectedHistoryRecord = (NPSHistoryRecord)app.getVariableResolver().resolveVariable(ctx, "SelectedHistoryRecord");
    but I don't know how to set the session bean to be an instance of a different bean than that returned. Your advice is appreciated, - Dave

    Indeed, ExternalContext#getSessionMap() returns a modifable map of session attributes (backed by HttpSession#get/setAttrbute() in a Servlet environment), including the session scoped managed beans which are keyed by their managed bean name.
    You may find this article useful in general: [http://balusc.blogspot.com/2006/06/communication-in-jsf.html].

Maybe you are looking for

  • HOW TO USE TRANSLATE FUNCTION

    Hi in XSQL i am one getting one row like this <REASON_FOR_REJECTION>1.Overhead line is not existing in front of the premises,2.The distance from the pole to the serice is more than 30 meters.,3.Another service is existing in the same premises with ar

  • Standard Swing Icons

    Hi, I'm doing a sort of a progress dialog showing the phases progress to the user. Are there any standard icons/images in Swing? in particular, I'm looking for images that show: "Done" - might be something like a checked CheckBox "Error" - Something

  • Running Forms and Oracle 9i on the same PC

    Some time ago I installed Oracle 8 and Forms and Reports 6i on the same PC (Windows 2000). I did specify a different ORA home for the Forms product to the database product. I believe this means that your registry is set to access one, probably your d

  • I am having trouble with scrollbars in netbeans 5.5.1

    I have had trouble getting a scrollbar working in netbeans 5.5.1 because the code is not all self written the new 5.5.1 platform takes away the need to write as much code. As a result the books that I am using as a reference does not work. Can anybod

  • Suppress message "Time Zone PST is not Valid in Country US

    Hi , I wan to supress the above message Message no: AM 482 ( Time Zone PST is not valide in country us (Several Possibility). I have checked not 1505591 but it is not released yet. Please let us know which note would supress this message. Thanks