How to create an Apex 3.1 a session context programmatically?

Hi
I want to do some unit testing on some pl/sql procedures that use apex collections. As I am using PL/SQL Developer and I am not connected to the database via Apex, inevitably they fail with the error "invalid parsing schema for the current workspace ID".
How can I create programmatically a session in Apex so I can unit test my code? I am sure I have seen code to do it, but cannot find it anywhere.
Thanks
Luis

Scott
Thanks for the help!
You say "uncomment the last line if you need to". How do I know if I need to? If the connected user is different from the application parsing schema?
In any case, the connect user is the same as the app parsing schema, and when I ran it without uncommenting that last line I got the error:
ORA-20104: create_collection_from_query_b Error:ORA-20001: Invalid parsing schema for current workspace ID
ORA-06512: at "FLOWS_030100.WWV_FLOW_COLLECTION", line 1223
Then I uncommented it (I granted execute to the package beforehand) but got the same error.
As I said, I am connected as the same database user as the application parsing schema, and the application does not require authentication. Where did it go wrong?
Please see below the code I am using.
Thanks
Luis
declare
  l_workspace_id   number;
  l_application_id number;
  l_user           varchar2(30);
  l_owner          varchar2(30);
  l_cgivar_name    owa.vc_arr;
  l_cgivar_val     owa.vc_arr;
BEGIN
  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);
  l_user           := 'ADMIN'; -- authenticated username
  l_application_id := 999; -- application ID
  l_owner          := 'PS'; -- application owner (parsing schema)
  for c1 in (select workspace_id
             from   apex_applications
             where  application_id = l_application_id)
  loop
    l_workspace_id := c1.workspace_id;
    dbms_output.put_line('l_workspace_id:' || l_workspace_id);
  end loop;
  wwv_flow_api.set_security_group_id(l_workspace_id);
  apex_application.g_instance     := 1;
  apex_application.g_flow_id      := l_application_id;
  apex_application.g_flow_step_id := 1;
  wwv_flow_custom_auth_std.post_login(p_uname      => l_user,
                                      p_session_id => null,
                                      p_flow_page  => apex_application.g_flow_id || ':' || 1);
  flows_030100.wwv_flow_security.g_parse_as_schema := l_owner;
  -- Call the procedure
  my_pkg.my_proc;    --- ERROR HERE
end;

Similar Messages

  • How to create an apex collection to store and loop through the values

    I couldn't find any simple example to do this
    Apex 4.2
    I need to create an apex collection. I have a query that returns multiple roles for a user. I need to check to see if one of my item values is within the collection but am not sure how to do so. So far I have:
    begin
    APEX_COLLECTION.CREATE_COLLECTION (
    p_collection_name => 'ALL_ROLES');
    select count(granted_role) into count from dba_role_privs where upper(grantee) = upper(:APP_USER);
    end;
    How would I store the query results in the collection?

    Trying to understand your code and a better suggestion:
    declare
    is_viewable boolean;
    v_count number;
    l_query varchar2(2000);
    i_counter number(10) :=1;
    begin
    --l_query := 'select granted_role from dba_role_privs where upper(grantee) = upper(:APP_USER)';
    --why do you need a collection, this is a simple select count(1) question
    APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY (
    p_collection_name => 'ALL_ROLES',
    p_query => l_query,
    p_generate_md5 => 'YES');
    -- You create a collection, but where are you using it?
    -- select count(granted_role) into count from dba_role_privs where upper(grantee) = upper(:APP_USER);
    -- discard the above code
    -- If you want to see  how many elements in a collection
    -- determine # of elements in a collection
    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_collection.htm#CJAFFEAH
    v_count := APEX_COLLECTION.COLLECTION_MEMBER_COUNT ('ALL_ROLES');
    IF :P32_SUBMISSION_DATE IS NOT NULL THEN
      begin
      select count(granted_role) into v_count
         from dba_role_privs
      where upper(grantee) = upper(:APP_USER) and
        granted_role in ('SURVEY_SUID','SURVEY_JOB_SUID');
      exception
      when no_rows_found then
        v_count := 0;
      end;
      if v_count > 0 then
        is_viewable := true;
      else
        is_viewable := false;
      endif;
    else
      is_viewable := false;
    endif;
    return is_viewable;
    end;Thank you,
    Tony Miller
    Ruckersville, VA

  • How to create an APEX 4.1 session?

    Hi,
    I've successfully used the mechanism described by [this thread|https://forums.oracle.com/forums/thread.jspa?threadID=663227] to create an APEX session in release 3.1.
    We've recently been forced to move onto Oracle 11g and APEX 4.1. The session routine no longer appears to work:
    - after setting up the session a call to the create_collection_from_query results in an error stating 'Invalid parsing schema for current workspace Id';
    - the apex_application.g_instance value is changing - post_login changes the value and show loses the value;
    Any ideas?

    Hi Scott
    Bad news. I read several time this thread, but I have not found error in my program ... .
    And I can not see what are really doing APIs of APEX.
    Time is going - so we have make a decision now.
    Probably (as I have no more answers at this forum) - we can not use APEX (as nobody using APEX sessions as I asked),
    as we can not manage its sessions programmatically (too risky).
    Thanks for your answer.
    Andres

  • How to create an apex session in e.g. SQL*Plus?

    I would like to establish an apex session using a tool different from SQL Workshop.
    How can I achieve this using e.g. SQL*Plus or SQL Developer?
    Is there some document on the internet which addresses this question? I couldn't find it yet.

    First and foremost you need to set the Security Group ID (SGID)
    begin
    APEX_UTIL.SET_SECURITY_GROUP_ID(APEX_UTIL.FIND_SECURITY_GROUP_ID('MY_WORKSPACE'));  -- replace MY_WORKSPACE with yours
    end;
    then you might need to set an application_id for certain features to work:
    select application_id
        into apex_application.g_flow_id
        from apex_applications
       where application_name = 'my_app_name';  -- replace my_app_name with yours
    If you need to create a session id, you can get a fresh one with
    DECLARE
      VAL NUMBER;
    BEGIN
      VAL := APEX_CUSTOM_AUTH.GET_NEXT_SESSION_ID;
    END;
    Flavio
    http://oraclequirks.blogspot.com
    http://www.yocoya.com

  • How to create a attachement field in the conent type programmatically ?

    Hi Every One,
    i want to create 3 attachment fields in sharepoint content type.
    how we can create it
    Thoughts ?
    Regards,

    Check if below hlps
    http://social.technet.microsoft.com/wiki/contents/articles/20267.sharepoint-2010-create-site-columns-and-content-types-using-c-net.aspx
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/c17500fa-bf14-4e16-ace8-5c382bb4c7c4/invalid-request-attempting-to-set-content-type-field-for-creating-list-item-in-sharepoint-2013?forum=sharepointdevelopment
    SPSite site = new SPSite("your site");
    SPWeb web = site.OpenWeb("your web");
    SPField field = web.Fields["field Name"];
    SPFieldType fieldType = field.Type;
    switch (fieldType)
    case SPFieldType.AllDayEvent:
    break;
    case SPFieldType.Attachments:
    break;
    case SPFieldType.Boolean:
    break;
    case SPFieldType.Calculated:
    break;
    case SPFieldType.Choice:
    break;
    default:
    break;...
    }http://stackoverflow.com/questions/2200369/check-which-field-type-column-belongs-programmatically-in-sharepoint

  • How to create/get user & role in Weblogic 9.2 programmatically?

    Hi,
    I am new to Weblogic 9.
    I need to create a web service to manage user/role in WebLogic 9.
    Searching thru the web and found some classes like:
    AtnSecurityMgmtHelper, AtnProviderDescription etc
    Are those the correct classes to create/retrieve user & role?
    If so, what jar file contains those classes and where is the jar
    file?
    Thanks in advance,
    Terry

    You can do it with WLST help
    http://e-docs.bea.com/wls/docs92/config_scripting/config_WLS.html#wp1019913
    or via JMX through http://e-docs.bea.com/wls/docs92/javadocs/weblogic/management/security/authentication/UserEditorMBean.html and such

  • How to create a physical table with a session variable.

    Hello,
    I have been trying to accomplish accessing data multiple databases from a single rpd and single connection pool. Is there a way to do it using session variables and OBIEE stored procedures or something. If someone has anything I could read up(unless I have already googled it), it would really help me out.
    Thanks.

    Where is there a need to access multiple DBs using the same connection pool?
    Just curious.

  • How to Create a Page LOV Template and a Region LOV Report Template in APEX

    Hi All,
    Thanks in advance ..
    I am new to APEX , Currently working in APEX 3.2
    Can any one please guide me How to Create a Page LOV Template and a Region LOV Report Template in APEX
    So that I can create dynamic Multi column LOV in APEX
    Cheers
    Sachin

    Sachin,
    I think you are en-quiring about 'Custom pop-up page'. See this link. You will get all required info there.
    Regards,
    Hari

  • How to create a fixed-width column within an APEX 4 interactive report?

    This thread is a follow-up to {message:id=9191195}. Thanks fac586.
    Partial success: The following code provided by fac586 limits the column width of the Apex 4 interactive report column as long as the column data contains whitespace within a Firefox 3.6 browser:
    <pre class="jive-pre">
    <style type="text/css">
    th#T_DESCRIPTION {
    width: 300px;
    td[headers="T_DESCRIPTION"] {
    width: 300px;
    word-wrap: break-word;
    </style>
    </pre>
    Notes:
    1. The code above is put into the HTML header section for the page.
    2. T_DESCRIPTION is defined as VARCHAR2(2000).
    3. The code above works within the Firefox 3.6.12 browser but does not work within the Internet Explorer 7.0.5730.13 browser.
    I tried adding "float: left;":
    <pre class="jive-pre">
    <style type="text/css">
    th#T_DESCRIPTION {
    width: 300px;
    td[headers="T_DESCRIPTION"] {
    width: 300px;
    word-wrap: break-word;
    <font color="red"> float: left;</font>
    </style>
    </pre>
    Notes:
    1. "float: left;" does not require whitespace and successfully splits the column between characters in lieu of whitespace.
    2. "float: left;" shrinks the cell height and allows the page background to show through... couldn't determine how to fix this.
    3. The code above works within the Firefox 3.6.12 browser but does not work within the Internet Explorer 7.0.5730.13 browser.
    I've done some more research, but I still haven't discovered how to create a fixed-width column within an APEX 4 interactive report that displays properly within an Internet Explorer 7 browser.
    Any ideas and help will be appreciated.

    Thanks for your help with this!
    <pre class="jive-pre">
    what theme are you using?
    </pre>
    A customized version of theme 15.
    <pre class="jive-pre">
    Floating a table cell makes no sense (to me anyway).
    </pre>
    You are correct. I was just trying a different approach ... trying to think out of the box.
    <pre class="jive-pre">
    Think you'll need to create an example on apex.oracle.com with sample data
    if there are any further problems.
    </pre>
    Great suggestion! The code your provided works in the Firefox 3.6.12 browser, but still doesn't work within my Internet Explorer 7.0.5730.13 browser.
    UPDATE:
    I have recreated the problem at apex.oracle.com, you can use the following information to check it out:
    URL: http://apex.oracle.com/pls/apex/f?p=43543:100::::::
    Workspace: IR_FIXED_WIDTH_COLS
    Username: GUEST
    Password: Thx4help
    Application: 43543 - CM_RANDY_SD
    Note: Table name is TEST_DATA
    The following code provided by fac586 works in both Firefox 3.6 and IE7 using default theme "21. Scarlet" at apex.oracle.com; however, it doesn't work when I use a copy of our customized theme "101. Light Blue":
    <pre class="jive-pre">
    <style type="text/css">
    .apexir_WORKSHEET_DATA {
    th#T_DESCRIPTION {
    width: 300px;
    max-width: 300px;
    td[headers="T_DESCRIPTION"] {
    max-width: 300px;
    word-wrap: break-word;
    </style>
    <!--[if lt IE 8]>
    <style type="text/css">
    /* IE is broken */
    th#T_DESCRIPTION,
    td[headers="T_DESCRIPTION"] {
    width: 300px;
    </style>
    <![endif]-->
    </pre>
    Any idea what in the theme could be causing the fixed width column to be ignored in IE 7?
    Edited by: CM Randy SD on Dec 7, 2010 11:22 AM

  • How to create a session variable in Apex?

    Hello colleagues,
    Is there someone do know how to create a session variable in Apex?
    How to get them?
    Thanks
    Best Regards

    Hello,
    What do you mean by 'session variable'? You mean something that stores the value int he users session state?
    I really recommend reading the 2-Day Developer guide documentation, there is a complete section on session state -
    http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10499/concept.htm#CIHCFHBD
    Hope this helps,
    John
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd

  • How to create a omniportlet for oracle portal with apex

    Hello everyone!
    Is there someone who knows how to create a omniportlet?
    This is for openning an application in apex from oracle portal using single sign on.
    Could you explain me step by step how to do this please?
    Thank you.
    Regards

    Hello Erik,
    Please check if the following can help you - http://www.oracle.com/technology/products/database/application_express/howtos/omniportlet_index.html .
    Regards,
    Arie.

  • How to create a system  parameter in Apex

    Hi friends,
    I am new to Oracle Apex and need to know how to create a System Parameter in Apex. Kindly let me know how to add one.
    Regards,
    Pradeep

    bluerose wrote:
    I am new to Oracle Apex and need to know how to create a System Parameter in Apex. Kindly let me know how to add one.
    using the privileges we can achieve this.Although I am not new to APEX I have no idea what you are talking about.
    What is "a System Parameter in Apex"? What "privileges" are used to create one?
    You'll find it easier to get help if you use terminology that is familiar to everyone...

  • How to create page zero in oracle apex 4.0?

    Hi All,
    How to create page zero in oracle apex 4.0?
    Regards
    Mani

    Hi,
    Home > Application Builder > Application xxx > Create Page
    At bottom center on wizard there is Page Zero
    Regards,
    Jari
    Edited by: jarola on Aug 25, 2010 7:28 PM
    And here is chapter about in documentation
    http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/ui.htm#BGBFFFGH

  • Step how to create a duplicate record button in APEX

    HI,
    Where do i find out the document step by step with the code behind on how to create a button to copy a record with master and detail in APEX.  My email address is [email protected]  Thanks.
    Thu Tran

    If you are using ADF BC you can also try this
    http://adftips.blogspot.com/2010/10/adf-model-creating-duplicate-row.html
    Regards
    Nicolas

  • How to create Shuttle Item in APEX

    Hi,
    could you please anyone let me know the steps of how to create shuttle item in APEX?
    Thanks for your help
    Thanks
    Sri

    Hi Jitendra,
    Thanks for replying.
    my query like this.
    select * from table1,table2
    where
    table1.value not in 'CABINET' ---- here i need to create shuttle
    and table2.name like 'B%' --- this is just text box
    table3. value is coming from LOV.
    could you please let me know how to create value as shuttle, in shuttle wht are the changes do i need to make changes?
    Thanks
    Sri

Maybe you are looking for