Trying to get a Trigger and Alert to work
So im trying to get a trigger to work with an alert and the Alert seems to be right and the trigger complies which seems right to me, however the instruction that I have in my book does not produce the same output that I get from my Update.
Here is the deal. I am to log into sql * with a default account as well as login as "SYSTEM"
the trigger should invoke the Alert and output a message to re-order some more product and the status should = 0 since there is no wait time. However I don't get a "Message" from the Alert and the status = 1 which indicates timeout. So if you can take a look at my code and let me know what I did wrong or how to "Connect" the two that would be great.
Trigger I created.
CREATE OR REPLACE TRIGGER order_replace_trg
AFtER UPDATE OF stock on bb_product
FOR EACH ROW
WHEN (OLD.stock = 24 AND NEW.stock = -2)
DECLARE
stock NUMBER(5,1);
idproduct NUMBER(2);
lv_msg_txt VARCHAR2(25);
lv_status_num NUMBER(1);
reorder NUMBER(3);
BEGIN
IF stock <> 24 AND reorder = 25 THEN
lv_msg_txt := 'Product 4 Reorder Time!';
DBMS_OUTPUT.PUT_LINE(lv_msg_txt);
ELSE
lv_status_num := 0;
DBMS_OUTPUT.PUT_LINE(lv_status_num);
END IF;
END;
The Alert:
BEGIN
DBMS_ALERT.REGISTER('reorder');
END;
DECLARE
lv_msg_txt VARCHAR2(25);
lv_status_num NUMBER(1);
BEGIN
DBMS_ALERT.WAITONE('reorder', lv_msg_txt, lv_status_num, 120);
DBMS_OUTPUT.PUT_LINE('Alert: ' ||lv_msg_txt);
DBMS_OUTPUT.PUT_LINE('Status: ' ||lv_status_num);
END;
Here is the block I need to run to test the trigger and alert.
UPDATE bb_product
SET stock = stock -2
WHERE idproduct = 4;
COMMIT;
The message I should get is:
Alert: Product 4 Reorder Time!
Status: 0
PL/SQL procedure successfully completed.
This is what I get.
SQL> /
Alert:
Status: 1
PL/SQL procedure successfully completed.
Thanks for your help!
Mac
Right. Register says "I'm interested in getting alerted to some particular event", Waitone says "I'm waiting until some event happens". Signal is the key thing that indicates that a particular event happened.
As for your trigger, a couple of issues
- I don't know why you're calling DBMS_OUTPUT. I'm guessing that you probably want to send a message along with your alert that the receiver gets and displays, not that you want to print a message to the window from inside the trigger.
- You're using the local variables stock and reorder in your IF statement but you never initialize them. I'm guessing that you would want to eliminate those local variables and just use :new.stock and :new.reorder (assuming that REORDER is a column in the table).
- Your WHEN clause doesn't seem to make sense. It's telling the trigger to fire only if you update stock from 24 to -2, which doesn't make sense. I'm not sure you would even need a WHEN clause here.
Justin
Similar Messages
-
Trying to get the Opening and Closing Balance, 0TOTALSTCK and 0VALSTCKVAL
Hi Experts, Good Day.
I am developing a query for Stock Balances, Using Custom cube created with copy from 0ic_c03.
I am trying to get the Opening and Closing Balance, based on Non-Cumulative KF - 0TOTALSTCK and 0VALSTCKVAL.
Both The KF's Behaviour for Exception Aggregat. = Last Value
I am using VARIABLE OFFSET as -1 to get Opening Balance, and just restriction for Closing Balance based on 0CALMONTH
Unfortunately i am getting data for the periods which does not have data in my Cube. It is taking the total value as closing balance for the periods which we don't have transaction in the cube.
For Ex. I have data for 09.2010 & 10.2010 a particular material, when i enter 08.2010 as input i am getting the total value of the material.
I hope you understand the problem and solution soon.
I will give you more explanation if needed.
Thanks in Advance....
Have a great Day Ahead.....
GopalNHi GopaIN,
can you explain us process you have done about initialization of data (2LIS_03_BX, cube compression)? it seams like there was data before 09.2010 and you load it with 2LIS_03_BX data source. That data is not in cube, but just used for update markers.
Edited by: Sasa Todorovic on Mar 25, 2011 9:48 AM -
I got a new ipad mini and chose to set up as a copy of my iPad. Didn't sync the music on however as it is a smaller model, not enough room. Now trying to get some pictures and music on. Chose some pictures that were not in iPhoto, got a message that I could only sync with one library, chose cancel, and apply and it downloaded my pictures anyway. Now trying to sync some music but just get "The iPad “Linda’s iPad” is synced with another iTunes library. Do you want to erase this iPad and sync with this iTunes library?" So I hit cancel. Have tried several times, same thing. What can I try?
You should be able to accept this message, it will cause existing music, photos (not camera roll) and videos (also excluding those in camera roll) to be removed and replaced with those from this computer. All other user data on the iPad will be unaffected.
-
Wanted to sync up my new IPhone4, and thought that I should make sure I had the most up to date version of ITunes on my desktop first. Tried to get on site, and got an error message saying; "The folder ITunes is on a locked disk or you do not have write permissions for this folder." Cannot get on ITunes at all now. Help! Thx.
In my case its a new computer the old one was stolen and the time machine disk did not work for a restore but did for copying the info to the new mac
-
I'm trying to get itunes up and running on new computer. I have lots of music I've purchased from Itunes...and they show in my account. But only some of them have the cloud next to them. The rest say "downloaded" and it won't let me download them again.
I believe that all audiobooks are supplied to Apple by audible.com, so I assume that it's them requiring the one-time only download. This is the link for contacting iTunes Support : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption
-
I had my hard drive replaced and I cant get my email to work on the new hard drive. I have the ! in the triangle next to the inbox. I tried "take all accounts online" and it ddidnt work. The email account is working on my iphone and ipad, and my macBook is connected to the internet.
Cant get help with this issue on Apple Support, so I have to go to the Apple store to the Genius Bar to get assistance. All the help issues are so technical in their jargon, that I cannot understand how to fix the issue.
-
How do I enable a calendar subscription in my iCloud calendar? I'm using a Windows laptop (Home Office 7) and am trying to get the rugby and footfall fixtures to appear on my iCloud calendar. Thanks for your help.
I suspect you had the same issue I did and downloaded the 64-bit version of the OpenSC libraries, but your firefox is 32-bit. You can see the opensc-pkcs11.dll in the System32 folder via windows explorer, but when you browse that directory via firefox to add the module, you are acutally being redirected to the SysWOW64 directory. Try intstalling the 32-bit OpenSC libraries, and adding the appropriate library from the C:\Windows\SysWOW64 directory.
-
I bought a new iPhone 6 and switched carriers and am trying to get my voicemail and instant messages ported over to the new phone
Restore from your backup. For voicemail contact your cell phone provider.
-
PLease help me.
trying to get new software and ipad reads iOS 5.1.1 your software is up to date can't get 6
iPad, iOS 5.1.1
trying to get new software and ipad reads iOS 5.1.1 your software is up to date can't get 6The original iPad can't be updated past 5.1.1.
(86600) -
I'm trying to get onto facetime and I keep getting a message saying the server encountered an error processing registration please try again later. Can anybody tell me what is going on?
I have read over and actioned ALL recommendations many times over, and still get the Facetime error..! I have reset Host file, looked for iphone certificates, set time/date to auto, checked for suspect DNS entries, cleared caches etc etc. It's become a very fustrating problem. Worked fine for a long time but then suddenly stopped.
I wish I could find the solution... -
I have Mac OS X version 10.5.8 and so im wondering what is the next step i need to get. i have tried to get snow leopard and other things and not having any lukck . can any one help me out pls.
If your Mac meets these requirements:
http://support.apple.com/kb/SP575
then you can order a Snow Leopard disk and install it.
http://store.apple.com/us/product/MC573Z/A/mac-os-x-106-snow-leopard
Ciao. -
Trying to get sysdate- 2yrs and sysdate+2yrs value into variable
Hi,
iam Trying to get sysdate- 2yrs and sysdate+2yrs value into variable.But facing the following issue. Please help me out .
Error :
p_start_date := select add_months(max(sysdate), -24) from dual;
ERROR at line 6:
ORA-06550: line 6, column 25:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable>
continue avg count current exists max min prior sql stddev
sum variance execute forall merge time timestamp interval
date <a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<an alternatively-quoted string literal with character set specification>
<an alternat
ORA-06550: line 7, column 3:
PLS-00103: Encountered the symbol "P_END_DATE"
Code
declare
p_start_date date;
p_end_date date;
begin
select add_months(max(sysdate),-24) into p_start_date from dual;
dbms_output.put_line('p_start_date' |p_start_date);
dbms_output.put_line('p_end_date' | p_end_date);
end;Hi, try:
SQL> declare
2
3 p_start_date date;
4 p_end_date date;
5
6 begin
7
8 select add_months(sysdate,-24) into p_start_date from dual;
9 select add_months(sysdate, 24) into p_end_date from dual;
10
11 dbms_output.put_line('p_start_date: ' ||to_char(p_start_date, 'dd-mm-yyyy hh24:mi:ss'));
12 dbms_output.put_line('p_end_date: ' ||to_char(p_end_date, 'dd-mm-yyyy hh24:mi:ss'));
13 end;
14 /
p_start_date: 14-04-2007 17:41:34
p_end_date: 14-04-2011 17:41:34
PL/SQL procedure successfully completed. -
keep trying to get onto appstore and its says my apple ID is disabled. Why is this happening and how can i fix it?
This forum is for questions from those managing sites on iTunes U, Apple's service for colleges and universities to post educational material in the iTunes Store. You'll be most likely to get help with this issue if you ask in the general iTunes forums.
Regards. -
my iphone 3 or 3gs got blocked when my mate was trying to get into it and blocked it and i unblocked it now im trying to activate it and it wont activate and ive tried to put diffrent sims in it and itunes keep saying theres no sim card in plz dissconect and connect again
sounds like the phone was previously jailbroken. It will never work again.
-
When I'm streaming videos from my Macbook Air to my AppleTV, my Macbook Air gets rather hot and the fan works hard and is loud trying to keep the laptop cool. Is this harmful to the laptop? Is this normal?
My MBA fans start running when I play video too - the CPU's video processor is working pretty hard to decode the video. The fans job is to provide better airflow. The time to worry is when you play video and the fans don't run.
Maybe you are looking for
-
How can I display an animated graphic in a PDF file or slide show?
I have a simple animated graphic comprising eight layers in a PSD file created in Photoshop. Can I create a version of this which can be included in a PDF file or a slideshow. I do not want to display it on the web. Any suggestions would be welcome.
-
How do I save a visual or picture of a webpage that I can then insert into a PowerPoint presentation. I don't need a live link to the web page, just a picture or visual.
-
Adding Metadata in pages for an epub
Hi I am going to use Pages to create and epub for itunes and kindle. One thing I cannot find is where to add a more comprehensive metadate, like ISBN etc. Can this be done in Pages? Regards
-
I need to use a back button which brings the site to the last selected MC. Anyone?
-
Hi i tried to update my g5 with mac os x 10.5.1 to 10.5.8
whilst updating i pulled out my usb when it was installing then i tried re installing but nothing was working i then switched the power mac off to restart it but its stuck on the apple screen and i cant open the disk drive to put a disk in to re inst