Home » Developer & Programmer » Forms » 2 Questions
2 Questions [message #86197] Wed, 08 September 2004 03:14 Go to next message
Dean
Messages: 34
Registered: August 2000
Member
Hi,

Just two questions.

1.  In Forms i've created a save button, how do a create a trigger that displays an alert to confirm that the record has been saved, providing the record gets saved.

2.  I'm linking a website to Oracle so that bookings can be made online, Im also having a Forms end so that booking can be made using that (housed within a car garage).  Ive created sequences on the cust_id and the booking_id, this woks fine via the website bookings, each newly added customer is assigned a cust_id, and each booking is assigned a unique id. 

When im in Forms I want to attach each of these sequences to the related form i.e. so that when I add a new customer in Forms it automatically creates a unique cust_id.  Because at the moment I have to manually enter a cust_id in Forms when I create a new customer, and if I enter an id such as 8, and the sequence has given the id's 1-7 already, then when I manually enter 8, the sequence will come to give the next id (8), when another customer is created via the website end, and can't because it has already been created, thus causing an error because the sequence has been disrupted.  So I want to assign the sequences to the forms so that an ID is created automatically on creation of a new customer in Forms.

The sequences are as follows: -

AutoNumber for cust_id
----------------------

CREATE SEQUENCE CUSTOMER_SEQ
START WITH 0000001
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER trigno1_bir
BEFORE INSERT ON CUSTOMER
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
BEGIN
IF :NEW.CUST_ID IS NULL THEN
SELECT CUSTOMER_SEQ.NEXTVAL
INTO :NEW.CUST_ID
FROM DUAL;
END IF;
END;
/

AutoNumber for booking_id
-------------------------

CREATE SEQUENCE BOOKING_SEQ
START WITH 0000001
INCREMENT BY 1;

CREATE OR REPLACE TRIGGER trigno2_bir
BEFORE INSERT ON BOOKING
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
BEGIN
IF :NEW.BOOKING_ID IS NULL THEN
SELECT BOOKING_SEQ.NEXTVAL
INTO :NEW.BOOKING_ID
FROM DUAL;
END IF;
END;
/
Re: 2 Questions [message #86202 is a reply to message #86197] Fri, 10 September 2004 01:20 Go to previous message
Ani
Messages: 56
Registered: November 2000
Member
Hi Dean,
1. No triggers can be written on a button. Only thing that could be done s to select distinct 1 into n_count(declare this as number) from table_name for that condition whether records are inserted or not and give an alert message.
2. At the time of creating a new customer id, check for select max(seq_no) from table and then increment it.
Hope your questions are answered.

Pls revert back.

all the best.

regards
ani
Previous Topic: Order by non base table column in forms
Next Topic: Character Mode Report
Goto Forum:
  


Current Time: Sun May 19 09:36:16 CDT 2024