Home » Developer & Programmer » Forms » How to user Alert in form
How to user Alert in form [message #259223] Tue, 14 August 2007 14:25 Go to next message
affanalim
Messages: 1
Registered: August 2007
Junior Member
Hi,

I want to use Alert option in form. How i will user alert as message "Given qty is greater than stock qty"

Thank
affan
Re: How to user Alert in form [message #259231 is a reply to message #259223] Tue, 14 August 2007 15:32 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
One way is to create an alert displaying function which can be called any time you need it. It looks like this:
FUNCTION ALERTF (alert_ime VARCHAR2, alert_poruka VARCHAR2)
   RETURN NUMBER IS alert_dugme NUMBER;
BEGIN
   set_alert_property(alert_ime, alert_message_text, alert_poruka);
   alert_dugme := show_alert(alert_ime);
   return alert_dugme;
END;

Then, create several alerts (those that will enable you to click only <OK>, or <OK> <Cancel>, or <Yes> <No>, or ...). Let's call one of them 'AERROR', its style is "Stop" and contains only one button with the "OK" label.

In a trigger/procedure, declare a NUMBER variable and use it to call previously created function:
procedure ... is
  alertgumb   number;
begin
  select ... into ... from ... where ...;

  if l_qty > stock_qty
  then
     alertgumb := alertf('AERROR', 'Given qty is greater than stock qty');
     raise form_trigger_failure;
  end if;
end;
Re: How to user Alert in form [message #259306 is a reply to message #259223] Wed, 15 August 2007 00:02 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
Set your message like this in the alert property...!

'Given '||:qty||' is greater than stock '||:qty

Regards,
Azam Khan
Re: How to user Alert in form [message #259320 is a reply to message #259306] Wed, 15 August 2007 00:56 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
OP's "qty" is NOT quantity (numeric value), but an abbreviated word - part of a sentence.

Your example
Quote:
'Given '||:qty||' is greater than stock '||:qty

evaluates to (if 'qty' item's value equals 150)
Quote:
'Given 150 is greater than stock 150'


What's the purpose of doing it?
Re: How to user Alert in form [message #259327 is a reply to message #259320] Wed, 15 August 2007 01:13 Go to previous messageGo to next message
azamkhan
Messages: 557
Registered: August 2005
Senior Member
What I meant was that instead of hard coding your numeric value why dont you use variables that hold your values and in this way your code becomes dynamic and if there is a new value that you want to alert then you dont have to change the code b/c the value is being displayed dynamically.

I hope Mr. Littlefoot this time you have received updated answer.

Regards,
Azam Khan
Re: How to user Alert in form [message #259366 is a reply to message #259327] Wed, 15 August 2007 05:02 Go to previous message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
If at all you want to show the figures also for better understandability, then there should be two variables.
'Given Quantity '||:given_qty||' is greater than Stock Quantity '||:stock_qty
Then it should give as the following For Ex:
Given Quantity 160 is greater than Stock Quantity 150

Edit: I prefer to put to_char, I mean an explicit conversion.
By
Vamsi

[Updated on: Wed, 15 August 2007 05:04]

Report message to a moderator

Previous Topic: forms upgrade problem:text line-height in forms 10g
Next Topic: get ROWID
Goto Forum:
  


Current Time: Fri Sep 27 04:18:45 CDT 2024