1 2 Previous Next 24 Replies Latest reply: Oct 5, 2011 3:26 AM by Joel_C Go to original post RSS
      • 15. Re: How to create an Apex 3.1 a session context programmatically?
        659457
        Unfortunately connecting as the app parsing schema does not fix the problem.
        • 16. Re: How to create an Apex 3.1 a session context programmatically?
          60437
          I'll work on this but I'm going to be away for a week. Sorry.

          Scott
          • 17. Re: How to create an Apex 3.1 a session context programmatically?
            659457
            Hi Scott, any progress on this?
            • 18. Re: How to create an Apex 3.1 a session context programmatically?
              60437
              I'm just getting back to pending issues after being away. I'll keep you apprised.

              Scott
              • 19. Re: How to create an Apex 3.1 a session context programmatically?
                60437
                Galit,

                If it still helps you, try this:
                set serveroutput on

                DECLARE
                  l_cgivar_name owa.vc_arr;
                  l_cgivar_val owa.vc_arr;
                  --
                  l_workspace_id number;
                  l_application_id number := 132; /* change this to your application ID */
                  l_user varchar2(30) := 'USERUSER'; /* change this to the username to be associated with the session */
                BEGIN
                     
                     -- set up cgi environment
                  htp.init;
                  l_cgivar_name(1) := 'REQUEST_PROTOCOL';
                  l_cgivar_val(1) := 'HTTP';
                  owa.init_cgi_env(num_params => 1,param_name => l_cgivar_name,param_val  => l_cgivar_val);
                  
                  -- find workspace ID of application
                  for c1 in (select workspace_id from apex_applications where application_id = l_application_id) loop
                    l_workspace_id := c1.workspace_id;
                  end loop;
                 
                  -- set security group ID, session ID, app ID globals
                  wwv_flow_api.set_security_group_id(l_workspace_id);
                  apex_application.g_instance := wwv_flow_custom_auth.get_next_session_id;
                  apex_application.g_flow_id := l_application_id;

                  -- create authenticated session for l_user
                  wwv_flow_custom_auth_std.post_login(
                    p_uname => l_user,
                    p_session_id => null,
                    p_flow_page => apex_application.g_flow_id||':'||1);

                  apex_util.set_session_state('P2_X','foofoo');

                  dbms_output.put_line('workspace:'||v('WORKSPACE_ID')||', session:'||apex_application.g_instance||', user:'||apex_application.g_user||' '||'P2_X = ' || apex_util.get_session_state('P2_X'));

                  -- call wwv_flow.show so that the correct parsing schema is established for the application
                  wwv_flow.show (
                    p_flow_id => apex_application.g_flow_id,
                    p_instance => apex_application.g_instance,
                    p_request => 'FSP_SHOW_POPUPLOV'
                    );
                     
                  -- set security group ID after show request unsets it
                  wwv_flow_api.set_security_group_id(l_workspace_id);

                  -- create collection
                  apex_collection.create_collection_from_query_b('FOO','select * from emp');

                END;
                /
                Scott
                • 20. Re: How to create an Apex 3.1 a session context programmatically?
                  Dietmar Aust
                  Hi Scott,

                  does that really work?

                  When I do (hopefully exactly) the same as you, I will have a different session id (apex_application.g_instance or v('APP_SESSION')) than before the call to wwv_flow.show.

                  Could you please verify this?

                  Just add another
                  dbms_output.put_line('workspace:'||v('WORKSPACE_ID')||', session:'||apex_application.g_instance||', user:'||apex_application.g_user||' '||'P2_X = ' || apex_util.get_session_state('P2_X'));
                  to the end of your testcase and check the two session ids (before wwv_flow.show and after). In my case they are different.

                  If you cannot reproduce the issue then the problem is in my code. I have tested on 3.1.2.

                  Thanks,
                  ~Dietmar.
                  • 21. Re: How to create an Apex 3.1 a session context programmatically?
                    60437
                    Dietmar,

                    I get the same session ID before and after the call to show. What schema are you connecting as to run this?

                    Scott
                    • 22. Re: How to create an Apex 3.1 a session context programmatically?
                      244118
                      Scott,

                      I need to call wwv_flow.show more than once in the code, the first call to wwv_flow.show works but the next call to wwv_flow.show will get
                      ORA-01403: no data found. Please advise. Thanks.

                      Below is the code I am using
                      DECLARE
                      l_cgivar_name owa.vc_arr;
                      l_cgivar_val owa.vc_arr;
                      --
                      l_workspace_id number;
                      l_application_id number := 102; /* change this to your application ID */
                      l_user varchar2(30) := 'OCS'; 
                      
                      BEGIN
                      
                      -- set up cgi environment
                      htp.init;
                      l_cgivar_name(1) := 'REQUEST_PROTOCOL';
                      l_cgivar_val(1) := 'HTTP';
                      owa.init_cgi_env(num_params => 1,param_name => l_cgivar_name,param_val => l_cgivar_val);
                      
                      -- find workspace ID of application
                      for c1 in (select workspace_id from apex_applications where application_id = l_application_id) loop
                      l_workspace_id := c1.workspace_id;
                      end loop;
                      
                      -- set security group ID, session ID, app ID globals
                      wwv_flow_api.set_security_group_id(l_workspace_id);
                      apex_application.g_instance := wwv_flow_custom_auth.get_next_session_id;
                      apex_application.g_flow_id := l_application_id;
                      
                      -- create authenticated session for l_user
                      wwv_flow_custom_auth_std.post_login(
                      p_uname => l_user,
                      p_session_id => apex_application.g_instance,
                      p_flow_page => apex_application.g_flow_id||':'||168);
                      
                      apex_util.set_session_state('P168_ID','434');
                      
                      wwv_flow.show (
                      p_flow_id => apex_application.g_flow_id,
                      p_instance => apex_application.g_instance,
                      P_FLOW_STEP_ID => '168'
                      );
                      
                      wwv_flow_api.set_security_group_id(l_workspace_id); 
                      
                      apex_util.set_session_state('P168_ID','435');
                      
                      wwv_flow.show (
                      p_flow_id => apex_application.g_flow_id,
                      p_instance => apex_application.g_instance,
                      P_FLOW_STEP_ID => '168'
                      );
                      
                      END;
                      • 23. Re: How to create an Apex 3.1 a session context programmatically?
                        863311
                        Hello, sorry, if I'm offtopic, but I woulld like to open a new window with a new session from my application, and I don't want to log in to the application again (I mean I don't want to type the username and password again).
                        How can I do it?
                        Thanks!!
                        • 24. Re: How to create an Apex 3.1 a session context programmatically?
                          Joel_C
                          Please do not post responses to old threads -

                          1. Despite superficial appearances, the content of the thread may not be related to your particular issue
                          2. Contributors to the original thread may not use the forum anymore or might * ahem * PLEASE READ (NOT SPAM!): Expert Oracle Application Express, by conventional means anyway.
                          3. There are no reward points available, thus discouraging other users from attempting to provide help.

                          Repost your well formed question (with reference to the additional information requested in the forum FAQ) as a new thread and, if necessary, make references to old threads within the new one to provide context.
                          1 2 Previous Next