Home » Other » Client Tools » query o/p in html page (oracle 11g)
query o/p in html page [message #556065] Thu, 31 May 2012 01:50 Go to next message
vivek_rol
Messages: 65
Registered: February 2009
Member
is it possible to write sql query o/p in html page ?
Re: query o/p in html page [message #556066 is a reply to message #556065] Thu, 31 May 2012 02:01 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Yes, with HPT.PRN.

P.S. Here's an example I used in an Apex application. Apex itself created a page (which includes most HTML tags, from <head> to <body>) - I just created one region. If you are going to create the WHOLE page by yourself, you'll have to actually "print" it line by line.

OK, here you go, just for an illustration. It creates a table with 5 images in a row.
  procedure p_dg_ts_slike (par_ts_broj in number)
  is
    l_filename   varchar2(255) := 'TS' || par_ts_broj || '-';
    l_filename_i varchar2(255);                              
    l_postoji    boolean;
    l_flen       number;
    l_bsize      number;   
  begin
    htp.prn('<table border="0">');
    htp.prn('<tr>');

    for i in 1 .. g_maxnum_img loop

      l_filename_i := l_filename || to_char(i) ||'.jpg' ;
       
      utl_file.fgetattr(pkg_degis.g_slike, l_filename_i, l_postoji, l_flen, l_bsize);

      if l_postoji then
         htp.prn('<td align="center">');
         htp.prn('<style="width: 170px; height: 140px"> ' || 
                 '  <img id="slika' || i || '"' ||
                 '      src="http://<removed>/' || 
                        l_filename_i || '?rnd=' || abs(dbms_random.random) ||                 
                 '    " width="150" height="120" style="border:2px solid black" ' 
                 );
         htp.prn('</br>');
         htp.prn('</br>' || l_filename_i);

         htp.prn('</td>');      
         if mod(i, 5) = 0 then
            htp.prn('<tr>');
         end if;
      end if;
            
    end loop;
      
    htp.prn('</tr>');
    htp.prn('</table>');
           
  end p_dg_ts_slike;

The result looks like this:
<table border="0"><tr><td align="center"><style="width: 170px; height: 140px">   <img id="slika1"      src="http://<removed>/TS3032-1.jpg?rnd=2011247857    " width="150" height="120" style="border:2px solid black" </br></br>TS3032-1.jpg</td>
Yes, I know, it is unformatted, but that's what the page source looks like. Manually reformatted (and easier to read):
<table border="0">
  <tr>
    <td align="center">
	  <style="width: 170px; height: 140px">   
	    <img id="slika1" 
		     src="http://<removed>/TS3032-1.jpg?rnd=2011247857    " 
			 width="150" 
			 height="120" 
			 style="border:2px solid black" 
			 </br></br>TS3032-1.jpg
    </td>


Page looks like this (blurred):
/forum/fa/10199/0/

I hope you got the idea.

[Updated on: Thu, 31 May 2012 02:20]

Report message to a moderator

Re: query o/p in html page [message #556069 is a reply to message #556065] Thu, 31 May 2012 02:41 Go to previous messageGo to next message
Michel Cadot
Messages: 68637
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> SET MARKUP HTML ON
SQL&gt; select * from emp where rownum=1;
<br>
<p>
<table border='1' width='90%' align='center' summary='Script output'>
<tr>
<th scope="col">
EMPNO
</th>
<th scope="col">
ENAME
</th>
<th scope="col">
JOB
</th>
<th scope="col">
MGR
</th>
<th scope="col">
HIREDATE
</th>
<th scope="col">
SAL
</th>
<th scope="col">
COMM
</th>
<th scope="col">
DEPTNO
</th>
</tr>
<tr>
<td align="right">
      7369
</td>
<td>
SMITH
</td>
<td>
CLERK
</td>
<td align="right">
      7902
</td>
<td>
17/12/1980 00:00:00
</td>
<td align="right">
       800
</td>
<td align="right">
&nbsp;
</td>
<td align="right">
        20
</td>
</tr>
</table>
<p>
SQL&gt; SET MARKUP HTML OFF
<br>
SQL> 

SQL*PlusĀ® User's Guide and Reference
Chapter 7 Generating HTML Reports from SQL*Plus

Regards
Michel
Re: query o/p in html page [message #556073 is a reply to message #556069] Thu, 31 May 2012 02:57 Go to previous message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
/forum/fa/450/0/

I'm quite sure that this is what the OP asked for. (But your way is not as fancy as mine.)
Previous Topic: import of data from Excel file into table
Next Topic: our UNIX user in group "dba" but can't connect as SYS
Goto Forum:
  


Current Time: Tue Apr 16 17:20:24 CDT 2024