Home » Developer & Programmer » Forms » AutoNumber
AutoNumber [message #82097] Tue, 22 April 2003 17:02 Go to next message
Dean
Messages: 34
Registered: August 2000
Member
hi,
i have created the sequence following sequence through SQL Plus to increment the customer ID, it works fine when a new customer is added via the SQL Plus interface, (which is what I want) but when i load up Oracle Forms, it does not work through Forms. Any ideas on how I can get an autonumber working through forms and SQL Plus?
CREATE SEQUENCE CUST_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 CUST_SEQ.NEXTVAL
INTO :NEW.CUST_ID
FROM DUAL;
END IF;
END;
/

im not getting an error message. When I enter the details for a new customer, it doesnt automatically create a unique custoemr ID, instead when i click on the customer ID text box, it produces the message FRM-40202: Field must be entered, and I have to type one in (but its not created via an autonumber)

The sollution is shown below, i understand the following :-

Change the class of the customer ID block item to TEXT_ITEM_DISPLAY_ONLY. If you are not building your form off of TEMPLATE.fmb then at least change the Navigable, Insert Allowed, Update Allowed, and Required property to FALSE.

Could you please explain in detail how I would do the following:-

Have the procedure called by the On-Insert trigger on the block return the customer_id, probably as an out parameter, after your insert the new record, and set :your_block.customer_id equal to it.

The on-insert trigger is on the data block right?
How would I call the procedure?

An explanation of how to do this or an example would be much appreciated, thanks.
Re: AutoNumber [message #82099 is a reply to message #82097] Tue, 22 April 2003 20:37 Go to previous messageGo to next message
Julie
Messages: 98
Registered: February 2002
Member
I don't even display the sequence on the canvas. The item exists on the block, but the canvas property of the item is set to null.
Create a pre-insert trigger on the block. Put the following code in it.

SELECT MySeq.NEXTVAL
INTO :MyBlock.MyItem
FROM DUAL;

Don't worry about calling it, it will be automatically called when you save a new record.
Re: AutoNumber [message #82111 is a reply to message #82097] Wed, 23 April 2003 09:47 Go to previous message
Frank
Messages: 7901
Registered: March 2000
Senior Member
See X-post
Previous Topic: Urgent.....
Next Topic: Delay a part of program
Goto Forum:
  


Current Time: Thu Mar 28 06:13:49 CDT 2024