Re: populate a data block

From: Richard Spee <rhpspee_at_wxs.nl>
Date: Sat, 12 Oct 2002 13:23:19 +0200
Message-ID: <ao91bg$a4f$1_at_reader13.wxs.nl>


Martin,
[Quoted] There are a few mistakes in your example.

Whenever you enter 'query mode' (enter_query) you loose control of the application. The lines

    :data_block_name.date_val := :control_block_name.date_val;     EXECUTE QUERY; will be executed after the user presses EXECUTE_QUERY or CANCEL_QUERY (control is returned to the application)
The line

:data_block_name.date_val := :control_block_name.date_val;

is doing an update of the retrieved record or an insert (in case cancel_query is pressed) The EXECUTE QUERY will trigger the message "Do you want to commit the changes ......" or "field must be entered" depending on other fields in the block.

The simplest way to achieve a where condition is by setting the block property (look in the documentation at SET_BLOCK_PROPERTY (DEFAULT_WHERE)) or by using the PRE-QUERY trigger.
In the pre-query trigger you could have the following line:

:data_block_name.date_val := :control_block_name.date_val; -- simple, isn't it

Following stage could be using stored procedures or ref cursors. If i may give you an advice Timbo. Buy a book on building forms. As you can see there a many ways to skin a cat. The best way to learn, is by doing/experimenting.

"Martin Doherty" <martin.doherty_at_oracle.comX> wrote in message news:veLp9.8$GW4.282_at_news.oracle.com...
> To clarify a bit:
>
> I agree with Daniel's general advice but I think Timbo is just looking
> to query the existing rows from a table, using the control block date as
> the search criterion. So, Timbo if this is the case then you can ignore
> the bit about calling a stored procedure to populate a table.
>
> The technique to use is basically this:
> 1) user enters a date into the control block
> 2) a forms trigger (maybe WHEN-BUTTON-PRESSED on a 'Find' button) will
> navigate to the data block, put it into enter_query mode, copy the date
> value into the corresponding base table item of the data block, then
> execute_query.
> 3) Happy user is now looking at the rows that match the date entered.
>
> Maybe like this (not tested)...
>
> BEGIN
> GO_BLOCK('data_block_name');
> enter_query;
> :data_block_name.date_val := :control_block_name.date_val;
> EXECUTE QUERY;
> END;
>
> HTH
> Martin
>
> Daniel Morgan wrote:
>
> >Timbo wrote:
> >
> >
> >
> >>Daniel Morgan wrote:
> >>
> >>
> >>>Timbo wrote:
> >>>
> >>>
> >>>
> >>>
> >>>>Hi. New to Forms. Using 9i dev suite.
> >>>>
> >>>>I want to have a control block on a form where a user enters a date,
> >>>>and then run a query to populate the data block using the date
> >>>>entered from the control block as the WHERE value. The data in the
> >>>>data block is query only, the user will make a selection from the
> >>>>returned data to do something else.
> >>>>
> >>>>How do I make the control block entry populate the data block?
> >>>>
> >>>>Thanks,
> >>>>
> >>>>Tim
> >>>>
> >>>>
> >>>I try to keep as much code out of a form as possible. One simple way to
> >>>do this is to in the validation trigger call a stored procedure in the
> >>>database to populate the table. Then your code consists only of the
> >>>following:
> >>>
> >>>BEGIN
> >>> back_end_proc(:block_name.date_field);
> >>> GO_BLOCK('block_name');
> >>> EXECUTE QUERY;
> >>>END;
> >>>
> >>>Let the proc contain the INSERT INTO using the passed date value as a
> >>>parameter to the WHERE clause.
> >>>
> >>>Keeps the form leaner and faster.
> >>>
> >>>Daniel Morgan
> >>>
> >>>
> >>>
> >>Thanks for the tip.
> >>
> >>When I write the PL/SQL procedure and store it on the database,
> >>do I reference all the form methods the same way? Such as the
> >>set_block_property ?
> >>
> >>Tim
> >>
> >>
> >
> >Code in the back-end can never reference the form. Code in the form
> >references the backend. So use back-end code to load tables. Then just
> >refresh the form with EXECUTE_QUERY.
> >
> >Daniel Morgan
> >
> >
> >
>
Received on Sat Oct 12 2002 - 13:23:19 CEST

Original text of this message