Apex_util.set_session_state issue

Hi
In order to try and workaround the issue reported in Translate substitutions I have been trying to set application item values using apex_util.set_session_state but this doesn't appear to be working.
The problem in the thread was that when the admin user changed the values of substitutions these are only changed in the primary application and not the seeded ones. I understand that we are perhaps using substitutions differently to other people and although this problem has been acknowledged by Oracle I thought there might be a relatively simple solution for us.
What I'd like to do is implement code similar to below as an application process:
BEGIN
  FOR i IN (SELECT * FROM apex_application_substitutions
            WHERE application_id = :APP_ID) LOOP
    apex_util.set_session_state(i.substitution_string||'1', i.substitution_value);
  END LOOP;
END;When running the seeded application the APP_ID is that of the primary application. So this code will pick up the values of the substitutions from the primary application and save these as values for similarly named application items in the current session, which we'd then refer to instead. This isn't ideal as we will need to re-write a lot of code, but at least it means we can translate our applications which we can't do at present.
However, the spplication item values are not set. I've done some investigation just looking at the primary application, so ignoring translation and seeded application completely. I've been working on APEX 4.0.2 but found that there was a reported bug, apex_util.set_session_state don't works after upgrade from 4.0.1 to 4.0.2 This may be relevant, but I'm unable to apply the patch. So I've investigated on apex.oracle.com which is APEX 4.1 and I have been able to reproduce the problem. Just incase it matters I've got no authentication or authorization on my application.
The problem can be seen here: http://apex.oracle.com/pls/apex/f?p=56303 The section of interest is the output not the form. Here I've output what I'm doing and the values of the application items after each step. The application items are called SUB_VALUE1 and 2ND_VALUE1 and my substitutions are called SUB_VALUE and 2ND_VALUE. At the end I set the application items to null, so they will always start null. The output is as follows:
(0) SUB_VALUE1 =
(0) 2ND_VALUE1 =
apex_util.set_session_state(i.substitution_string||'1', i.substitution_value);
(1) SUB_VALUE1 =
(1) 2ND_VALUE1 =
apex_util.set_session_state('SUB_VALUE1',i.substitution_value);
(2) SUB_VALUE1 =
(2) 2ND_VALUE1 =
:SUB_VALUE1 := i.substitution_value;
(3) SUB_VALUE1 = Primary App Value
(3) 2ND_VALUE1 =
apex_util.set_session_state('SUB_VALUE1','XYZ');
(4) SUB_VALUE1 = Primary App Value
(4) 2ND_VALUE1 =
apex_util.set_session_state(i.substitution_string||'1', i.substitution_value);
(1) SUB_VALUE1 = Primary App Value
(1) 2ND_VALUE1 =
apex_util.set_session_state('SUB_VALUE1',i.substitution_value);
(2) SUB_VALUE1 = Primary App Value
(2) 2ND_VALUE1 =
:2ND_VALUE1 := i.substitution_value;
(3) SUB_VALUE1 = Primary App Value
(3) 2ND_VALUE1 = Second value
apex_util.set_session_state('2ND_VALUE1','ABC');
(4) SUB_VALUE1 = Primary App Value
(4) 2ND_VALUE1 = Second valueYou can see that no values are set using apex_util.set_session_state, even explicitly stating the application item name and value (e.g. apex_util.set_session_state('2ND_VALUE1','ABC');) does not set or update the value.
This could be as simple as the patch hasn't been included in APEX 4.1 or maybe I am missing something obvious. Unfortunately I'm unable to test this in 4.0.1 or any other version, to see if it's just a problem in 4.0.2 and 4.1.
If someone could confirm if the patch has been included in 4.1 or if this is a new issue. Or perhaps point me to another post answering this (I couldn't find one) or just show me the error of my ways that would be brilliant.
Cheers
Sara

Further, what should the 'Source' be set to for these hidden items.Static Assignment, with Source Used set to Only...
Scott

Similar Messages

  • Apex_util.set_session_state + user id

    Hi,
    In my login process I have the following two calls, where user_group and user_id are application level items
    apex_util.set_session_state('USER_GROUP', apex_util.get_groups_user_belongs_to(:APP_USER));
    apex_util.set_session_state('USER_ID', apex_util.get_user_id(:APP_USER));
    After I login, when I check the session state, I have the user_group populated correctly but not the user_id item. When I use a debug to print out what is happening using apex_util.get_session_state('USER_ID'), it seems to print the correct value.
    THis is what I have in my debug output
    0.01: Branch point: BEFORE_PROCESSING
    0.01: Processing point: AFTER_SUBMIT
    0.01: ...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.01: ...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.01: ...Process "set_application_items": PLSQL (AFTER_SUBMIT) BEGIN pkg_utils.debug('In set_application_items. Going to set appl item values for appuser' || :APP_USER); apex_util.set_session_state('USER_GROUP', apex_util.get_groups_user_belongs_to(:APP_USER)); apex_util.set_session_state('USER_ID', ape
    0.01: ****Application Debugging: In set_application_items. Going to set appl item values for appuserCHAND****
    0.03: ...Session State: Save Item "USER_GROUP" newValue="ADMIN, AMPINV, AMPMGR, AMRINSTLR, AMRPLN, AMRSURVYR, IT, LV, LVPLN, MANAGER, MR, MANAGER" "escape_on_input="Y"
    0.03: ...Session State: Save Item "USER_ID" newValue="4110819710784391" "escape_on_input="Y"
    0.03: ****Application Debugging: In set_application_items. Set the session state. User id is now , from session state it is 4110819710784391 now getting person id****
    0.03: ****Application Debugging: In set_application_items. Done. User id is ,and username is CHAND, and session user id is 4110819710784391****
    0.03: ...Session State: Saved Item "USER_ID" New Value=""
    0.03: ...Session State: Save Item "PERSON_ID" newValue="12" "escape_on_input="Y"
    0.03: ...Process "Clear Page(s) Cache": CLEAR_CACHE_FOR_PAGES (AFTER_SUBMIT) 101
    0.03: Nulling cache for application "102" page: 101
    How do I sort this ? I've got the exact same code in another application and there the user_id is populated correctly. Any pointers welcome.
    Thank you,
    Chandini

    Hi,
    Just an update. I've sorted this problem though I do not understand why there was a problem.
    After my call to the Apex_util.set_session_state, I had an anonymous block written to look up some data from the db. And for some reason this was causing the problem. So I've had to move that bit into a separate process and it all seems to work now.
    Though, if somebody could explain why it was a problem in the first place it would be useful to know.
    Ta,
    Chandini

  • Apex_util.set_session_state don't works after upgrade from 4.0.1 to 4.0.2

    Hi!
    We have custom authentication scheme with "Page Sentry Function" and "Post-Authentiaction Process" defined.
    Page sentry function called wwv_flow_custom_auth.define_user_session procedure.
    Post-authentiaction process called apex_util.set_session_state procedure to set some application items.
    All works fine until we upgraded from version 4.0.1 to 4.0.2 (patch 10173973).
    In verion 4.0.2 apex_util.set_session_state does nothing....
    This is a bug or a feature? :)
    Thanks.

    Hi, Patrick!
    Test case on http://apex.oracle.com/pls/apex/f?p=31741
    1. Run http://apex.oracle.com/pls/apex/f?p=31741 (Values of items F31741_USERID and F31741_USERINFO are not null)
    2. Login into apex builder (workspace: WS_AVER, user: VERSALAO, pass: qwerty%)
    3. Run page 1. Values of items F31741_USERID and F31741_USERINFO is null
    4. Logout from apex builder
    5. Run http://apex.oracle.com/pls/apex/f?p=31741 - "ERR-1201 session ID not set on custom authentication" displayed
    Where is an error in my code?
    Thanks.
    Edited by: user12288359 on 25/11/2010 7:23

  • How to trap APEX_UTIL.SET_SESSION_STATE errors like ERR-1002?

    Hi team,
    i noticed that when i call APEX_UTIL.SET_SESSION_STATE and the relevant page item or application item doesn't exist, this API procedure doesn't return a normal oracle exception but, i guess, it sets some status flag in the Apex engine that causes ERR-1002 to be reported. This is the behaviour i am seeing on Apex 3.1.2 and Apex 3.2.
    Is there any way to work around this?
    Thank you
    Flavio
    http://oraclequirks.blogspot.com

    Yes I realised it... I think I read your original post too hastily!
    I personally don't like tampering with code I don't have full access to... You never know if it will work with the next release or if you have covered all bases. So the solution I decided to use was to override the original apex function with my own (Apex 3.2):
      Checks whether a page item exists in the current application.
      Returns: TRUE if it does and FALSE otherwise.
      FUNCTION page_item_exists(p_name IN VARCHAR2) RETURN BOOLEAN IS
      BEGIN
        FOR r IN (SELECT i.item_name
                  FROM   apex_application_page_items i
                  WHERE  i.application_id = v('APP_ID')
                  AND    i.item_name = upper(p_name))
        LOOP
          RETURN TRUE;
        END LOOP;
        RETURN FALSE;
      END;
      Set session state.
      Raises an exception if the item does not exist.
      PROCEDURE set_session_state(p_name  IN VARCHAR2,
                                  p_value IN VARCHAR2) IS
      BEGIN
        IF NOT page_item_exists(p_name => p_name)
        THEN
          raise_application_error(-20000,
                                  'Item ' || p_name || ' does not exist');
        ELSE
          apex_util.set_session_state(p_name => p_name, p_value => p_value);
        END IF;
      END;Luis

  • Issue with Setting Application Item

    Hi All,
    I have an issue with setting the value of application item G_USER_ID as part of the login process.
    I use customized authentication for login. I have created an application item G_USER_ID, and in my CUSTOM_AUTH procedure, I am setting its value as APEX_UTIL.SET_SESSION_STATE('G_USER_ID', l_user_id);
    For some reason, the value is not set to G_USER_ID the first time I login. When I log out and login again without closing the browser, the value is set. Note that I even tested with a static value instead of l_user_id like APEX_UTIL.SET_SESSION_STATE('G_USER_ID', '5555555'); but still fails to set during the first login.
    I hope someone can guide me as to what I am doing wrong here.
    Thanks!
    JMcG

    What does this do?
    :SVR_FLAG := NVL(l_mult_svr,'N');
    Scott

  • KNOWN ISSUE: Problem using GET_PRINT_DOCUMENT to produce multiple PDFs.

    Hi Folks
    I'm calling a report stored in APEX (Shared Components Report Query & Layout) many times using a loop in a process on my page.
    At each iteration of the loop I am updating the value of a hidden text item on the page which is the one and only parameter of the report.
    I update the hidden text item using APEX_UTIL.SET_SESSION_STATE.
    The first time I call the report from the process it works perfectly, the .pdf file is produced and stored in a BLOB column in the database.
    The problem is that all subsequent iterations of the loop to produce the report result in a report .pdf being generated and stored but with no database values. As if the hidden text item value was NULL or not valid for the query.
    I know there is no problem with the report queries or the parameter values I am using. I have tested this by forcing the initial value set by APEX_UTIL.SET_SESSION_STATE to be the next record I would have supplied in the loop. Again, the first report is generated with data and all subsequent reports get generated with no data.
    It appears that whilst I can use APEX_UTIL.SET_SESSION_STATE to loop through and update the value of the hidden text item my report refers to for it's parameter, the report process only seems to recognise the first iteration and none of the subsequent ones.
    Can anyone shed any light on this or offer any suggestions?
    Many thanks
    Dogfighter.

    Hi Scott.
    I have set up a bare bones demo of what the page looks like. You'll see what I'm doing.
    You can have a poke around using...
    Workspace :SIMONGADD
    User ID :[email protected]
    Password :hopeli
    I have not created the report query & template but suffice to say, in the real world app the report query has one parameter. In this demo example the report query would end with..
    "where order_id = :P1_ORDER_ID"
    I have tried, in my app, setting the :P1_ORDER_ID to text/hidden/display only. no difference in behavior.
    My logging insert statement records that the order ID is being updated in each iteration of the loop.
    I have noted the behavior of the report output is as follows...
    1) First report is generated perfectly.
    2) Second report DOES include two bits of data (out of dozens)
    3) Third report & onwards contain no data at all but the PDF files and placeholder structure of the reports are generated.
    If I force the loop to start providing order_ids in a different order, or from a different starting order number I get the same behavior. The first order PDF is produced perfectly (so I deduce no issues with the query or the template), the second one just contains data in the same two report items, and the third and subsequent reports are empty.
    Any suggestions welcome.
    I would be happy to email you the report template rtf, query, and report outputs if you like.
    Kind regards
    Simon

  • APEX 4.1 APEX_UTIL.CLEAR_PAGE_CACHE Bug

    Hi,
    I found the following issue in APEX 4.1. It's easiest described with an example:
    Before going into a page process suppose P1_X = 'abc' in session state;
    -- First page process (coming in P1_X = 'abc')
    l_backup := :P1_X;
    apex_util.clear_page_cache(:app_page_id);
    :P1_X := l_backup;
    -- Second page process (following the page process above)
    -- This prints the value of P1_X to the screen
    sys.htp.p(':P1_X: ' || nvl(:P1_X, 'null'));
    -- Results:
    -- APEX 4.0: (expected value)
    :P1_X: abc
    -- APEX 4.1 (incorrect)
    :P1_X: nullIf I change +:P1_X := l_backup;+ line to apex_util.set_session_state('P1_X', l_backup); the output is:
    -- Results (correct):
    -- APEX 4.0:
    :P1_X: abc
    -- APEX 4.1
    :P1_X: abcIf I change the +:P1_X := l_backup;+ line to +:P1_X := 'def';+ the output is:
    -- Results (correct):
    -- APEX 4.0:
    :P1_X: def
    -- APEX 4.1
    :P1_X: defIt appears in 4.1 that any time a page item is set following a clear cache call (this issue also happens for clear_app_cache) and the page item value is the same as it was before the clear cache value (using a bind variable set) then its value is null in session state once the page process completes.
    This was found in APEX version 4.1.1.00.23 and compared against 4.0.2.00.09
    Martin
    http://www.ClariFit.com
    http://www.TalkApex.com
    Edited by: Martin Giffy D'Souza on Oct 5, 2012 3:36 PM

    Hi Martin,
    thanks for reporting this. This change was introduced during a code reorg in 4.1.
    The reason for the current behaviour is our dynamic code exec implementation:
    1. create cursor and parse as user
    2. for all bind variables:
    3.      save session state value in local variable array
    4.      bind local value in cursor
    5. execute cursor
    6. for all bind variables:
    7.     if current bind value is different to local variable array value:
    8.         save current value in session state Step 7 only detects a change if the bind variable value itself has been modified in the dynamic pl/sql block. I filed bug #14731783 to fix this, but we will probably ship it with the first patch set.
    As a work-around, you should be able to use
    l_backup := :P1_X;
    apex_util.clear_page_cache(:app_page_id);
    apex_util.set_session_state('P1_X', l_backup);
    which does not rely on the dynamic code exec for writing back the original value of P1_X.
    Regards,
    Christian

  • 'Search': Filtering issue

    Hi All,
    I have an issue with the search feature.
    I have a couple of select lists and text fields (search) with which i am filtering a report(classic).
    for select list i tried using the below two options in the region source where conditions.
    1. where emp_name = :P2_EMPNAME
    2. where DECODE(:P2_EMPNAME,'%null%',emp_name,null,emp_name,:P2_EMPNAME);
    My issue is, when i use the option 2, the number of records are becoming less. For example, if I have 2,000 records. It becomes 1980 when I apply one filter and if I apply another filter it becomes ~1940. Why is this issue occurring? I am using a static LOV for the data i need to filter.
    Please suggest me if there is anything i missing or any work around to filter.
    And one other issue I have for text field search, I am fine using a text field filter since i usually follow one of the below formats
    1. where emp_name like lower(:P2_EMPNAME)
    2. where emp_name like '%'||:P2_EMPNAME ||'%'
    What if there is a combination of 'capital' and 'small' alphabets in the data? How to overcome this?
    I am using 3.1 version and 9i DB
    Thanks All in Advance,
    Daniel

    Daniel,
    For your first question, that really depends on what the value of :P2_EMPNAME is and what is in your table. One thing that i include in all of my applications prior to 4.0 is i make an application processes that runs "on load before header" and i set its sequence to -9999.
    BEGIN 
        FOR x IN (SELECT *
                  FROM (SELECT item_name
                          FROM apex_application_page_items aapi
                         WHERE aapi.application_id = :app_id
                           AND aapi.page_id = :app_page_id
                           AND LOWER (aapi.lov_display_null) = 'yes'
                           AND aapi.lov_definition IS NOT NULL
                           AND aapi.lov_null_value IS NULL
                           AND ROWNUM > 0) x
                 WHERE LOWER (v (x.item_name)) = '%null%') LOOP
            apex_util.set_session_state (x.item_name, NULL); 
        END LOOP;
    END; This converts all page items with teh value of "%NULL%" to atually be null so you do not have to work around it anymore. Because this process runs before header and it is set to sequence -9999 it should run before all of your other processing.
    You will kill your index by modifying the database column in your predicate but for multicase columns you can use:
    where lower(emp_name) like '%' || lower(:P2_EMPNAME) || '%'Cheers,
    Tyson Jouglet

  • Authentication issue with 4.1

    We are using a custom authentication scheme. It calls the authenticatin api to authenticate agains active directory.
    It is working in multiple apex aplications in apex version 3.2. We created a new install of 4.1 and imported the apps from 3.2
    I can't get this authentication to work in 4.1. Here is the code that works in 3.2 but not in 4.1
    This code is in the login process of page 101.
    The error msg I get is Invalid Login Credentials
    I have created the application at the oracle hosted site. id/wd id guest/Lock01$
    Off course for simplicty, all the code does is emualte how I am logging in at the 3.2 install. All other code has not been copied over. This application works on our 3.2 install but not 4.1! Help!
    {declare
    b_result boolean := false;
    c_result boolean := false;
    d_result boolean := false;
    begin
    -- :IS_ADMIN_USER := 0;
    -- :IS_IE_USER := 0;
    :USERNAME := :P101_USERNAME;
    :PASSWORD := :P101_PASSWORD;
    -- for security reasons I commented out the server and base domain info. in this call.
    b_result := LDAP2.AUTHENTICATE_ADUSER(:P101_USERNAME, :P101_PASSWORD, :P101_DOMAIN, '#####.####.com', 'DC=####,DC=####,DC=com');
    if (b_result = true) then
    -- I know that session is valid as i displayed a mesg if it was valid to be sure.
    If APEX_CUSTOM_AUTH.IS_SESSION_VALID
    --this was the old way in 3.2 that worked but doesn't in 4.1
    -- wwv_flow_custom_auth_std.post_login(
    -- P_UNAME => :USERNAME,
    -- P_PASSWORD => :PASSWORD,
    -- P_SESSION_ID => v('APP_SESSION'),
    -- P_FLOW_PAGE => :APP_ID||':1'
    -- I tried this in 4.1 but still doesn't work
    APEX_CUSTOM_AUTH.POST_LOGIN (
    p_uname => :USERNAME,
    p_session_id => V('APP_SESSION'),
    p_app_page => :APP_ID||':1');
    End if;
    else
    owa_util.redirect_url('f?p=&APP_ID.:&LOGIN_PAGE.:&SESSION.');
    apex_util.set_session_state('LOGIN_MESSAGE', 'Your ID or PASSWORD is incorrect. Please try again.');
    end if;
    -- :PASSWORD := null;
    end;
    Edited by: ashalon on Mar 16, 2012 11:23 AM
    Edited by: ashalon on Mar 16, 2012 11:25 AM
    Edited by: ashalon on Mar 16, 2012 12:20 PM
    Edited by: ashalon on Mar 16, 2012 3:46 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi ashalon,
    login processing normally calls the authentication scheme's login handler (aka authentication function). In many cases, this is done in a submit process on an Apex login page, that calls
    apex_authentication.login (
        p_username => :P101_USERNAME,
        p_password => :P101_PASSWORD );This procedure (and it's variants, like wwv_flow_custom_auth_std.login) cause the Apex engine to
    1. run the authentication scheme's pre-authentication procedure
    2. pass username and password to the authentication scheme's authentication function, which should return true or false, depending on whether the credentials are valid
    3. if true: run the post-authentication procedure
    4. if true: save the username in session state
    5. if true: prepare a redirect URL to the deep link (i.e. the page that triggered login)
    6. if false: prepare a redirect URL to the login page with a notification_msg that contains the error
    7. log success/failure of the login attempt
    8. generate a new session cookie
    9. perform the redirect
    The exact order and technical details of these steps may vary from Apex version to version.
    The authenentication function (2.) can check against the workspace users table (Apex authentication), the database, an LDAP repository or you can build your own.
    Some authentication schemes rely on external mechanisms to check the credentials and a defined way for these to pass the username back to the authentication scheme. SSO does this in a very special way, the header-based authentication scheme simply relies on a HTTP header variable to transport the username. These authentication schemes never run 1. and 2. from above, but simply accept the username and run 3. - 9. This behaviour is exposed with the post_login procedure.
    Your authentication scheme is interesting. It piggybacks on the Apex authentication scheme, but de facto uses nothing of it. The submit process on the login page checks LDAP credentials and then runs post_login, if the check was successful. You could surely rewrite this as a custom authentication, although the authentication function had to rely on v('P101_DOMAIN') in addition to the username and password that get passed to it by default. Whether the rewrite makes sense is up to you, of course. If you are comfortable with this authentication, stick to it. But it probably would be much easier to understand for others and also easier to reuse in other apps if the LDAP credentials checking was in the authentication scheme.
    Regards,
    Christian

  • Custom authentication issue

    Good Afternoon,
    I am trying to add some code to a custom authentication routine to allow for tracking in the APEX supplied logs. Currently the authentication code processes the Login attempt and either allows access or returns the user back to the login page with a error message in case they entered an invalid username/password.
    I had added in each case the required two lines of code:
    APEX_UTIL.SET_CUSTOM_AUTH_STATUS('Test Message.. Ignore Me')
    APEX_UTIL.SET_AUTHENTICATION_RESULT(1) (Just as a test, will use more accurate values later)
    Now when I login with a non-existent user it logs it as a successful login, with NO custom text loaded...
    Can anyone suggest an idea here, other than using a custom logging table?
    Thank you,
    Tony Miller
    Webster, TX

    Hi,
    I did test set item session state , and it works OK for me.
    First I did forgot create that item when there was errors in my test.
    Do you have some computations, validations in login page ? Any application process that might run ?
    Or do you have any Page Sentry Function, Session Verify Function or Pre-Authentication Process in authentication scheme ?
    What is you session not valid in authentication scheme ?
    Have you tested your code on apex.oracle.com ?
    Br,Jari
    Edited by: jarola on Apr 16, 2010 9:25 AM
    I did more test.
    If you try login with some user name and password
    http://apex.oracle.com/pls/otn/f?p=12444
    Then you can try login with user EXPIRED and passwd test.
    To see access log login with user ACTIVE and passwd test.
    Then go page 10 you can see access log
    http://apex.oracle.com/pls/otn/f?p=12444:10
    My auth function is
    create or replace
    function                            custom_auth_2 (p_username in VARCHAR2, p_password in VARCHAR2)
    return BOOLEAN
    is
      l_password varchar2(4000);
      l_stored_password varchar2(4000);
      l_expires_on date;
      l_count number;
    begin
    -- First, check to see if the user is in the user table
    select count(*) into l_count from demo_users where user_name = p_username;
    if l_count > 0 then
      -- First, we fetch the stored hashed password & expire date
      select password, expires_on into l_stored_password, l_expires_on
       from demo_users where user_name = p_username;
      -- Next, we check to see if the user's account is expired
      -- If it is, return FALSE
      if l_expires_on > sysdate or l_expires_on is null then
        -- If the account is not expired, we have to apply the custom hash
        -- function to the password
        l_password := custom_hash(p_username, p_password);
        -- Finally, we compare them to see if they are the same and return
        -- either TRUE or FALSE
        0, 'AUTH_SUCCESS',
        1, 'AUTH_UNKNOWN_USER',
        2, 'AUTH_ACCOUNT_LOCKED',
        3, 'AUTH_ACCOUNT_EXPIRED',
        4, 'AUTH_PASSWORD_INCORRECT',
        5, 'AUTH_PASSWORD_FIRST_USE',
        6, 'AUTH_ATTEMPTS_EXCEEDED',
        7, 'AUTH_INTERNAL_ERROR',
        if l_password = l_stored_password then
          APEX_UTIL.SET_CUSTOM_AUTH_STATUS('SUCCEEDED');
          APEX_UTIL.SET_AUTHENTICATION_RESULT(0);   
          return true;
        else
          APEX_UTIL.SET_CUSTOM_AUTH_STATUS('WRONG_PASSWORD');
          APEX_UTIL.SET_AUTHENTICATION_RESULT(4);
           APEX_UTIL.SET_SESSION_STATE('LOGIN_MESSAGE','You have entered invalid Username or Password');
          return false;
        end if;
      else
        APEX_UTIL.SET_CUSTOM_AUTH_STATUS('ACCOUNT_EXPIRED');
        APEX_UTIL.SET_AUTHENTICATION_RESULT(3);
         APEX_UTIL.SET_SESSION_STATE('LOGIN_MESSAGE','Your account has been locked');     
        return false;
      end if;
    else
      -- The username provided is not in the DEMO_USERS table
      APEX_UTIL.SET_CUSTOM_AUTH_STATUS('USER_NOT_FOUND');
      APEX_UTIL.SET_AUTHENTICATION_RESULT(1); 
      APEX_UTIL.SET_SESSION_STATE('LOGIN_MESSAGE','You have entered invalid Username or Password');
      return false;
    end if;
    end;I have application item LOGIN_MESSAGE and in login page I did also create before header process.
    APEX_APPLICATION.G_NOTIFICATION := :LOGIN_MESSAGE;
    :LOGIN_MESSAGE := NULL;To show that item message in notification. It do not affect how auth work.
    It seems work ok

  • Null value handling in LOVs

    Has null value handling improved any in HTMLDB 1.6?
    If my LOV has "Display null"=Yes (default null value is %null%) and I need to pass in a database NULL to a After Submit process, I need to do add a After Submit computation for each of these LOVs with something like
    CASE WHEN :P1_ITEM='%null%' THEN NULL ELSE :P1_ITEM END
    I have a couple dozen LOVs on a page and it is getting tiring to go and do this on each and every one!
    Is there a better way?
    Thanks

    Hi Patrick,
    we are currently moving over to Apex 4.02 and are doing some smoke tests on our existing apps.
    I have come across an issue with your generic solution to the %null% issue above (incidently, for a long time it's the first piece of code I include when I start a new app... thank you!)
    We found that a lot of our SQL Query (PL/SQL function body returning SQL query) reports were failing due to the session state of the LOVs still having a session state of %null% even after the RemoveNulls application process had run.
    After debugging your generic process we found that the LOV_NULL_VALUE in the APEX_APPLICATION_PAGE_ITEMS view has changed from NULL to '%null%'.
    so the fix was as below:-
    BEGIN
        FOR rItem IN
          ( SELECT ITEM_NAME
              FROM APEX_APPLICATION_PAGE_ITEMS
             WHERE APPLICATION_ID   = TO_NUMBER(:APP_ID)
               AND PAGE_ID          IN (TO_NUMBER(:APP_PAGE_ID), 0)
               AND LOV_DISPLAY_NULL = 'Yes'
               AND LOV_DEFINITION   IS NOT NULL
    -- change here
               AND LOV_NULL_VALUE  = '%null' || '%'
        LOOP
            IF V(rItem.ITEM_NAME) = '%null' || '%'
            THEN
                Apex_Util.set_session_state(rItem.ITEM_NAME, NULL);
            END IF;
        END LOOP;
    END;Cheers,
    Gus.. (always a fan of your work!)

  • Shuttle and AJaX

    Hello all,
    I have an interesting issue to do with population of a shuttle in 3.1 using AJaX. The session state of selected items is what's causing me dramas, details as follows:
    The left side of the shuttle is populated according to a series of cascading select lists with an optional 'filter' checkbox on each. So every time the value of a select is changed or a checkbox checked/unchecked the ajax process is fired to repopulate the list accordingly.
    My Javascript is:
    function get_ITEMS(){
    var l_Count = 0
    var l_Return = null;
    var l_Select = $x('P2_ITEMS_LEFT');
    var get = new htmldb_Get(null,$v('pFlowId'),
    'APPLICATION_PROCESS=BUILD_ITEMS_SEL',0);
    get.addParam('x01',$v('P2_PRODFILTER'));
    get.addParam('x02',$v('P2_WORKFILTER'));
    get.addParam('x03',$v('P2_COREFILTER'));
    get.addParam('x04',$v('P2_PRODUCT'));
    get.addParam('x05',$v('P2_WORK_TYPE'));
    get.addParam('x06',$v('P2_CORESYSTEM'));
    get.addParam('x07',$v('P2_DISCIPLINE'));
    gReturn = get.get('XML');
    if(gReturn && l_Select){
    l_Count = gReturn.getElementsByTagName("option").length;
    l_Select.length = 0;
    for(var k=0;k<l_Count;k++){
    var l_Opt_Xml = gReturn.getElementsByTagName("option")[k];
    appendToSelect(l_Select, l_Opt_Xml.getAttribute('value'),
    l_Opt_Xml.firstChild.nodeValue)
    get = null;
    and the application level process BUILD_ITEMS_SEL is:
    DECLARE
    v_doprod varchar2(3);
    v_dowork varchar2(3);
    v_docore varchar2(3);
    v_prod varchar2(30);
    v_work varchar2(30);
    v_core varchar2(30);
    v_disc varchar2(30);
    BEGIN
    v_doprod := wwv_flow.g_x01;
    v_dowork := wwv_flow.g_x02;
    v_docore := wwv_flow.g_x03;
    v_prod := wwv_flow.g_x04;
    v_work := wwv_flow.g_x05;
    v_core := wwv_flow.g_x06;
    v_disc := wwv_flow.g_x07;
    owa_util.mime_header('text/xml', FALSE );
    htp.p('Cache-Control: no-cache');
    htp.p('Pragma: no-cache');
    owa_util.http_header_close;
    htp.prn('<select>');
    FOR rec IN (
    SELECT distinct(item) as "ITEM"
    FROM TBL_ROVE_GRADINGS
    WHERE bus_unit = :P2_BUSUNIT
    AND discipline = v_disc
    AND ((product = v_prod or product = 'all') or v_doprod = 'No')
    AND ((work_required = v_work or work_required = 'all') or v_dowork = 'No')
    AND ((core_system like '%'||v_core||'%' or core_system = 'all') or v_docore = 'No')
    order by item asc
    LOOP
    htp.prn('<option value="' || rec."ITEM"|| '">' || rec."ITEM"|| '</option>');
    END LOOP;
    htp.prn('</select>');
    END;
    This all works perfectly well. I can change my cascading selects, select items, refilter and select other items, the AJaX does its lovely stuff and I've got beautiful process flow. I can have the right-hand side populated from multiple different left-hand lists according to filtering choices.
    The problem is when I need to have the selected items remembered in session state. If I navigate away and then return my left-side has retained its session state (it's rebuilt onload from the currently selected cascading select values) but the right-hand side is blank.
    I've got a nasty suspicion that the core of the issue is because the left side may no longer have the values that the right-side session state is looking for to mark as 'selected'.
    Essentially, what I need is a solution that will 'force' the right-side to have the values previously selected for various filtered choices in the left.
    Any thoughts?
    Thanks :D

    Hello Frank,
    >> If I navigate away and then return my left-side has retained its session state
    I’m assuming that “navigate away” means redirecting from the page (without submitting it). In this case, the session state of the page is not saved, and none of the AJAX components you are using save it either, so you are left with a session state that represent page loading time.
    The addParam() method doesn’t save state. You should use the add() method, which do set session state. For example
    get.add(' P2_PRODFILTER',$v('P2_PRODFILTER'));This will save the session state for all your select lists. Of course, you will have to change the on-demand process accordingly.
    The second thing is to handle the shuttle value. You need to remember that for the APEX engine, a shuttle value is a colon-delimited string. You should generate this value in your on-demand process, and use the APEX_UTIL.SET_SESSION_STATE procedure to save it into session state. If you anticipate that this value will include options that don’t exist on your shuttle left side (left is relative, so let’s say your source column) you should set the LOV option of “Display Extra Values” to Yes.
    Regards,
    Arie.
    &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    &diams; Author of Oracle Application Express 3.2 – The Essentials and More

  • Popup Key LOV, NULL and "Invalid numeric value undefined for column"

    Hello.
    I've created an item based on database column of NUMBER type and set the following properties:
    Display As = Popup Key LOV (Displays description, returns key value)
    List of values definition=select 'display_value' d, 1 r from dual
    Null display value=%
    Null return value=
    Display Null=Yes
    When I select "%" in the LOV and try to apply changes to database I get error:
    ORA-20001: Error in DML: p_rowid=1781, p_alt_rowid=N1, p_rowid2=, p_alt_rowid2=. ORA-20001: Invalid numeric value undefined for column N2
    Error Unable to process row of table TTT.
    If I set Display As = Select List, all works fine. But I need Popup Key LOV.
    Could anybody help me?
    I use Application Express 2.2.1.00.04

    Hi all,
    I did my homework and solved this issue. First I would like to thank Patrick Wolf for the invaluable help he gives out on thread Re: Null value handling in LOVs The code presented here is just a minor edit to his code, but an essential one when dealing with Popup Key LOV items.
    Here's what I did:
    1. Create an Application Process.
    Name: RemoveNulls
    Sequence: 0
    Point: On Submit: After Page Submission - Before Computations and Validations
    Process Text:
    BEGIN
        FOR rItem IN
          ( SELECT ITEM_NAME
              FROM APEX_APPLICATION_PAGE_ITEMS
             WHERE APPLICATION_ID   = TO_NUMBER(:APP_ID)
               AND PAGE_ID          IN (TO_NUMBER(:APP_PAGE_ID), 0)
               AND LOV_DISPLAY_NULL = 'Yes'
               AND LOV_DEFINITION   IS NOT NULL
               AND LOV_NULL_VALUE   IS NULL
        LOOP
            IF (V(rItem.ITEM_NAME) = '%null' || '%' OR V(rItem.ITEM_NAME) = 'undefined')
            THEN
                Apex_Util.set_session_state(rItem.ITEM_NAME, NULL);
            END IF;
        END LOOP;
    END;Error Message: #SQLERRM#Condition: None
    2. You should be able to submit a Popup Key LOV with a NULL value now.
    Once again, THANKS, Patrick! You rock! I'm seriously thinking of trying ApexLib now :)
    Georger

  • Active Directory authentication works in apex 3.2 - fails in apex 4.0.2

    I'm attempting to implement an AD authentication function which works for many of our apex 3.2 based apps in a 4.0 based one (both versions of apex installed in 10.2.0.4 DB) and it fails with this error -
    h4. ORA-01400: cannot insert NULL into ("APEX_040000"."WWV_FLOW_USER_ACCESS_LOG2$"."SECURITY_GROUP_ID") ERR-10480 Unable to run authentication credential check function.
    h5. Location: f?p=128:101:3059364335985257&notification_msg=Invalid%20Login%20Credentials/BC024DDF77AEE643E81F807FB74C83E6/
    I'm having trouble researching this issue as all the links for OID/DBMS_LDAP documentation at oracle.com are broken on http://www.oracle.com/technetwork/documentation/oid-089101.html
    I've read similar threads in the forum but either did not clearly understand the prescribed suggestions or did not ascertain I was experiencing the same issue.
    I've tested the function in the apex 4.0/10.2.0.4 schema using SQL Developer and the function works fine at this level so I have to presume something fundamental changed in the way apex implements authentication.
    Any suggestions as to a cause/resolution? My AD authentication function code follows;
    create or replace
    FUNCTION        "STRAININTEREST_AUTH_AD" (
          p_username IN VARCHAR2,
          p_password IN VARCHAR2 )
        RETURN BOOLEAN
      IS
        l_ldap_user   VARCHAR2 (256);
        l_ldap_base   VARCHAR2 (256) := 'DC=domain,DC=org';
        l_ldap_server VARCHAR2 (256) := 'adhostname.domain.org';
        l_ldap_port   NUMBER         := 389;
        l_domain      VARCHAR2 (256) := 'domain.org';
        l_retval      PLS_INTEGER;
        l_session     DBMS_LDAP.SESSION;
        l_attrs       DBMS_LDAP.string_collection;
        l_message     DBMS_LDAP.MESSAGE;
        l_entry       DBMS_LDAP.MESSAGE;
        l_vals        DBMS_LDAP.string_collection;
        l_dn          VARCHAR2(256);
        l_attr_name   VARCHAR2(256);
        l_ber_elmt    DBMS_LDAP.ber_element;
        l_org_unit    VARCHAR2(256) :='CN=GRP-StrainInterestApex_Users,OU=Domain_Local,OU=Groups,DC=domain,DC=org';
        l_org_unit_test VARCHAR2(2) := 0;
        attr_index    PLS_INTEGER;
        entry_index   PLS_INTEGER;
      BEGIN
        l_ldap_user             := p_username || '@' || l_domain;
        l_session               := DBMS_LDAP.init (l_ldap_server, l_ldap_port);
        l_retval                := DBMS_LDAP.simple_bind_s (l_session, l_ldap_user, p_password);
        DBMS_LDAP.use_exception := TRUE;
        l_attrs (1)             := '*';
        l_retval                := DBMS_LDAP.search_s ( ld => l_session, base => l_ldap_base, scope => DBMS_LDAP.scope_subtree, filter => '(sAMAccountName='||p_username||')', attrs => l_attrs, attronly => 0, res => l_message );
        l_entry                 := DBMS_LDAP.first_entry ( ld => l_session, msg => l_message );
        l_dn                    := DBMS_LDAP.get_dn(l_session, l_entry);
        WHILE l_entry IS NOT NULL
        LOOP
          l_attr_name       := DBMS_LDAP.first_attribute(l_session,l_entry,l_ber_elmt);
          attr_index        := 1;
          WHILE l_attr_name IS NOT NULL
          LOOP
          BEGIN
            l_vals := DBMS_LDAP.get_values (l_session, l_entry,l_attr_name);
            exception
               when others then
                  null;
          END;
          if l_vals.COUNT > 0 then
            FOR i IN l_vals.FIRST..l_vals.LAST
            LOOP
              IF l_attr_name = 'mail' THEN
                 APEX_UTIL.SET_SESSION_STATE('F111_USER_EMAIL',l_vals(i));
              END IF;
               --DBMS_OUTPUT.PUT_LINE('ATTR  IS: '||l_attr_name);
               --DBMS_OUTPUT.PUT_LINE('VALUE IS: '||l_vals(i));
              IF l_vals(i) = l_org_unit THEN
                l_org_unit_test := 1;
              END IF;
            END LOOP;
            end if;
            l_attr_name := DBMS_LDAP.next_attribute(l_session,l_entry,l_ber_elmt);
            attr_index  := attr_index+1;
          END LOOP;
          l_entry     := DBMS_LDAP.next_entry(l_session, l_entry);
          entry_index := entry_index+1;
        END LOOP;
        l_retval          := DBMS_LDAP.unbind_s (l_session);
        IF l_org_unit_test = 0 THEN
          RETURN FALSE;
        END IF;
        RETURN TRUE;
      EXCEPTION
      WHEN OTHERS THEN
        l_retval := DBMS_LDAP.unbind_s (l_session);
        RETURN FALSE;
      END STRAININTEREST_AUTH_AD;

    DOH. Too much copy/paste.
    In my code, I was setting an application variable to contain the email address I was retrieving from AD. Once commented out, it worked fine.
              IF l_attr_name = 'mail' THEN
                 APEX_UTIL.SET_SESSION_STATE('F111_USER_EMAIL',l_vals(i));
              END IF;

  • Global temporary table in PL/SQL called from APEX page

    I have a global temporary table in a PL/SQL procedure that is called from an APEX page.
    The global temp table is populated with data as the procedure runs and then at the end of the procedure I do a create_collection_from_query_b to populate a collection with the data from the temp table. (I do this b/c it is much faster than creating the collection and doing an add_member for each row.)
    The problem is that there are no commits in my procedure but I cannot get the bulk insert to work unless I define the temp table as on commit preserve rows.
    Can anyone shed any light on this issue.
    Thanks,
    Andrew

    alamantia wrote:
    My PL/SQL procedure is called from an after submit page process. Does that imply that there is a commit happening after that process is successful?Ultimately, yes.
    If the process calls the PL/SQL procedure and the temp table is in the procedure, wouldn't the commit fire after all the PL/SQL code is complete which would be after the bulk insert from the temp table to my collection?Yes, but at any point in the procedure containing code like
    :APEX_ITEM := ...or
    select ... into :APEX_ITEM from ...or
    my_procedure(p_in => ..., p_out => :APEX_ITEM, ...);or
    apex_util.set_session_state(...);then APEX will commit whilst maintaining session state.
    If you don't have any of these events in the procedure, then test to see if the commit is occurring in <tt>apex_collection.create_collection_from_query_b</tt> prior to creation of the collection.

Maybe you are looking for

  • Anyone got 5.1 surround working for games in OSX or Windows 7 on 2010 Mac P

    I got mine earlier this month have been trying out games in bootcamp on windows 7 they work really well with amazing graphics but no 5.1 sound in either OSX or W7, through the onboard sound card. Has anyone managed to to do this. I have only tried vi

  • How do I retrieve elements in a xml document ?

    I would like to know how to retrieve elements from xml document ? I have created a document already, but how do I proceed from there ? Also, how do I access the values inside, the attributes and value ? Thank you.

  • Design Mode black

    Hi, I have an application based on flash builder 3 with SDK 3.2. I try to import this application to Flash builder 4.6 with SDK 3.6, but in design mode, I have a black screen. Anyone have a solution for that ?

  • Can you walk me through how to download Adobe Flash

    I have a Mac Pro with Mountain Lion. I am unable to download adobe reader and the Flash Player. I need help

  • Epson stylus Pro 9600 problem printing?

    We have 3 Epson stylus pro 9600 connect to LAN network and the latest driver 8.6.1. We have Mac Pro with Lion installed 10.7.4. We tried to print the progress comes up and then it says error.  This is what we did to solve the problem:  1. we unplug t