2010-11-15

How to check the pl/sql web output

If you use the pl/sql web toolkit sometimes you will want to check the web output that you are creating.
You can use a browse, but maybe you do not have a web server (with the pl/sql gateway) or the EPG configured, or you want to unit test inside PL/SQL or to see the result before pl/sql gateway mess with the http header.



To check it you would use the OWA.get_page procedure but running (in the sql environment) a web sender instruction like htp.p will raise an error (ORA-06502).
That is due that the Web environment needs to be initialized. Tools like TOAD, SQL Navigator, SQL Developer have a button to activate that environment/output, but if you need to do it yourself here is a sample code:


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;
BEGIN
li_version := OWA.initialize;

OWA.init_cgi_env (li_num, la_name_arr, la_value_arr);

HTP.p ('My output'); -- or call to a procedure that will generated HTP like calls
li_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;

2 comments:

  1. THANKS!!! IT WORKS!!!, but you have a little code error on line 14 is "li_irows" no "irows"

    Best regards
    Fede

    ReplyDelete

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