Friday 12 April 2013

Placing Buttons in Oracle Forms 6i

Okay apologies for the delay but here I am with method to add buttons to your forms...

Above screen with form field but without buttons on it...

Simply click on new block and create the block but create it manually because you have to enter the buttons in this block.  Better if you name this block as 'BUTTONS'...
Simply click on the name of block and change it to 'BUTTONS' as shown above...
Design button as shown above, from tools menu shown at left of form...
Rename the button as per your requirement...
Okay now if simply selecting the button and pressing 'Ctrl+D' will duplicate the buttons...
Duplicate as many as you require...
After renaming them place them where ever you want on your form...
Right click on button and click on PL/SQL Editor which will give you below screen to enter the codes...

Now please note the coding for different buttons given below...

for INSERT Button:


DECLARE
A NUMBER;
BEGIN
GO_BLOCK('VENDOR');
CLEAR_BLOCK(NO_COMMIT);
SELECT NVL(MAX(VID),0) INTO A FROM TRAINING.VENDOR;
:VENDOR.VID:=(A+1);
GO_ITEM('VENDOR.VNAME');
END;

Let me explain to you the Insert Button coding above.
This is a body of the trigger which will be fired when you will click on the Insert button.  What button will execute is that it will go to the block named 'Vendor' and will clear the block for, if you have inserted anything by mistake or intentionally in the form fields.  Then it will execute the select statement of Oracle Database which will store highest number of Vendor Id into a (which is our variable to store number temporary so that we can perform additional calculations on that number) and then at next level it will put higher number + 1 into vid field automatically.  Every time when you save and make an addition to the record it will increase.  After inserting max number into vid field it will jump to vendor name.

for DELETE button:

GO_BLOCK('VENDOR');
DELETE_RECORD;

for SAVE Button:

COMMIT;

for EXIT Button:

GO_BLOCK('VENDOR');
CLEAR_BLOCK(NO_COMMIT);
EXIT_FORM;

for Query Button:

GO_BLOCK('VENDOR');
EXECUTE_QUERY;

for Clear Button:

GO_BLOCK('VENDOR');
CLEAR_BLOCK(NO_COMMIT);

I hope that you will do practice this method and will make yourself more and more efficient with this.

Please do contact me if you have any problems, and yes the next thing we will talk about is trigger which plays a great and important role in Oracle Database to automatically calculate things and make changes to data when you Insert, Delete or Update the records.

See you soon again for further training...

No comments:

Post a Comment