Solved

DEVELOPER 2000 LOV/Cursor_Trigger

Posted on 2000-04-18
5
711 Views
Last Modified: 2011-10-03
I have a customer order line which has
Line No
Style No
Colour
Size
Qty

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.

E.G

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:

DECLARE
      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;
BEGIN

      IF NOT CUR_Qty_OH%ISOPEN THEN
            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;      
END;

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
      
0
Comment
Question by:Joana
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Expert Comment

by:jtrifts
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?

Regards,

JT
0
 

Accepted Solution

by:
prabhatmandal earned 100 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....
 
0
 
LVL 4

Expert Comment

by:jtrifts
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.

Regards,
JT

0
 
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.
0
 

Author Comment

by:Joana
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 :-)
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PL SQL Search Across Columns 4 62
use lov values 2 71
date show only hh:mm 2 37
Oracle TRC and TRM files are taking too much space at Oracle client computer. 5 57
Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

762 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