Apex_util.prepare_url from PL/SQL (outside APEX)

Hello there,
I have to create a job that sends emails with a link to a page with SSP actived and that requires authentification.
I've read those threads from Dan and Omar and I wonder if this is still possible in APEX 4.2.1?
Re: apex_util.prepare_url outside of ApEx
Create APEX session context from outside APEX (plsql)
My procedure generate the link with the checksum, but when I try to access the page I got an error :
•is_internal_error: true
•apex_error_code: APEX.SESSION_STATE.SSP_VIOLATION2_FOR_DEVELOPERS
•error_backtrace: ----- PL/SQL Call Stack -----
  object      line  object
  handle    number  name
0x69e9c2e8       548  package body APEX_040200.WWV_FLOW_ERROR
0x69e9c2e8       599  package body APEX_040200.WWV_FLOW_ERROR
0x69e9c2e8       903  package body APEX_040200.WWV_FLOW_ERROR
0x6e5ff258      6025  package body APEX_040200.WWV_FLOW
0x73cbd318       249  procedure APEX_040200.F
0x6bdb2dd0        31  anonymous blockHere is my proc (code found in Omar's thread).
Maybe I'm missing something.
CREATE OR REPLACE procedure testInitApexFromOutside
      ( i_app_id     in number
      , i_page_id      in number
      , i_apex_user    in varchar2
      ) is
    v_cgivar_name  owa.vc_arr;
    v_cgivar_val   owa.vc_arr;
    v_workspace_id NUMBER;
    v_app_id       number;
      BEGIN
    -- set up cgi environment
    htp.init;
    v_cgivar_name(1) := 'REQUEST_PROTOCOL';
    v_cgivar_val(1)  := 'HTTP';
    owa.init_cgi_env
      ( num_params => v_cgivar_name.count
      , param_name => v_cgivar_name
      , param_val  => v_cgivar_val
    -- load apex IDs by application name
    SELECT workspace_id,
           application_id
    INTO v_workspace_id,
         v_app_id
    FROM apex_applications
    WHERE application_id=i_app_id;
    -- set up apex workspace
    wwv_flow_api.set_security_group_id(v_workspace_id);
    -- set up apex session vars
     apex_application.g_instance     := wwv_flow_custom_auth.get_next_session_id;
    apex_application.g_flow_id      := v_app_id;
    apex_application.g_flow_step_id := i_page_id;
    -- "login"
    apex_custom_auth.define_user_session
      ( p_user       => i_apex_user
      , p_session_id => apex_application.g_instance
    wwv_flow_custom_auth_std.post_login
      ( p_uname      => i_apex_user
      , p_session_id => apex_application.g_instance
      , p_flow_page  => apex_application.g_flow_id
                     || ':'
                     || apex_application.g_flow_step_id
      -- set array of protected page IDs for session state protection
     apex_application.g_protected_page_ids(1) := '1500';    -- this establishes page 1500 as an SSP-protected page
    dbms_output.put_line(APEX_UTIL.PREPARE_URL('f?p='||i_app_id||':'||i_page_id||':::NO:1500:P1500_PEV_SEQ_NO:18137',2));
end testInitApexFromOutside;And the result:
f?p=128:1500:::NO:1500:P1500_PEV_SEQ_NO:18137&cs=3B3D5905A7DDBCB5520E8F88885169CAC
Thanks for your help,
Lucien

See Re: Link in report ?
Maarten

Similar Messages

  • Apex_util.get_print_Document not working outside apex environment

    I am working on one of the assignment in Apex 4.0.2 .
    The requirement is to dynamically generate reports and mail to User using the Scheduler program(Pl/sql) -> dbms_scheduler.
    I have used BI publisher to create the template and xml data for the report(Excel) and used Apex_util.get_print_Document
    in the scheduler program (which is written outside Apex), but this is not working properly,sends blank report to email.
    Please suggest how to set the apex session and use Apex_util.get_print_Document to work properly outside apex env.

    Apex (PL/SQL web-enabled) code needs to execute inside an Oracle server session that has been properly and correctly initialised for executing web enabled PL/SQL code.
    An example of how to execute such PL/SQL by intialising a proper environment, is shown in {message:id=2251131}.
    Note that this will not be able to execute Apex pages (via the flow engine) that are not public - that needs a proper authenticated Apex web session. Which could be a tad complex to emulate in this fashion.

  • Apex_util.prepare_url

    Hi
    I have this sql, and need to add cs to the url... someone there know how I use apex_util.prepare_url() in a sql statement?
    My sql statment:
    http://vels.dk/tmp/sql.jpg
    (I have tryed to pass the code here, but it is not showed correct)

    See Re: Link in report ?
    Maarten

  • Apex_Util.Prepare_URL  Question due to Apex Util Advisor msg

    Hi,
    I have the following code in an SQL statement within an IRR:
    APEX_UTIL.PREPARE_URL( p_url => 'f?p=' || v('APP_ID') || ':398:'||v('APP_SESSION')||'::NO:398:P398_IDOBJ:||VIMG_SEARCH.IDOBJ:', p_checksum_type => 'SESSION') FullImg,
    And it works as expected. However when i run the Apex Util Advisor I get the following:
    Attribute     Region Source (Identifies the source of the region, reference Region Source Type)
    Check     V Function used in SQL Statements
    Category     Performance
    Message     Contains V/NV/DV function call in SQL statement (can be a performance problem).
    Do I need to worry about this ? or should I change the syntaxt within the APEX_UTIL.PREPARE_URL parameters ?
    Thank you
    Daniel

    In SQL (and PL/SQL blocks within APEX) the bind variable notation should be used:
    APEX_UTIL.PREPARE_URL( p_url => 'f?p=' || :APP_ID || ':398:'||:APP_SESSION||'::NO:398:P398_IDOBJ:||VIMG_SEARCH.IDOBJ:', p_checksum_type => 'SESSION') FullImg,The <tt>v(...)</tt> notation is for use in database PL/SQL program units called from APEX.

  • Apex_util.prepare_url within a select statement

    APEX Version: 3.1.2.00.02
    Need help with embedding APEX_UTIL.PREPARE_URL in select statement. Unable to reference column name as a bind variable...or it allows as in code below, but no values are included in the URL. Using PREPARE_URL so checksum is created.
    URL created:*
    https://.../f?p=108:90:623968923157010::NO::P90_RID:&cs=3CB12F3B467B3989B51377487817BDB08
    Note: href >> replaced with >> hrf
    declare
       q           varchar2(32767);      -- query
       w           varchar2(4000) ;      -- where clause
       we          varchar2(1) := 'N';  -- identifies if where clause exists
    begin
       q :=  'select "RID", '||
             '       "EMPLOYEE_NO", '||
             '       InitCap(first_name)||
             '||''' '''||
             '||InitCap(last_name) as "Name", '||
             '       "HIRE_DATE", '||
             '       "JOB_TITLE", '||
             '       CASE '||
             '          WHEN CORRECTION_IND = 'X' '||
             '             THEN ''<a hrf="' ||
    apex_util.prepare_url('f?p='||:APP_ID||':90:'||:APP_SESSION||'::'||:DEBUG||'::P90_RID:'||:RID) ||
             '">Correction</a>'' '  ||
             '          ELSE    NULL '||  
             '       END CORRECTED '||
             '  from "#OWNER#"."EMPLOYEE_TABLE" ';
       if :P28_FIRST_NAME IS NOT NULL
          then
             w := w || ' AND first_name LIKE UPPER(:P28_FIRST_NAME||'||'''%''' ||')' ;
             we := 'Y';
       end if;
       if :P28_LAST_NAME IS NOT NULL
          then
             w := w || ' AND last_name LIKE UPPER(:P28_LAST_NAME||'||'''%''' ||')' ;
             we := 'Y';
       end if;
       if we = 'Y'
          then q := q || w;
       end if;
    return q;
    end;Edited by: JSandoval on May 25, 2011 1:03 PM

    I think that the problem is that the function apex_util.prepare_url is executed building the "q" variable, not during query execution. (you have to try to quote it ...)
    I often use the "Query from function".
    There a couple of things that helps me:
    - I always put in the page an item PXX_SHOW_SQL(checkbox) visible only to administrator (a user setting in my application...).
    Before the "return q" put a htp.p(q) if this Item is not null. So you can see the actual SQL (often helps reformattig the output with SqlDeveloper)
    - I'm became crasy tring to quote complex query ... Now I write the query code in a TABLE
    Example AUXSQL(APP_ID number,APP_PAGE number, PRG number, sql VARCHAR2(4000))
    More "PRG" if more than 4000 chars. (I start in this way, but someone use CBLOB ...)
    I find this very usefully!!
    Thanks
    Stefano Corradi

  • Redirect to URL from PL/SQL

    Hi,
    I'm trying to redirect to a url from an Application Process using
    DECLARE
    l_url varchar2(2000);
    BEGIN
    select APEX_UTIL.PREPARE_URL('f?p=&APP_ID.:10:&SESSION.:DELETELINE:&DEBUG.:RP:P10_ORID,P10_ORDID:&P10_ORID.,&PP10_CCODE.') into l_url from dual;
    htp.init();
    owa_util.redirect_url(l_url, true);
    END;The above process is called with javascirpt using ajax. This successfully deletes the item i want but first it returns this error
    (<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> and second it doesn't refresh the page.
    I'm using prepare_url since Page Protection is enabled with Arguments Must Have Checksum.

    Solutions:
    i) Use the Javascript inside the Pl Sql .,
    sample Code:
    declare
    l_count number:=0;
    begin
    select count(*) into l_count from usermaster where usertypeid in
    ( select usertypeid from usermaster where usertypeid !=1 and Userid=:P9_USERID);
    if l_count > 0 then
    return true;
    else
    htp.p('<script language="javascript">');
    htp.p('window.location ="http://localhost:8080/apex/f?p=2234:8:&SESSION.::NO::"');
    htp.p('</script>');
    return false;
    end if;
    end
    that's all
    All the best...
    Udayakumar
    Edited by: 872464 on Sep 29, 2011 5:59 AM

  • APEX_UTIL.PREPARE_URL with checksum

    Hi all,
    sorry to bring up this topic up again.
    I was trying to do what was discussed in the following thread, but it just couldn't work for me.
    APEX_UTIL.PREPARE_URL 0- cecksum parameter
    The link in my email did not have the checksum parameter though i have run it over the APEX_UTIL.prepare_url function
    I verify this using the toad debugger.
    and I use the following sql to test as well
          select apex_util.prepare_url('f?p=137:99::5:NO:5:P5_REQUESTSEQ:2010100246',null,3) from dualit only return that string back without any checksum parameter.
    Am I doing this wrongly?
    Appreciate any input.
    Thanks.
    -Joel

    Hi Jari,
    Should i have session id because the link will be used by other people whom is the recipient of the email?
    I was following the steps in the other thread I mentioned.
           So if the link you want them to use is f?p=100:1:::NO:RP:P1_X,P1_Y:abc,def and your new public page is 2, send them this link instead:f?p=100:2::1:NO:RP:P1_X,P1_Y:abc,def.Without the SSP, the redirection and joining existing session are working. So I guess order of the parameter in the URL is correct.
    Thanks
    -Joel

  • Trouble getting  apex_util.prepare_url to produce checksum

    Session State Protection is enabled in both apps & Page attribute "Page access protection" is set to "Arguments Must have Checksum"
    Does not give checksum...
    http://apex.oracle.com/pls/apex/f?p=34780:3
    I even went into SSP and had it enabled for all page items and pages and still doesn't make a difference.
    Select 'x', APEX_UTIL.PREPARE_URL ('f?p='||:APP_ID || ':1::' || :APP_SESSION || '::::P1_EMPNO:' ) employee_link from dual;
    Different app Same Query... Provices checksum
    http://apex.oracle.com/pls/apex/f?p=39900:3
    Select 'x', APEX_UTIL.PREPARE_URL ('f?p='||:APP_ID || ':1::' || :APP_SESSION || '::::P1_EMPNO:' ) employee_link from dual;
    Any Ideas?
    Justin
    workspace:epic

    OK.. seems to me that:
    Justin Patterson wrote:
    Does not give checksum...
    http://apex.oracle.com/pls/apex/f?p=34780:3
    SSP Screenshot
    http://tinypic.com/r/k4fjvc/7
    This has no page 1, therefore no checksum would be generated ;).
    >
    Different app Same Query... Provices checksum
    http://apex.oracle.com/pls/apex/f?p=39900:3
    SSP Screenshot
    http://tinypic.com/r/5fnst2/7
    This has page 1, therefore checksum is generated.
    Also, the app_session is in the wrong place.
    Ta,
    Trent

  • Unable to Login into APEX after upgrade from ORACLE XE to APEX 3.2

    Hi,
    I have upgraded Oracle 10g XE to with apex_3.2 on the Windows XP.
    My ORACLE XE wa in folder "C:\ORACLE XE"
    And APEX 3.2 in folder "C:\Ver 3.2\APEX"
    Once you complete the standard install, i performd the following steps to complete
    the upgrade which i got on my previous post.
    Till normal installation i was able to login in Apex link and was able to run my application which was
    in oracle XE but the only problem was i was unable to see any images in "EDIT PAGE" but my application was running well.
    then i did following steps to get those images
    Connect to SQL*Plus as SYS
    @APEX_HOME/apex/apxldimg.sql APEX_HOME
    @APEX_HOME/apex/apxxepwd.sql password
    (where password is the password of the Application Express internal ADMIN account)
    I chanbged image directory as below
    FROM:
    create directory APEX_IMAGES as ‘&1/apex/images’ ;
    TO:
    create directory APEX_IMAGES as ‘c:\oraclexe\apex\images’ and also tried ‘c:\ver 3.2\apex\images’;
    Ran @apxldimg.sql
    @apxxepwd.sql password (where password is the password of the Application Express internal ADMIN account)
    Exit from the SQL*Plus session.
    Change directory to c:\oraclexe\apex\owa, open the README.TXT file and follow the instructions within to complete the installation
    But now i am unable to login into the page itself. It "showing Page Not Found"
    Please kindly help me how to run APEX now through link.
    Thanks in advance.
    Thanks & Regards
    Sanjay
    Edited by: user11204334 on Aug 11, 2009 2:05 AM
    Edited by: user11204334 on Aug 11, 2009 4:30 AM

    Hi John,
    Thanks for reply
    I got error while doing following steps in few procedures
    Change directory to c:\oraclexe\apex\owa, open the README.TXT file and follow the instructions within to complete the installation
    Before doing the above step i was able to login into my application but without images
    Can you please help that how to check those errors and any particular procedure you know which is responsible for the Login problem.
    Thanks a Lot for help John
    Thanks & Regards
    Sanjay

  • PDF report from PL/SQL

    Hi,
    I have a region built from PL/SQL(Anonymous Block). This report is one record with 90 fields formatted to display. Is there a way to do this so it opens in a pdf?
    I am using APEX 3.1 on Oracle 11g. We do not have BI, so I need to find another solution to doing this.
    Thanks
    Kevin

    You can do this with Apache FOP. You may also want to look at http://www.plpdf.com/.
    Mike

  • Hyperlink from PL SQL Report to a branch

    Hi,
    Is there a "good" way to hyperlink from PL SQL report to a branch?
    I cant use the regular report, as there is a lot of data and I need to control the layout.
    I would like to go to another page and pass data to one known field.
    Have tried googling and I found this page:
    http://www.lucidprocess.com/blog/building-hyperlinks-in-oracle-apex-reports/
    But it seems a bit "hacky", eg.. many places to edit if the page where to move or change in the future (or if one copies the page).
    Is there a more "clean" way to do this, or does one have to get his/her hands dirty for such a task?

    Thank you.
    I managed to write the other code too:
    "f?p='||:APP_ID||':686:'||:APP_SESSION||'::'||:DEBUG||'::P686_TBNR,P686_VIS_REGISTER:'||oppdrag.PE_TBNR_BET||'%2CHUSKNYTT"instead of firing the branch and using JS, I just set the two fields that change the logic and basis of the page. However as you see, the "flaw" with the code I wrote, is that if the fields or anything were to change, it will be harder to go in and edit reports that have this type of code.
    Have just started with APEX, but I must say I like it a lot..
    Just wish there where something inbetween the sql reports and the pl sql reports..
    The possibilities of the PL SQL Reports meeting the SQL Reports flexibility would be super.
    However, maybe it's good not everything is served on a plate, as this forces me to learn it more in depth. I also love challenges and I like making things properly :-)

  • APEX_UTIL.PREPARE_URL does not work across workspaces?

    We are running ApEx 4.1.1 on Oracle 11g.
    I am trying to call an application in another workspace and am using APEX_UTIL.PREPARE_URL in a hidden item and then a button with REDIRECT TO URL using javascript:popUp2 which uses the hidden item (the returned value of the PREPARE_URL. The code works fine if I am in the same workspace and a checksum is returned:
    APEX_UTIL.PREPARE_URL('f?p=9002:2:&SESSION.::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:&APP_ID.,&G_APP_NAME.&c=STU_WS','SESSION');
    returns:
    f?p=9002:2:1400894538262901::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:9001,FRD_MASTER_BANSECR&c=STU_WS&cs=3190FB9A8CC967E5B3CED03460DF6F291
    I can press the button and app 9002 opens in a new window.
    When I try the same code in an application in another workspace, no checksum is returned:
    APEX_UTIL.PREPARE_URL('f?p=9002:2:&SESSION.::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:&APP_ID.,&G_APP_NAME.&c=STU_WS','SESSION');
    returns:
    f?p=9002:2:8288147979401::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:112,Testing_Template&c=STU_WS
    and I get the error:
    Error     Session state protection violation: This may be caused by manual alteration of a URL containing a checksum or by using a link with an incorrect or missing checksum.
    I have also tried it without the workspace '&c=STU_WS' and explicitly passing the parameters, but no checksum is returned.
    APEX_UTIL.PREPARE_URL(p_url => 'f?p=9002:2:&SESSION.::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:&APP_ID.,&G_APP_NAME.',p_checksum_type => 'SESSION')
    If I do not try to pass any parameters, no checksum is produced, but the button successfully opens app 9002 in a new window:
    APEX_UTIL.PREPARE_URL('f?p=9002:4:&SESSION.::NO::&c=STU_WS','SESSION');
    returns:
    f?p=9002:4:8288147979401::NO:::&c=STU_WS
    Again, the above code successfully opens app 9002 in a new window. In fact, when not passing parameters to app 9002, I would not seem to need to use PREPARE_URL.
    BUT. I do need to pass the calling app id and the calling app name to app 9002, because 9002 looks up information about the calling app. Since, I must pass parameters, I must use PREPARE_URL, and it does not seem to work when you call it for an app in a different workspace.
    Given all of the above, I have found a kludge. I call PREPARE_URL using the APP_ID of the current app and then replace that APP_ID with 9002.
    replace(APEX_UTIL.PREPARE_URL('f?p=&APP_ID.:2:&SESSION.::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:&APP_ID.,&G_APP_NAME.&c=STU_WS','SESSION'),
    'f?p=&APP_ID.:2','f?p=9002:2')
    returns:
    f?p=9002:2:8288147979401::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:112,Testing_Template&c=STU_WS&cs=33B2BB2ECFE3555198CE3325CCF9F67B8
    And the button opens app 9002 just fine.
    Is there anyway to get PREPARE_URL to work with apps in another workspace? What am I missing? Is there a better way than the kludge I came up with?
    A little more information: my app 9002 is a help & info for ApEx DBAs and Developers. It is my attempt at code reuse. Calls to 9002 are in a master template. I can continually update and change the help in 9002 without having to update the apps that call it.
    Thanks for your help,
    Chris

    lewisc3 wrote:
    We are running ApEx 4.1.1 on Oracle 11g.
    I am trying to call an application in another workspace and am using APEX_UTIL.PREPARE_URL in a hidden item and then a button with REDIRECT TO URL using javascript:popUp2 which uses the hidden item (the returned value of the PREPARE_URL. The code works fine if I am in the same workspace and a checksum is returned:
    APEX_UTIL.PREPARE_URL('f?p=9002:2:&SESSION.::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:&APP_ID.,&G_APP_NAME.&c=STU_WS','SESSION');
    returns:
    f?p=9002:2:1400894538262901::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:9001,FRD_MASTER_BANSECR&c=STU_WS&cs=3190FB9A8CC967E5B3CED03460DF6F291
    I can press the button and app 9002 opens in a new window.
    When I try the same code in an application in another workspace, no checksum is returned:
    APEX_UTIL.PREPARE_URL('f?p=9002:2:&SESSION.::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:&APP_ID.,&G_APP_NAME.&c=STU_WS','SESSION');
    returns:
    f?p=9002:2:8288147979401::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:112,Testing_Template&c=STU_WS
    and I get the error:
    Error     Session state protection violation: This may be caused by manual alteration of a URL containing a checksum or by using a link with an incorrect or missing checksum.
    I have also tried it without the workspace '&c=STU_WS' and explicitly passing the parameters, but no checksum is returned.
    APEX_UTIL.PREPARE_URL(p_url => 'f?p=9002:2:&SESSION.::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:&APP_ID.,&G_APP_NAME.',p_checksum_type => 'SESSION')
    If I do not try to pass any parameters, no checksum is produced, but the button successfully opens app 9002 in a new window:
    APEX_UTIL.PREPARE_URL('f?p=9002:4:&SESSION.::NO::&c=STU_WS','SESSION');This is wrong because you are passing string SESSION for url_charset parameter, that's why id is not adding any checksum
    See this http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_util.htm#AEAPI160
    returns:
    f?p=9002:4:8288147979401::NO:::&c=STU_WS
    Again, the above code successfully opens app 9002 in a new window. In fact, when not passing parameters to app 9002, I would not seem to need to use PREPARE_URL.
    BUT. I do need to pass the calling app id and the calling app name to app 9002, because 9002 looks up information about the calling app. Since, I must pass parameters, I must use PREPARE_URL, and it does not seem to work when you call it for an app in a different workspace.
    Given all of the above, I have found a kludge. I call PREPARE_URL using the APP_ID of the current app and then replace that APP_ID with 9002.
    replace(APEX_UTIL.PREPARE_URL('f?p=&APP_ID.:2:&SESSION.::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:&APP_ID.,&G_APP_NAME.&c=STU_WS','SESSION'),
    'f?p=&APP_ID.:2','f?p=9002:2')
    returns:
    f?p=9002:2:8288147979401::NO::P2_CALLING_APP_ID,P2_CALLING_APP_NAME:112,Testing_Template&c=STU_WS&cs=33B2BB2ECFE3555198CE3325CCF9F67B8
    And the button opens app 9002 just fine.
    Is there anyway to get PREPARE_URL to work with apps in another workspace? What am I missing? Is there a better way than the kludge I came up with?
    A little more information: my app 9002 is a help & info for ApEx DBAs and Developers. It is my attempt at code reuse. Calls to 9002 are in a master template. I can continually update and change the help in 9002 without having to update the apps that call it.
    Review all above API calls and make sure you pass right parameters

  • 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

  • Export data into Excel from PL/SQL Block

    Hi,
    Please tell me how to export data into excel comming out from PL/SQL code in APEX.
    We can simply export data into excel if we have Report region, but my query is dynamic for which i had to use PL/SQL block. Now i want to export that data into excel.
    Thanks & Regards,
    Smith

    Hi,
    Take a look here http://spendolini.blogspot.com/2006/04/custom-export-to-csv.html
    Regards
    Paul

  • Joining 2 related records using PL SQL in Apex - Problems when there are more than 2 related records?

    Hi
    I am combining 2 related records of legacy data together that make up a marriage record.  I am doing this in APEX using a before header process using the following code below which works well when there are only 2 related records which joins the bride and groom record together on screen in apex.  I have appended a field called principle which is set to 'Y' for the groom and 'N' for the bride to this legacy data
    However there are lots of records where in some instances there are 3, 4 , 5, 6 or even 1 record which causes the PL/SQL in APEX to not return the correct data.  The difference in these related columns is that the name of the bride or groom could be different but it is the same person, its just that from the old system if a person had another name or was formally known as they would create another duplicate record for the marriage with the different name, but the book and entry number is the same as this is unique for each couple who get married.
    How can I adapt the script below so that if there are more than 2 records that match the entry and book values then it will display a message or is there a better possible work around?  Cleaning the data would be not an option as there are thousands of rows of where these occurrences occur
    declare 
         cursor c_mar_principle(b_entry in number, b_book in varchar2) 
         is 
              select DISTINCT  id, forename, surname, marriagedate, entry, book,  formername, principle
              from   MARRIAGES mar 
              where  mar.entry   = b_entry
              and    mar.book = b_book
              order by principle desc, id asc; 
         rec c_mar_principle%rowtype;
    begin 
    open c_mar_principle(:p16_entry,:p16_book)  ;
    fetch c_mar_principle into rec;
    :P16_SURNAME_GROOM   := rec.surname; 
    :P16_FORNAME_GROOM   := rec.forename;
                   :P16_ENTRY := rec.entry; 
                   :P16_BOOK :=rec.book;
    :P16_FORMERNAME :=rec.formername;
    :P16_MARRIAGEDATE :=rec.marriagedate;
    :P16_GROOMID  := rec.id;
    fetch c_mar_principle into rec;
    :P16_SURNAME_BRIDE   := rec.surname; 
    :P16_FORNAME_BRIDE   := rec.forename;
                   :P16_ENTRY := rec.entry; 
                   :P16_BOOK :=rec.book;
    :P16_FORMERNAME :=rec.formername;
    :P16_MARRIAGEDATE :=rec.marriagedate;
    :P16_BRIDEID  := rec.id;
    close c_mar_principle;
    end;

    rambo81 wrote:
    True but that answer is not really helping this situation either?
    It's indisputably true, which is more than can be said for the results of querying this data.
    The data is from an old legacy flat file database that has been exported into a relational database.
    It should have been normalized at the time it was imported.
    Without having to redesign the data model what options do I have in changing the PL/SQL to cater for multiple occurances
    In my professional opinion, none. The actual problem is the data model, so that's what should be changed.

Maybe you are looking for

  • Distortion Correction with Lookup Table

    Hello, I am trying to run an image through lookup tables in order to correct some distortion. I have two 2D lookup tables "LUTsXnew.raw" and "LUTsYnew.raw" which locate the new (x,y) coordinates that i want to move the pixel intensities from original

  • Photoshop 3.2 to photoshop

    I have photoshop album starter addition 3.2 that has expired..we were gone out of the country for a while and would like to transfer the pics on 3.2 to the newphotoshop album..how do i go about doing it..thanks..

  • Customize the requirements plan number

    Hi, where can I customize the requirements plan number. Thanks Dede

  • Web service throughput slow and clipping

    We've been seeing the slow web throughput performance that clips between 4 and 5 KB/s. We've tried upping the simultaneous connections from 500 to 1024. I've also read through the post at http://discussions.apple.com/thread.jspa?messageID=4468345&#44

  • CSCue57694 - netflow on 7.4 will not support 3rd party NMS e.g. solarwind

    Having netflow support on 7.4 was a great news....but is not usable. Is there any way to define a record template which corresponds to a v5 flow. Doing so, it would be possible to get flow information on existing flow collector such as Fluke NPM.