Development notes, tips and tricks for Oracle's HTML DB

Tuesday, June 29, 2004

Update primary key with sequence number

To dynamically set a primary key column to a sequence number, add a page process that fires 'On Submit - After Computations and Validations' before the 'Process Row of [table]' process.
Use a PL/SQL statement that selects the sequence.nextval into the primary key column:

if :P3_EMPNO is null then
select ct_id_seq.nextval into :P3_EMPNO from dual;
end if;

Make sure to use the if statement. If you don't then you will encounter No-data-found errors.

Sunday, June 27, 2004

Pre-Update trigger

A trigger that functions similar to the pre-update trigger in Oracle forms is created by creating a page process that fires On Submit-Before validations and computations:

-- This example populates the country_code field from a database table
-- based on the value passed in from the state_code field.
BEGIN
IF :P1036_STATE_CODE IS NOT NULL AND :P1036_COUNTRY_CODE IS NULL THEN
select country_code
into :P1036_COUNTRY_CODE
from ct_state_code
where state_code = :P1036_STATE_CODE;
END IF;
END;

Change the case of a field to upper when a page is submitted:

Change the case of a field to upper when a page is submitted:
Create a page process: Processing > Processes
On Submit and Before Computation
Process: :P1036_STATE_CODE := UPPER(:P1036_STATE_CODE)

Create a hyperlink

Create a hyperlink to another page and pass values:

Create a region item as ‘Display as Text (does not save state)’
In the source put:
a href="f?p=&APP_ID.:1036:&SESSION.::::P1036_CT_ID:&P1032_CT_ID

Note that variables are preceded by an ampersand (&) and post ceded by a period (.).

HTMLDB Blog

I have created this blog for people to help with Oracle's (TM) HTMLDB database development tool.
I encourage people to submit ideas on how to solve development issues in order to share them with others.