Go Premium for a chance to win a PS4. Enter to Win


DEVELOPER 2000 LOV/Cursor_Trigger

Posted on 2000-04-18
Medium Priority
Last Modified: 2011-10-03
I have a customer order line which has
Line No
Style No

If the clerk - when entering in the ordered item details -  enters in a qty for the item that is higher than the qty
that exsists in the oracle stock_item table (called qty_on_hand) then a message appears saying 'There is not enough of this item in chosen colour.  Please chose another colour or lower qty'.  It then pops up with and LOV that has the avaiable colours for that styleno and size.


Line Style Colour Size Qty
No   No
1    DS204 Olive  12   8

But there is only 5 of this colour and size for that style so the message adn lov should be activated and stop the user being able to tab till it is correct:

My current post_change trigger code is:

      CURSOR      CUR_Qty_OH IS
            SELECT Qty_On_Hand
            FROM Stock_Item
            WHERE styleno    = :customer_order_line.styleno
            AND colour = :customer_order_line.colour
            AND sizes = :customer_order_line.sizes;

      dummy_Qty_OH            NUMBER;
      LOVColour_dummy            BOOLEAN;

            OPEN CUR_Qty_OH;
      END IF;
      FETCH CUR_Qty_OH INTO dummy_Qty_OH;
      IF :customer_order_line.quantity > dummy_Qty_OH THEN
            message ('There is not enough of this item in stock.  Please lower the quantity or pick another colour from the list');

            LOVColour_dummy := Show_LOV('LOVCOLOUR',15,10);
      END IF;

      CLOSE CUR_Qty_OH;      

And my LOV Code for the colour is

select colour from stock_item where :customer_order_line.styleno = stock_item.styleno and :customer_order_line.sizes = stock_item.sizes and qty_on_hand >= :quantity
Question by:Joana

Expert Comment

ID: 2729727
So what exactly is the question?  Are you saying that your code doesn't work?

If you are succesfully bringing up the lov, you could simply clear the field that was previously entered (qty) and do a go_item back to that field.

You can attach this to the buttons of the LOV or put it in a when-validate-item trigger.

I assume that you are already using a WVI trigger here that is running the above code.  If you clear the field and go_item back to it and then run your other code, this should ensure that a field must be entered.

Or am I missing something here?



Accepted Solution

prabhatmandal earned 200 total points
ID: 2730601
I am not getting the question fully. AS I feel...
You want to stop the user to go ahead without entering the field and the value entered shoule be validated against existing data.... right...

So in the key-next-item for the item, check for not null of the field. And in When-validate-item check the validity of the value entered.... And throught LOV always only valid values would come...

I hope I have made myself clear....
If still any query is there... Please write with clarification....

Expert Comment

ID: 2730650
I would question the suggestion of key next item if you are able to "tab-out" of the field using a method other than "tab" (e.g. using a mouse) though it does answer one aspect of your question if you are to be taken literally.

I would prefer to put that in a WVI trigger as well since the validation will be run whatever method is used to leave the field.

With respect to the NULL values, that is why I recommended you clear the record and sent the focus back to that item...as it will fail if they try to exit, witht he appropriate message.


LVL 35

Expert Comment

by:Mark Geerlings
ID: 2736807
A post-change trigger is not the best way to do this (unless you are still working on a Forms2.3 or 3.0 system).  Use a when-validate-item trigger instead (Forms4.0 through Forms6.0) to check the quantity.  This will fire only and exactly at the time you need it to.  A post-change trigger will also fire at query time, and that is wasted processing in this case.  Using a key-next-item trigger is dangerous because there are too many other ways the user can move the cursor out of the item and avoid that trigger.

You would be better off (from a performance and reusability perspective) to put the query that checks the available quantity on hand in a database function (or packaged function), then call that function in your when-validate-item trigger.

To be completely safe, you need to repeat this check of available quantity in the pre-insert trigger (and pre-update trigger if quantity, color or size can be adjusted).  Otherwise what happens if there are three available, and the clerk enters two different lines for two each?  At when-validate-item time, it appears that there is sufficient quantity for each.  You also need the commit-time (pre-insert and/or pre-update) triggers to cover you if two different clerks could possibly enter a line for the same item at almost the same time.

Author Comment

ID: 2758095
Sorry i didn't expalin myself very well but i didn't know how to put what i actually wanted - turns out i had the code in the wrong kind Trigger - i had it in post change instead of in when validate - when i changed it it worked fine :-)

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question