2010-11-16

How to check the pl/sql web output with cookies

In the previous post "How to check the pl/sql web output" I show how you can check the pl/sql web output in code with minimal initialization.
Today I will show how you can make a cookie emulation or put other CGI environment variables in the pl/sql "web environment" variables.

I will show how to do it with cookies because it's the most strange one.


DECLARE
la_thepage SYS.HTP.htbuf_arr;
li_irows INTEGER;
li_version INTEGER;
la_name_arr OWA.vc_arr;
la_value_arr OWA.vc_arr;
li_num PLS_INTEGER := 0;
lv_cookies VARCHAR2 (2000) := 'TESTE=Teste;COOKIE2=Value2';--if you have several cookies concatenate them with ';'
BEGIN
li_version := OWA.initialize;
OWA_COOKIE.init; -- so it will reload the cookies buffer

la_name_arr (1) := 'HTTP_COOKIE';
la_value_arr (1) := lv_cookies;
li_num := li_num +1;
--you could add more CGI environment variables in subsequent positions in the arrays

OWA.init_cgi_env (li_num, la_name_arr, la_value_arr);

my_program(); -- call to your program

irows := 99999999999;
OWA.get_page (thepage => la_thepage, irows => li_irows);

FOR i IN 1 .. li_irows
LOOP
DBMS_OUTPUT.put_line (la_thepage (i));
END LOOP;
END;
END;


And this is how you can check the cookie existence and value inside your program.

PROCEDURE my_program IS
(...)
lrec_cookie OWA_COOKIE.cookie
BEGIN
(...)
lrec_cookie := OWA_COOKIE.get ('TESTE');

IF lrec_cookie.num_vals > 0
THEN
HTP.p ('Cookie value:' || lrec_cookie.vals (1));
END IF;
(...)
END;

No comments:

Post a Comment

Os comentários são moderados.
The comments are moderated.