Output of OWA_UTIL.tableprint
Declare
V_Temp Boolean;
Begin
v_Temp := OWA_UTIL.tableprint( ctable => 'tbl_log', cattributes => 'BORDER=1', ntable_type => OWA_UTIL.pre_table);
I want to store the output of this function explained in above code in a variable (variable is in a procedure. I want to get this output in a variable coz i want to forward this output to a mail procedure, which will mail this data).
The output is: -
<PRE>
| Col1 | Col2 | Col3 |
| 2000 | 4000 | 5000 |
| 2000 | 4000 | 5000 |
</PRE>
I guess I'm showing my history. OWA_UTIL wasn't originally a sys object. It was just an "extra" package that you installed. In fact, for quite a while, we had a version of OWA_UTIL under SYS and the orginal version under our "PROD" schema. In fact, I did fix one small bug in the SYS version of OWA_UTIL. I guess that's why I'm not that afraid to change OWA_UTIL.
Have you tried something like this?
declare
lb_done BOOLEAN := Null;
i NUMBER := 0;
s_result VARCHAR2(2000);
begin
htp.htmlOpen();
htp.bodyOpen();
htp.tableOpen;
htp.tableRowOpen;
htp.tableData('jason was here');
htp.tableRowClose;
htp.tableClose;
htp.bodyClose();
htp.htmlClose();
lb_done := FALSE;
WHILE NOT lb_done LOOP
BEGIN
s_result := htp.get_line(irows => i);
common_func.display_output(TO_CHAR(i)||' : '||s_result);
IF (i = 0) OR (s_result IS NULL) THEN
lb_done := TRUE;
END IF;
EXCEPTION
WHEN OTHERS THEN
lb_done := TRUE;
common_func.display_output('SQLERRM : '||SQLERRM);
END;
END LOOP;
end;
Similar Messages
-
Owa_util.tablePrint
Hi,
How do I set the attributes for each table cell and row with the
owa_util.tablePrint() package/function.
Cheers> No Billy! At least not the sign of growing old because I'm just 25 ('82 born).
Geez.. you young pups... :-)
1982? Lemme see... Joan Jett & The Blackheart's "I Love Rock & Roll" was playing on the airwaves. Locally Dr. Hook's "Baby Makes Her Blue Jeans Talk" was one of the top songs of the year. And we rocked on the dance floor to Toni Basil's "Mickey". And we survived as we had the eye of the tiger.
The first CD's started to make their appearance. Scott Fahlman started the emoticons. Epcot opened.. (the best of the Disney parks IMO). We had the Comodore 64.
'82? A fine year. But then the 80's was a fine decade. The best music of any decade thus far. The best hairstyles too.
;-) -
Problem in the output when the table name is explicitly assigned.
hi
Am using a procedure to copy the information's in a table to a flat file. my aim is to achieve this copy function by assigning the table name from user explicitly.
this is the program:
create or replace procedure jk(table_name in varchar2) is
sel_table varchar2(30);
l_bool BOOLEAN;
irows INTEGER := 1;
buffer LONG;
f utl_file.file_type;
BEGIN
sel_table:='select * from '||table_name;
f := utl_file.fopen('SAMPLE','tablename.txt','W');
OWA.cgi_var_name (1) := 1;
OWA.cgi_var_val (1) := 1;
OWA.init_cgi_env (1, OWA.cgi_var_name, OWA.cgi_var_val);
HTP.adddefaulthtmlhdr (FALSE);
l_bool :=
OWA_UTIL.tableprint (ctable => sel_table,
cattributes => '',
ntable_type => OWA_UTIL.pre_table,
ccolumns => '*',
cclauses => '',
ccol_aliases => '',
nrow_min => 0,
nrow_max => 500
WHILE (irows != 0)
LOOP
buffer := HTP.get_line (irows);
utl_file.put_line(f,buffer);
/* do whatever you like with the contents of the buffer */
/* You may write to a file or simply print it out */
DBMS_OUTPUT.put_line (buffer);
END LOOP;
END;
the error during execution:
SQL> @for.sql
Procedure created.
SQL> exec jk('CUST');
BEGIN jk('CUST'); END;
ERROR at line 1:
ORA-00931: missing identifier
ORA-06512: at "SYS.DBMS_UTILITY", line 125
ORA-06512: at line 2
ORA-06512: at "SYS.DBMS_SYS_SQL", line 1120
ORA-06512: at "SYS.DBMS_SQL", line 323
ORA-06512: at "SYS.OWA_UTIL", line 595
ORA-06512: at "SYS.OWA_UTIL", line 689
ORA-06512: at "SYS.OWA_UTIL", line 1222
ORA-06512: at "XMLUSER.JK", line 14
ORA-06512: at line 1
thanks in advance
karthik.JYou better don't supply the whole select statement to OWA_UTIL.tableprint but only the table name!
-
Displaying table using DBMS_OUTPUT using OWA
Dear All,
I have created a procedure to display a table in DBMS_OUTPUT (Thanks to Michaels) using OWA package.
PROCEDURE showtable (tablename VARCHAR2)
AS
b BOOLEAN;
OUT CLOB;
irows INTEGER := 1;
BEGIN
OWA.cgi_var_name (1) := 1;
OWA.init_cgi_env (OWA.cgi_var_name);
HTP.adddefaulthtmlhdr (FALSE);
b :=
OWA_UTIL.tableprint (ctable => tablename,
cattributes => 'border=1',
ntable_type => OWA_UTIL.pre_table
WHILE irows > 0
LOOP
OUT := OWA.get_line (irows);
IF RTRIM (OUT, CHR (10)) NOT IN ('<PRE>', '</PRE>')
THEN
DBMS_OUTPUT.put_line (OUT);
END IF;
END LOOP;
END;
This procedure displays proper tabular output.
But in few cases it shows tabular output along with <PRE> </PRE> tags.
Also in few cases it inserts unnecessary carriage returns in the output and therefore the rows in output gets misaligned.
Is this the problem with tool that displays output?
I have tested it with SQL * Plus, Toad, Oracle SQL Developer but it displays same output in each case.
Please help me in improving this procedure.
Thanks in advance.
-SameerYou can try this. It displays fine (in the spool file) even for very wide tables as long as the overall output size does not exceed 32767 (limitation of dbms_output):
SQL> declare
2 b boolean;
3 out clob;
4 irows integer := 1;
5 offset integer := 1;
6 amt integer := 255;
7 tablename varchar2 (40) := 'flows_030000.wwv_flows';
8 i integer := 1;
9 begin
10 owa.cgi_var_name (1) := 1;
11 owa.init_cgi_env (owa.cgi_var_name);
12 htp.adddefaulthtmlhdr (false);
13 b := owa_util.tableprint (ctable => tablename,
14 cattributes => 'border=1',
15 ntable_type => owa_util.pre_table,
16 nrow_max => 3
17 );
18
19 while irows > 0
20 loop
21 out := out || replace (replace (owa.get_line (irows), '<PRE>' || chr (10)), '</PRE>' || chr (10));
22 end loop;
23
24 while dbms_lob.substr (out, amt, offset) is not null
25 loop
26 dbms_output.put (dbms_lob.substr (out, amt, offset));
27 offset := offset + amt;
28 end loop;
29
30 dbms_output.new_line;
31 end;
32 /
| ID | SECURITY_GROUP_ID | GLOBAL_ID | ALIAS | DISPLAY_ID | OWNER | NAME | DEFAULT_PAGE_TEMPLATE | HOME_LINK | BOX_WIDTH | WEBDB_LOGGING | PRINTER_FRIENDLY_TEMPLATE | DEFAULT_REGION_TEMPLATE | DEFAULT_LABEL_TEMPLATE | DEFAULT_REPORT_TEMPLATE | DEFAULT_LIST_TEMPLATE | DEFAULT_MENU_TEMPLATE | DEFAULT_BUTTON_TEMPLATE | DEFAULT_CALENDAR_TEMPLATE | ERROR_TEMPLATE | FLOW_LANGUAGE | FLOW_LANGUAGE_DERIVED_FROM | CHARSET | FLOW_IMAGE_PREFIX | AUTHENTICATION | LOGIN_URL | LOGOUT_URL | LOGO_IMAGE | LOGO_IMAGE_ATTRIBUTES | PUBLIC_URL_PREFIX | PUBLIC_USER | DBAUTH_URL_PREFIX | PROXY_SERVER | CUSTOM_AUTHENTICATION_PROCESS | CUSTOM_AUTHENTICATION_PAGE | CUSTOM_AUTH_LOGIN_URL | FLOW_VERSION | FLOW_STATUS | FLOW_UNAVAILABLE_TEXT | RESTRICT_TO_USER_LIST | APPLICATION_TAB_SET | EXACT_SUBSTITUTIONS_ONLY | CSV_ENCODING | BUILD_STATUS | VPD | SECURITY_SCHEME | REJOIN_EXISTING_SESSIONS | CHECKSUM_SALT | CHECKSUM_SALT_LAST_RESET | SUBSTITUTION_STRING_01 | SUBSTITUTION_VALUE_01 | SUBSTITUTION_STRING_02 | SUBSTITUTION_VALUE_02 | SUBSTITUTION_STRING_03 | SUBSTITUTION_VALUE_03 | SUBSTITUTION_STRING_04 | SUBSTITUTION_VALUE_04 | SUBSTITUTION_STRING_05 | SUBSTITUTION_VALUE_05 | SUBSTITUTION_STRING_06 | SUBSTITUTION_VALUE_06 | SUBSTITUTION_STRING_07 | SUBSTITUTION_VALUE_07 | SUBSTITUTION_STRING_08 | SUBSTITUTION_VALUE_08 | SUBSTITUTION_STRING_09 | SUBSTITUTION_VALUE_09 | SUBSTITUTION_STRING_10 | SUBSTITUTION_VALUE_10 | SUBSTITUTION_STRING_11 | SUBSTITUTION_VALUE_11 | SUBSTITUTION_STRING_12 | SUBSTITUTION_VALUE_12 | SUBSTITUTION_STRING_13 | SUBSTITUTION_VALUE_13 | SUBSTITUTION_STRING_14 | SUBSTITUTION_VALUE_14 | SUBSTITUTION_STRING_15 | SUBSTITUTION_VALUE_15 | SUBSTITUTION_STRING_16 | SUBSTITUTION_VALUE_16 | SUBSTITUTION_STRING_17 | SUBSTITUTION_VALUE_17 | SUBSTITUTION_STRING_18 | SUBSTITUTION_VALUE_18 | SUBSTITUTION_STRING_19 | SUBSTITUTION_VALUE_19 | SUBSTITUTION_STRING_20 | SUBSTITUTION_VALUE_20 | LAST_UPDATED_BY | LAST_UPDATED_ON | DEFAULT_CHART_TEMPLATE | DEFAULT_REPORTR_TEMPLATE | DEFAULT_FORM_TEMPLATE | DEFAULT_WIZARD_TEMPLATE | DEFAULT_TABFORM_TEMPLATE | DEFAULT_MENUR_TEMPLATE | DEFAULT_LISTR_TEMPLATE | THEME_ID | GLOBAL_NOTIFICATION | PAGE_PROTECTION_ENABLED_Y_N |
| 4411 | 10 | 26203551107945 | 4411 | 4411 | FLOWS_030000 | APEX - System Messages | 36912332266496846 | f?p=4411:1:&SESSION. | 98% | YES | 36911425616496846 | 36915002366496846 | 36912920899496846 | | 36916121240496847 | 36916209479496847 | | | 36911425616496846 | en-us | BROWSER | utf-8 | /i/ | COOKIE | | | | | | APEX_PUBLIC_USER | | | | | | &PRODUCT_NAME. 3.0.1.00.07 | AVAILABLE_W_EDIT_LINK | This application is currently unavailable. | | 1 | Y | | RUN_AND_BUILD | | | N | | 18-AUG-07 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 18-AUG-07 | | | | | | | | 101 | | |
| 4000 | 10 | 26616754121304 | BUILDER | 4000 | FLOWS_030000 | APEX - Application Builder | 3181227431044578 | f?p=4000:1:&SESSION. | 98% | YES | 7403029749876837 | 344742548 | 93372822814585113 | 6600628282501516 | 35066701739635046 | 13734421012904391 | 18498019930416612 | | 7403029749876837 | en-us | BROWSER | utf-8 | /i/ | CUSTOM2 | | wwv_flow_custom_auth_std.logout?p_this_flow=&FLOW_ID.&p_next_flow_page_sess=4550:8:&SESSION. | #IMAGE_PREFIX#htmldb/apex_logo.gif | width="300" height="30" alt="&PRODUCT_NAME." | | APEX_PUBLIC_USER | | | .60856310633085148. | | | &PRODUCT_NAME. 3.0.1.00.07 | AVAILABLE_W_EDIT_LINK | This application is currently unavailable at this time. | | 1 | N | Y | RUN_AND_BUILD | | FLOW: EDIT | | | 18-AUG-07 | LOGOUT | Logout | PRODUCT_NAME | Application Express | MSG_COMPANY | Workspace: &COMPANY. | MSG_LANGUAGE | Language | MSG_COPYRIGHT | Copyright © 1999, 2007, Oracle. All rights reserved. | MSG_USER | User | MSG_JSCRIPT | You must run this product with JavaScript enabled. | MSG_TBL_SUMMARY | Page Layout Table | EDIT | Edit | DONE | Done | TOP | Top | CLOSE | Close | CONFIRM | Confirm | DATE_FORMAT | mm/dd/yyyy | LONG_DATE_FORMAT | fmDay, Month dd, yyyy | TIME_FORMAT | hh:mi:ss AM | DATE_TIME_FORMAT | mm/dd/yyyy hh:mi:ss AM | RETURN_TO_APP | Return to Application | DELETE_MSG | Would you like to perform this delete action? | PAGE | Page | | 18-AUG-07 | 61427218674569660 | 61427218674569660 | 61427218674569660 | 91980429263284255 | 61427218674569660 | | 61427218674569660 | 3 | | N |
| 4350 | 10 | 683611196230867 | HTMLDB_HOME | 4350 | FLOWS_030000 | APEX - Workspace Admin | 6322904659084760 | f?p=4500:1000:&SESSION. | 98% | YES | 6322904659084760 | 60932116232746047 | 107534131274292840 | 6659715068668103 | 77000120193659142 | | 153893729392735447 | | 6322904659084760 | en-us | BROWSER | utf-8 | /i/ | CUSTOM2 | development_service_home_login | wwv_flow_custom_auth_std.logout?p_this_flow=&FLOW_ID.&p_next_flow_page_sess=4550:8:&SESSION. | #IMAGE_PREFIX#htmldb/apex_logo.gif | width="300" height="30" alt="&PRODUCT_NAME." | | APEX_PUBLIC_USER | | | .60874129745270430. | | | &PRODUCT_NAME. 3.0.1.00.07 | AVAILABLE_W_EDIT_LINK | This application is currently unavailable. | | 1 | Y | Y | RUN_AND_BUILD | | | | | 18-AUG-07 | LOGOUT | Logout | PRODUCT_NAME | Application Express | MSG_COMPANY | Workspace: &COMPANY. | MSG_LANGUAGE | Language | MSG_COPYRIGHT | Copyright © 1999, 2007, Oracle. All rights reserved. | MSG_USER | User | MSG_JSCRIPT | You must run this product with JavaScript enabled. | MSG_TBL_SUMMARY | Page Layout Table | DONE | Done | TOP | Top | CLOSE | Close | EDIT | Edit | DATE_FORMAT | mm/dd/yyyy | LONG_DATE_FORMAT | fmDay, Month dd, yyyy | TIME_FORMAT | hh:mi:ss AM | DATE_TIME_FORMAT | mm/dd/yyyy hh:mi:ss AM | DELETE_MSG | Would you like to perform this delete action? | | | | | | | | 18-AUG-07 | | | | | | | | 3 | | N |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Sorry for the wide display, but thats what I wanted to demonstrate anyway ;-) -
This is my procedure through which i m sending an e-mail. In my e-mail i want to show formatted output from query.(?) I can show it in simple text but i want the output for the query to be formatted as the query result is formated in iSQLPlus.
In simple words instead of the message i want to send the query result which is formatted as iSqlPlus query output. Thankx in advance. Please provide a simple solution that iSqlPlus engine recieves my any given query and gives the formatted output for that query in the e-mail
Or suggest any implemented code for mailing the formatted query result through mail.
Thankx in advance
DECLARE
conn utl_smtp.connection;
v_log number;
BEGIN
conn := demo_mail.begin_mail(
sender => '<sender-email>',
recipients => '<recipient-email>',
subject => 'HTML E-mail Test',
mime_type => 'text/html');
</h1>
-- This method will be used for oracle error reporting');
demo_mail.write_text(
conn => conn,
message => '<h1>Hi! This is a <i>test msg</i>);
demo_mail.end_mail( conn => conn );
END;Justin:
There is a function where you submit a query and this function output is formatted table data, but problem is how to store that output of a function in a variable
Declare
V_Temp Boolean;
Begin
v_Temp := OWA_UTIL.tableprint( ctable => 'tbl_log', cattributes => 'BORDER=1', ntable_type => OWA_UTIL.pre_table);
I want to store the output of this function explained in above code in a variable (variable is in a procedure. I want to get this output in a variable coz i want to forward this output to a mail procedure, which will mail this data).
The output is: -
<PRE>
| Col1 | Col2 | Col3 |
| 2000 | 4000 | 5000 |
| 2000 | 4000 | 5000 |
</PRE> -
I am exporting a Report into the CSV file. The problem is I am having a column called NAME - which is having first name and last name with comma.
exp
Name
abc, xyz
aaa, bbb
Now when I do the export .... in the CSV file the above column is coming in 2 seperate columns instead of one column. I am using the following ....code
owa_util.mime_header('application/excel',FALSE );
htp.p('Content-Disposition: attachment; filename=Report Output.csv');
owa_util.http_header_close;
Just wondering what the other changes I have to make??
thanks,
deepakHi Deepak,
csv are "comma separated values" files, so your comma is splitting the data into two fields.
If it were me, I would use two fields anyway, but if you need a single field, you should enclose the entire string within quotes:
'"' || lastname || ',' || firstname || '"' NAMEThis may work with just this data in quotes - but you may have to put quotes around all string values (numbers and dates won't need quotes).
Andy -
Generate a text file using Portal
Hello Everyone,
I need to generate a flat text file from a portal screen. I have no idea as
to what is the best way to do this. I have a screen on which i will have a
push button which when pressed needs to run a procedure which generates a
text file.
I don't know whether this is possible also or not.
Any help in the matter would be great.
Thanks.Hi,
You can create a procedure like this.
create or replace procedure op1
as
begin
htp.init;
owa_util.mime_header('plain/text', false);
htp.p('Content-Disposition: attachment; filename='||'output.txt');
owa_util.http_header_close;
htp.p('My output is text...');
exception
when others then
null;
end;
This will direct the ouput to a file called output.txt.
Thanks,
Sharmila -
Assigning table name explicitly
is it possible to get the table name from the user instead of hard-coding it in the pl/sql block itself?
will it cause any dependency problems? if yes, then how should i proceed?
thanks in advance
karthik.JLet's introduce a bit simpler method for what you are trying to achieve. There are kind of built-in functions you may use. Consider:
SQL> SET serverout on
SQL> DECLARE
l_bool BOOLEAN;
irows INTEGER := 1;
buffer LONG;
BEGIN
OWA.cgi_var_name (1) := 1;
OWA.cgi_var_val (1) := 1;
OWA.init_cgi_env (1, OWA.cgi_var_name, OWA.cgi_var_val);
HTP.adddefaulthtmlhdr (FALSE);
l_bool :=
OWA_UTIL.tableprint (ctable => 'emp',
cattributes => '',
ntable_type => OWA_UTIL.pre_table,
ccolumns => '*',
cclauses => '',
ccol_aliases => '',
nrow_min => 0,
nrow_max => 500
WHILE (irows != 0)
LOOP
buffer := HTP.get_line (irows);
/* do whatever you like with the contents of the buffer */
/* You may write to a file or simply print it out */
DBMS_OUTPUT.put_line (buffer);
END LOOP;
END;
<PRE>
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
</PRE>
PL/SQL procedure successfully completed. -
Bold the words in excel..
Hello Guys..I have been here before with my questions and everyone helped me to get the solution.. !!
hope you can help me out this time too..thanks !!
I am exporting table data to an excel.. through pl/sql procedure ..using utl_file package. Now I have to bold the first row of that excel (column names).
Thanks !!A nice »trick« is also to generate simple HTML and store it with a XLS extension. Excel will open it according to the formats given in the html table.
An example to follow:
declare
bl boolean;
param_val owa.vc_arr;
thepage htp.htbuf_arr;
irows integer := 999999;
cl clob;
begin
param_val (1) := 1;
htp.adddefaulthtmlhdr (false);
owa.init_cgi_env (param_val);
bl :=
owa_util.tableprint (ctable => 'emp',
cattributes => null,
ntable_type => owa_util.html_table,
ccolumns => '*',
cclauses => null,
ccol_aliases => null,
nrow_min => 0,
nrow_max => 500);
htp.get_page (thepage, irows);
for i in 1 .. thepage.count
loop
cl := cl || thepage (i);
end loop;
dbms_xslprocessor.clob2file (cl, 'TEMP', 'emp.xls');
end;
/ -
How to download output from a PL/SQL Procedure
Hi all
I have set up a PL/SQL procedure that sets up the mime type etc.
to download the output but IE keeps telling me it can't get the
file. I think that it's something to do with the browser wanting
to just GET the file and getting extra stuff because the mime
header is being sent every time. Anyone managed to do this?
Code sample follows:
create or replace procedure x
is
begin
owa_util.mime_header('application/force-download',false,null);
htp.p('Content-Disposition: attachment;
filename="timeline.html"');
htp.p('Pragma: no-cache');
htp.p('Cache-Control: no-cache');
htp.p('Expires: Thu, 01 Jan 1970 12:00:00 GMT');
owa_util.http_header_close;
htp.p('<HTML>');
htp.p('<body>');
htp.p('Hello there man');
htp.p('</body>');
htp.p('</HTML>');
end;What version are you on?
Works fine for me on my 11g:
SQL> create or replace procedure testxml (clob_out out clob)
2 is
3 l_clob clob;
4 l_ctx dbms_xmlquery.ctxhandle;
5 begin
6 l_ctx := dbms_xmlquery.newcontext ('select * from dual');
7 l_clob := dbms_xmlquery.getxml (l_ctx);
8 clob_out := l_clob;
9 dbms_xmlquery.closecontext (l_ctx);
10 end testxml;
11 /
Procedure created.
SQL>
SQL> variable vout clob;
SQL>
SQL> exec testxml (:vout)
PL/SQL procedure successfully completed.
SQL>
SQL> print vout
VOUT
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DUMMY>X</DUMMY>
</ROW>
</ROWSET>But definitely you can optimize your proc a bit: Try
create or replace procedure testxml (clob_out in out nocopy clob)
is
l_ctx dbms_xmlquery.ctxhandle;
begin
l_ctx := dbms_xmlquery.newcontext ('select * from dual');
clob_out := dbms_xmlquery.getxml (l_ctx);
dbms_xmlquery.closecontext (l_ctx);
end testxml;
/ -
Error while setting Owa_Util.Mime_Header
Hi.....
I have to make code to download BLOB file from my custom table Oracle APEX.
I am setting MIME Header using the following statement.
owa_util.mime_header(nvl( v_mime,'application/octet'), FALSE );
htp.p('Content-type: ' || v_mime);
htp.p('Content-length: ' || v_length);
htp.p('Content-Disposition: attachment; filename="'||replace(replace(substr(v_file_name,instr(v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
owa_util.http_header_close;
I am using this code to download BLOB file from table.
But i am getting following error:
Error report:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "SYS.OWA_UTIL", line 354
ORA-06512: at "SYS.OWA_UTIL", line 413
ORA-06512: at line 10
06502. 00000 - "PL/SQL: numeric or value error%s"
Can anyone tell me how to come out of this error.
I am not able to understand this error.
Thanks in advance.
Edited by: user639262 on Sep 4, 2008 11:06 AMtward wrote:
I'm trying to use:
owa_util.mime_header('application/vnd.ms-excel', FALSE)
htp.p('Content-Disposition: filename="test.xls"');
owa_util.http_header_close;
htp.htmlopen;
htp.bodyopen;
htp.tableopen(cattributes=>'border="1" width="100%" align="CENTER"');
htp.tablerowopen;--(cattributes => 'align="LEFT", bgcolor="LIGHTGRAY"');
htp.tableheader(cattributes=>'width="10%"', cvalue => 'Header 1');
htp.tableheader(cattributes=>'width="15%"', cvalue => 'Header 2');
htp.tableheader(cattributes=>'width="20%"', cvalue => 'Header 3');
htp.tableheader(cattributes=>'width="10%"', cvalue => 'Header 4');
htp.tableheader(cattributes=>'width="20%"', cvalue => 'Header 5');
htp.tableheader(cattributes=>'width="25%"', cvalue => 'Header 6');
htp.tablerowclose;
htp.tableclose;
htp.bodyclose;
htp.htmlclose;
My understanding is that this will open the window to Open/Save/Cancel the output in Excel.....
But for some reason, it simply displays in a browser window.....
The first line in the windows is:
Content-type: application/vnd.ms-excel Content-Disposition: filename="test.xls"
followed by the HTML Table....
Why will it not open in Excel for me?Something is not getting recognized properly.
Try hard-coding the functionality you want into a static HTML document. Then work on using owa_util.mime_header or Like MichaelS suggested htp.p surrounded by any needed tags w/options to duplicate the working static document's functionality. -
Owa_util.mime_header not working like it should
I have written a PL/SQL procedure that functions as a report using htp and htf tags. I wish to give the user the option to display the report in MS Excel. In the procedure, I have the following line:
OWA_UTIL.MIME_HEADER('application/vnd.ms-excel');
This has worked fine for me on several previous occasions, but at this particular client all I get is an output of
Content-type: application/vnd.ms-excel
in the browser, without Excel being opened.
Is there a server/DB/Portal setting that may be restricting Portal from sending this report to Excel? I'm using portal 9.0.2.6.18 on a Sun/Unix platform.I've been struggling with this too. I've ceated a test procedure which includes:
htp.init;
owa_util.mime_header('application/excel');
htp.p('ID;ORACLE;N;E');
htp.p('line 1 col 1');
htp.p('line 1 col 2');
htp.p('line 1 col 1');
htp.p('line 2 col 2');
but when I open it in Excel I get:
"Error reading record 5"
Can anyone suggest what I'm doing wrong? -
Need to output data to TXT with static header and footer but multiple rows
Using APEX 4.0 and 11g - The only way I could find to get data out of APEX in TXT format was to use htp.prn. I load a cursor with the data and this works fine, the problem is that I need to have the file start with a string (*:P9_HEADER_STRING*) but it can only appear once in the output.
Is there a way to add the *:P9_HEADER_STRING* to the output in a single TXT file? or is there another way I should be doing this?
This is what I have now: The *:P9_HEADER_STRING* is in the loop which I know it can't be, but I can't figure out how to concatenate this string to the output from the loop. The rank() is being used because I can only send the selected number of records, ranked from highest. (I will have to do the same thing with a footer too, but that variable isn't in here yet)
begin
-- Set the MIME type
owa_util.mime_header( 'application/octet', FALSE );
-- Set the name of the file
htp.p('Content-Disposition: attachment; filename="cra_outgoing.txt"');
-- Close the HTTP Header
owa_util.http_header_close;
-- Loop through all rows in CLIENT_TABLE
for x in (select * from (select XREF_NBR
, TOT_AMT
, '' SPOUSE_INFO
, '' PHONES
, NAME
, SURNAME
, '' MARITAL_STATUS
, '' EMPLOYER_INFO
, GENDER
, '' CO_ADDRESS
, '' PREV_ADDRESS
, POSTAL_CODE
, ADDRESS1
, '' FILLER
, rank() over (order by tot_amt desc, rownum asc) rn
from client_table c where c.File_Seq_Nbr is NULL and c.xref_nbr in (select xref_nbr from ticket_table where to_char(ticket_issue_date, 'YYYY-MM-DD') between :P7_START_DATE and :P7_END_DATE))
where rn <= :P7_NUMBER_RECORDS)
loop
-- Print out a portion of a row,
-- separated by commas and ended by a CR
htp.prn( *:P9_HEADER_STRING* || '03' || lpad(X.XREF_NBR, 12) || lpad(x.TOT_FINE_AMT, 11, '0') || '0201'|| lpad(x.NAME, 30) || lpad(x.SPOUSE_INFO, 60) || '00000000000000000000'|| x.DATE_OF_BIRTH || '0000000000000000' || x.GENDER || x.MARITAL_STATUS || lpad(x.EMPLOYER_INFO, 60) || lpad(x.CO_ADDRESS, 102) || lpad(x.ADDRESS1, 30) || lpad(x.POSTAL_CODE, 9) || lpad(x.FILLER, 21) );
end loop;
-- Send an error code so that the
-- rest of the HTML does not render
htmldb_application.g_unrecoverable_error := true;
end;Yes, I've already done that, hence this part of the code I pasted above:
begin
-- Set the MIME type
owa_util.mime_header( 'application/octet', FALSE );
-- Set the name of the file
htp.p('Content-Disposition: attachment; filename="cra_outgoing.txt"');
-- Close the HTTP Header
owa_util.http_header_close;
-- Loop through all rows in CLIENT_TABLE
-- Send an error code so that the
-- rest of the HTML does not render
htmldb_application.g_unrecoverable_error := true;
end;
I've solved my problem by loading the cursor data into a variable (inside the loop) and concatenating the header info to it (outside the loop). This works when there are only a few records but as soon as I get to 32767 bytes it's throwing an error because of the size. So that's a different issue altogether. -
Error in outputting xml formatted data
Hello,
I'm trying to output xml formatted data using apex.
At about 70% into the formatted output I get this in the browser:
<descript>punct= & > < /,() &</descript>
</row>
- <row The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
Only one top level element is allowed in an XML document. Error processing resource 'http://apex.oracle.com/pls/otn/f?p=158...
<script language="JavaScript1.1" type="text/javascript">
-^
m">>
<DIVI have a 600 row table (dml below) with identical string in each row of the descript column. (I put in some special characters just to push it through the escape function for html. It is displaying the text correctly.)
The page has one report region (plsql below).
The page template is stripped down.
My local results are identical to the otn hosted workspace.
I did dump the table in xml format and displayed the dump file in browser without a problem, so I'm missing something in the code.
Thank you.
Albert
On OTN webspace, go to http://apex.oracle.com/pls/otn/f?p=15866:1:1291425545573680200:::::
plsql
declare
xdescript varchar2(4000);
begin
-- xml preface is in the page template
-- htp.p('<?xml version="1.0"?>');
htp.p('<rowset>');
begin
for item in
(select descript,cid from receipts order by cid)
loop
htp.p ('<row>');
xdescript := htf.escape_sc(item.descript);
htp.p('<cid>' || item.cid || '</cid>');
htp.p('<descript>'|| xdescript || '</descript>');
htp.p('</row>');
end loop;
end;
htp.p ('</rowset>');
end;
dml
CREATE TABLE "RECEIPTS"
( "CID" NUMBER,
"AMOUNT" NUMBER NOT NULL ENABLE,
"CLEARED" DATE,
"DESCRIPT" VARCHAR2(80),
"DATEENTERED" DATE DEFAULT SYSTIMESTAMP,
"CHECKNBR" NUMBER,
"CLEARSEQ" NUMBER DEFAULT 0,
CONSTRAINT "RECEIPTS_PK" PRIMARY KEY ("CID") ENABLE
CREATE SEQUENCE "RECEIPTS_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999
INCREMENT BY 1 START WITH 4319 CACHE 20 NOORDER NOCYCLE
CREATE OR REPLACE TRIGGER "BI_RECEIPTS"
BEFORE INSERT ON "RECEIPTS"
FOR EACH ROW
BEGIN
SELECT "RECEIPTS_SEQ".NEXTVAL INTO :NEW.CID FROM DUAL;
END;
ALTER TRIGGER "BI_RECEIPTS" ENABLE
/May be it helps you. I use SQL/XML and APEX Application Process to generate XML succesfully
Here is the result:
http://htmldb.oracle.com/pls/otn/f?p=9774:101:0:APPLICATION_PROCESS=RSSNEWEVENTS
and here is the Process Text source:
declare
a clob;
begin
owa_util.mime_header( ccontent_type => 'text/xml', bclose_header => TRUE, ccharset => 'utf-8');
htp.prn('<?xml version="1.0" encoding="UTF-8"?>');
select
XMLTYPE.getStringVal(
XMLElement("rss",
XMLAttributes('2.0' as version),
XMLElement("channel",
XMLConcat(
XMLElement("title",'iActiveLife - novinky'),
XMLElement("link",'http://www.iactivelife.cz/'),
XMLElement("description",'iActiveLife - Zajímavý ivot snadněji'),
XMLElement("language",'cs'),
XMLElement("pubdate",''),
XMLAgg(
XMLElement("item",
XMLConcat(
XMLElement("title",event_name),
XMLElement("link",'http://htmldb.oracle.com/pls/otn/f?p=' || v('APP_ID') || ':37:' || v('SESSION') || '::NO::P37_EVENT_ID:' || event_id),
XMLElement("description",'')
) into a
from (
select event_id,event_name,issue_date, last_update_order
from (
select events.event_id, events.event_name, events.issue_date, rank () over (order by events.issue_date desc) as last_update_order
from events
where exists ( select * from opportunities where events.event_id=opportunities.event_id and opportunities.user_id is not null)
order by events.issue_date desc)
where last_update_order<=10
htp.prn(a);
end; -
Output Mutiple Files Using htp.p
Hello,
I wish to output 3 CSV files from APEX I have the following code
Declare
S_FileName VarChar(20);
S_Counter Number;
begin
-- Set the File NAme
S_FileName :=To_char(sysdate,'yyyymmdd')||'Letters.CSV';
For S_Counter IN 1..4 LOOP
-- Set the MIME type
owa_util.mime_header( 'application/octet', FALSE );
-- Set the name of the file
htp.p('Content-Disposition: attachment; filename="'||S_FILENAME||S_Counter|| '"');
-- Close the HTTP Header
owa_util.http_header_close;
-- Loop through all rows in EMP
for x in (select MPAN_CORE,ACCOUNT_NO
from Categoriser.LTNA_LETTER_ONE_OUTPUT@link_to_dqmDevdb )
loop
-- Print out a portion of a row,
-- separated by commas and ended by a CR
htp.prn(x.MPAN_CORE ||','|| x.ACCOUNT_NO ||','||
x.MPAN_CORE || chr(13));
END LOOP;
END LOOP;
-- Send an error code so that the-- rest of the HTML does not render
htmldb_application.g_unrecoverable_error := true;
end;
At this stage i only want to output 3 files the content is not a issue
I it possible to do this with APEX?
Any help on this is greatly appreciated.
DavidI take it from the lack of response that this is not somthing that APEX can do?No, it's something that HTTP cannot do. Think about it: if it was possible for a server to send multiple files in response to an HTTP request, then it would be possible to break your computer very easily indeed.
aww well looks like i will need to find another way..You'd need something in the browser client-side, Java applet, Flash control etc...
Maybe you are looking for
-
1book 12" with dvd/cdRW won't recognize blank cds or dvds,
The model number is A1054, machine model powerbook 6.5. 12 inch G4 30 gig 1,2 GHZ 512 MB with DVD/CD-RW drive. This wil not recognize blank DVDs or CDs. It reads awhile and ther rejects them.The preferences are set up to ask what I want done to the d
-
Scratching sounds coming from hard disk.
For the past few weeks there has been a scracthing sound which is generally getting worse that sounds like its coming from the hard disk. It is under warranty in south east asia but I am currently studying in the UK and its not possible to take it ba
-
Can someone please give me the tech help phone number in the back of their MP3Players guide? I lost the guide almost a year ago and since well, no one can help me with my problem here and after sending 4 e-mails I haven't gotte one reply with any use
-
How can I get my creative cloud membership onto my new computer?
I have logged into my adobe ID but I am only offered to download the free trials, not the programs I purchased? all programs have six months until expiration
-
An error has occurred while attempting to load crystal report runtime 64
I am using Crystal Report 2008. Visual Studio 2008 Professional on a SQL Server 2005 X64 SP2 with .NET 3.5 SP1 beta framework This problem happens in X64 environment only. I tried everything I Can find in the web: 1) run the crredist2008_x64 and X86.