Eh?PEX Unofficial Tour
10 years ago
A place for Application Express tips and tricks
$('td[headers="MY_COLUMN"]').append('%');
$('td[headers^="MY_COLUMN"]').text(function(index,text){return text+'%'});
svn checkout file:///path/to/svn/project/ /path/to/project/dev/deployment --non-interactivesvn update /path/to/project/dev/deployment --non-interactive
htp.init procedure. During the process of tracing the problem, I attempted to use htp.init to suppress the headers from showing up when calling a particular procedure. Apparently this isn't how it works. The application server still amends header information to the response before it is sent.
CREATE OR REPLACE PACKAGE WEB_SCRAPER AS
FUNCTION HTTP_GET_PAGE(p_url in VARCHAR2) RETURN CLOB;
FUNCTION DOCUMENT_BODY(p_document in CLOB) RETURN CLOB;
FUNCTION HTTP_GET_PAGE_BODY(p_url in VARCHAR2) RETURN CLOB;
PROCEDURE PRINT_CLOB(p_content in CLOB);
END WEB_SCRAPER;
/
CREATE OR REPLACE PACKAGE BODY WEB_SCRAPER AS
FUNCTION HTTP_GET_PAGE(p_url in VARCHAR2) RETURN CLOB AS
/* Performs a simple HTTP GET request and returns the content */
l_request Utl_Http.req;
l_response Utl_Http.resp;
l_content_buffer VARCHAR2 (32767);
l_page CLOB;
BEGIN
DBMS_LOB.createtemporary(l_page, FALSE);
l_request := Utl_Http.begin_request (url => p_url, method => 'GET');
Utl_Http.set_header (r => l_request, NAME => 'User-Agent', VALUE => 'APEX-Scraper/0.1');
l_response := Utl_Http.get_response (r => l_request);
BEGIN
LOOP
UTL_HTTP.read_text(l_response, l_content_buffer, 32767);
DBMS_LOB.writeappend (l_page, LENGTH(l_content_buffer), l_content_buffer);
END LOOP;
EXCEPTION WHEN Utl_Http.end_of_body THEN
NULL;
END;
Utl_Http.end_response (r => l_response);
RETURN l_page;
END HTTP_GET_PAGE;
FUNCTION DOCUMENT_BODY(p_document in CLOB) RETURN CLOB AS
/* Return everything between the body tags */
BEGIN
RETURN REGEXP_REPLACE(p_document,'^.*<[[:space:]]*BODY[^>]*>(.*)<[[:space:]]*/[[:space:]]*BODY[[:space:]]*>.*$','\1',1,0,'imn');
END DOCUMENT_BODY;
FUNCTION HTTP_GET_PAGE_BODY(p_url in VARCHAR2) RETURN CLOB AS
/* Convienience function combining DOCUMENT_BODY and HTTP_GET_PAGE */
BEGIN
RETURN DOCUMENT_BODY(HTTP_GET_PAGE(p_url));
END HTTP_GET_PAGE_BODY;
PROCEDURE PRINT_CLOB(p_content in CLOB) AS
/* Use this instead of htp.p which only supports Varchar2 */
l_buffer_size Number := 8191; --Can't always use 32767. See bug #5896994
l_clob CLOB := p_content;
l_chunks Number;
l_cloblen Number;
BEGIN
l_cloblen := dbms_lob.getlength(l_clob);
l_chunks := floor(l_cloblen / l_buffer_size) + 1;
FOR i IN 0 .. l_chunks LOOP
htp.p(dbms_lob.substr(l_clob, l_buffer_size, (i * l_buffer_size) + 1));
END LOOP;
END PRINT_CLOB;
END WEB_SCRAPER;
/
owa_util.redirect_url('f?p='||:APP_ID||':XYZ:'||:APP_SESSION||'::'||:DEBUG||':::');
owa_util.http_header_close;
Where 'XYZ' is the page you desire to redirect to and the condition is the assertion fail state.v('PXYZ_VAR') := 'my message';. Then have an 'After Header' process on that destination page which displays the contents of the page variable if it's not null (use an 'item not null' condition to determine this). Here's the code that will give you a nice Apex style message...apex_application.g_print_success_message := :PXYZ_VAR;Simple as that!
:PXYZ_VAR := '';