Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Where to put page redirect code when using htp.prn

mimi_jonesOct 14 2011
Apex 4.0 oracle 11g.

The user starts on page 7, chooses rows from a list and clicks a Run button which redirects them to page 10 which has a process (on load before header) using htp.prn to create a text file which the user then can save. The end of this process has apex_application.g_unrecoverable_error := true; because if it doesn't have this, the HTML gets put into the text file too.

Anyway, when the user is done saving this text file, to all appearances they are still on page 7 (since page 10 doesn't really load, just runs that process) but I want them to go to page 14 after saving, not stay on page 7. I can't figure out where to put the redirect. The branching on page 7 doesn't seem to get activated after they hit the save button of the popup file save window, page 10 never loads for a branch on that page to work and I tried to put

htp.init;
owa_util.redirect_url('f?p=&APP_ID.:14:&APP_SESSION.');

after the htp.prn call in but then the popup file download window doesn't come up at all and the user is immediately redirected to page 14.

This is the process - I've tried the redirect inside its own begin end; and it didn't make any difference. If I put it in a separate process, it never gets run because as soon as the htp.prn is done, all processing stops. Any ideas on how I can get this file created and then redirect user to page 14? Thanks!

begin
-- Set the MIME type
owa_util.mime_header( 'application/octet', FALSE );
-- Set the name of the file
htp.p('Content-Disposition: attachment; filename="this_file_add.txt"');
-- Close the HTTP Header
owa_util.http_header_close;
-- Loop through all rows in CLIENT_TABLE
for x in (select HEADER_TRANS_TYPE
, HEADER_FILLER
, TRANS_TYPE_CD
, SOURCE_DEPT_NBR
, DEST_DEPT_NBR
, ENV_TYPE
, FILE_SEQ_NBR
from TEMP_CRA_EXTRACT
)
loop
-- Print out rows
htp.prn(x.HEADER_TRANS_TYPE|| x.SOURCE_DEPT_NBR|| x.DEST_DEPT_NBR|| x.TRANS_DATE || x.ENV_TYPE || lpad(x.FILE_SEQ_NBR, 4, '0') || rpad(x.HEADER_FILLER, 48) || x.TRANS_TYPE_CD || rpad(x.XREF_NBR, 12) || chr(13) || chr(10) );
end loop;
-- Send an error code so that the rest of the HTML does not render
apex_application.g_unrecoverable_error := true;

htp.init;
owa_util.redirect_url('f?p=&APP_ID.:14:&APP_SESSION.');

end;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 11 2011
Added on Oct 14 2011
0 comments
2,375 views