Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: ORACLE WebServer V2.1 OWA_UTIL choose_date and Calendar fucntions
On Mon, 02 Jun 1997 08:59:05 -0500, Todd Alex Cohen <Todd.Cohen_at_CAPNCC01.ssw.abbott.com> wrote:
>Does anyone have evamples of how to code the Oracle Webserver V2.1
>CHOOSE_DATE and calendar PL/SQL procedures/functions? I have not been
>able to get them to work and the book is not much help.
>
>Thanks
>
>Todd
Here is a small example. The first routine will just display a form that allows you to pick a date. The date input 'widget' is really three pull down lists that hold days/months/ and years. The choose_date routine just creates the three input fields based on the DATE you pass into it (the second parameter, which i am passing sysdate below, is used to default the value of the date input field).
Since the date consists of three inputs, we are using a pl/sql table (an array) to pass them around as one variable. The routine that is the target of the form, show_the_date, takes one input - p_the_date. Since this is a pl/sql table, the first thing we do with it is put it in a real oracle date field, l_the_date. owa_util.empty_date is simply a NULL date we can use.
To see this example work, just run the 2 procedures in your DCD's schema. Then use the URL:
http://yourHost/DCDName/owa/show_the_date
You'll get the form and when you submit, you'll see the date and get to pick another....
create or replace procedure pick_a_date
as
begin
htp.formOpen( 'show_the_date' );
htp.p( 'Please pick a date...' || htf.br ); owa_util.choose_date( 'p_the_date', SYSDATE );
htp.br; htp.formSubmit; htp.formReset;
create or replace procedure show_the_date ( p_the_date in owa_util.datetype default owa_util.empty_date ) as
l_the_date date default owa_util.todate( p_the_date ); begin
if ( l_the_date is not null ) then
htp.bold( 'You picked ' || l_the_date ); htp.br;
For the calendar example:
create or replace procedure owaext_demo_cal
( p_data in varchar2 default NULL )
is
begin
-- if ( p_data is not null ) then htp.tableOpen( 'Border' ); owa_util.cellsprint( owa_util.bind_variables( 'select * from all_users where user_id = :x', ':x', p_data ) ); htp.tableClose; end if; -- -- owa_util.calendarprint( 'select created, username, ''owaext_demo_cal?p_data=''||user_id from all_users order by created' ); -- end; Use the URL http://yourHost/DCDName/owa/owaext_demo_cal to try it out. The calendarprint, shown in its simplest form above, will use the all_users table to display a calendar of when the users in your database were created. You can then click on one of the users and it'll call the same routine but this time display all of the information about that user and the calender as well. The call to cellsprint shows you how to use the owa_util.bind_variables call to get an open cursor as well. Just as you can pass the output of owa_util.bind_variables to owa_util.cellsprint, you can pass owa_util.bind_variables to owa_util.calendarprint (you can use parameterized queries to calendarprint is the point)... Anyway the MOST IMPORTANT THING to note about the calendarprint routine is that you MUST order by the date field and you are selecting out in order: column1 = The Date field column2 = The text to show on that date column3 = The thing to link to when you click on the text (OR NULL if nothing to link to) BTW: if you install the samples (found in $ORACLE_HOME/ows21/sample/owa) you'll get the above.... Also, if you goto http://govt.us.oracle.com/ and follow the link to downloadable utilities you'll see a thing called the OWA Extensions. These were the original routines that got included in the OWS2.1. There is online doc there and demos online. Try em out. They renamed some of the functions (i called it select_date, they called it choose_date; I called it cells_from_qyery, they called it cellsprint) but they are implemented exactly the same. Thomas Kyte tkyte_at_us.oracle.com Oracle Government Bethesda MD http://govt.us.oracle.com/ -- downloadable utilities ---------------------------------------------------------------------------- Opinions are mine and do not necessarily reflect those of Oracle CorporationReceived on Mon Jun 02 1997 - 00:00:00 CDT
![]() |
![]() |