Chekcing the code of trigger/SP
Hi,
I would like to know how to check the code of triggers/stored procedures that created.
What privillge(s) do I need to do so?
Michael
create or replace view
vns as
select e.department_id,e.last_name,d.department_name
from employees e,departments d
where e.department_id=d.department_id;
create or replace trigger trgg
instead of insert on vns
for each row
declare
cnt number;
begin
select count(*) into cnt from employees where department_id=:new.department_id;
if cnt=0 then
--insert into employees(department_id,last_name) values(11,'nandu');
insert into employees(employee_id,email,hire_date,job_id,department_id,last_name)
values(207,'[email protected]',sysdate,'AC_MGR',11,'nandu'); --- Values you have to choose!!
end if;
select count(*) into cnt from departments where department_id=:new.department_id;
if cnt>0 then
insert into departments(department_id, department_name) values(11, 'wrestling'); -- department_id is needed
end if;
end;
-- testing with existing dept id = 10
insert into vns(department_id) values(10);
SQL> select * from departments where department_id = 11;
DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
11 wrestlingRequirement you must be knowing well
Just showing you, how the trigger should be as per your view and logic inside trigger or you re-create view to avoid required values in trigger body.
thanks!
Similar Messages
-
Minimizing the code in trigger
Hi All,
I've written the following code...as per the requirement... But my manager is said to minimize the code..
But i couldn't find where can i minimize it...
Could you give me suggestion on this...
Create or replace trigger G_TMO_QPP_SDY_FSDO_UAR
after update of QPP_CNTRY_ID
on TMO_QPP_SDY_T
referencing new as new old as old
for each row
WHEN (OLD.QPP_CNTRY_ID<>NEW.QPP_CNTRY_ID)
declare
voutdat varchar2(1);
vmodtp varchar2(1);
vsdy_id TMO_QPP_SDY_T.SDY_ID%type;
BEGIN
vsdy_id:=:new.SDY_ID;
INSERT into T_FSDO_D(
REPL_ID,
DK_SDY,
DK_DAT,
DK_ADT,
MOD_TMST,
MOD_TP)
SELECT
NULL,
TMO_QPP_SDO_T.SDY_ID,
TMO_QPP_SDO_T.DAT_ID,
0,
SYSDATE,
'I'
FROM TMO_QPP_SDO_T
WHERE TMO_QPP_SDO_T.SDY_ID=vsdy_id;
vsdy_id:=:OLD.SDY_ID;
INSERT into T_FSDO_D(
REPL_ID,
DK_SDY,
DK_DAT,
DK_ADT,
MOD_TMST,
MOD_TP)
SELECT
NULL,
TMO_QPP_SDO_T.SDY_ID,
TMO_QPP_SDO_T.DAT_ID,
0,
SYSDATE,
'D'
FROM TMO_QPP_SDO_T
WHERE TMO_QPP_SDO_T.SDY_ID=vsdy_id;
exception
when others then
dbms_output.put_line('error');
end;thanksJyothsna,
Very disappointed with your posting -> :(
Where is the indentation of your coding? Who will do it for you? You are not a novice here. You know how to post neatly in order to get quick response. :(
Hope you will maintain this from next time.
Now, Coming to your question ->
Trigger code can be reduced in two ways. Make modular approach and put al your code inside any function or procedure. That will be a secure approach, too.
And, speaking to your current coding - i think your boss might look like this ->
create or replace trigger G_TMO_QPP_SDY_FSDO_UAR
after update of QPP_CNTRY_ID on TMO_QPP_SDY_T
referencing new as new old as old
for each row WHEN (:OLD.QPP_CNTRY_ID {noformat}<{noformat}{noformat}>{noformat} :NEW.QPP_CNTRY_ID)
declare
voutdat varchar2(1);
vmodtp varchar2(1);
BEGIN
INSERT into T_FSDO_D(
REPL_ID,
DK_SDY,
DK_DAT,
DK_ADT,
MOD_TMST,
MOD_TP
SELECT REPL_ID,
DK_SDY,
DK_DAT,
DK_ADT,
MOD_TMST,
MOD_TP
FROM (
SELECT NULL AS REPL_ID,
TMO_QPP_SDO_T.SDY_ID AS DK_SDY,
TMO_QPP_SDO_T.DAT_ID AS DK_DAT,
0 AS DK_ADT,
SYSDATE AS MOD_TMST,
'I' AS MOD_TP
FROM TMO_QPP_SDO_T
WHERE TMO_QPP_SDO_T.SDY_ID IN (:new.SDY_ID,:OLD.SDY_ID)
exception
when others then
dbms_output.put_line('error');
end;N.B.: Not Tested...
Regards.
Satyaki De.
As suggested by Williams
Edited by: Satyaki_De on Sep 28, 2008 1:15 AM -
How can i change the code in when new form instance trigger using JDAPI
Hi all,
Can anyone tell me how can i use JDAPI to modify the when-new-form-instance trigger in all my forms,coz we have around 500 FMB's ,if this is possible by using jdapi it will be better for us..
Thanks in advance..
NajeebHi Najeeb,
The code I've given you should cover the basic steps - you will need to have a basic knowledge of Java if you want to use the JDAPI, there's no way around that unless you go and buy one of the off-the-shelf products for this kind of thing (I think there's one called orcltoolbox..?)
I've written an application that does all kinds of things to Forms specific to our needs, so it's a bit tricky to just pull out the code you need, but again, the basics will be:
String formName="C:\some_dir\some_form.fmb";
FormModule mForm=FormModule.open(formName);
Trigger myWNFITrig=Trigger.find(mForm,"WHEN-NEW-FORM-INSTANCE");
String myText=myWNFITrig.getTriggerText();
And there you have your trigger text, to do with what you please. You could put this code in the main() method of one class if you want to keep things really simple - but see how you get on, if you have any more specific questions, do come back.
Eric - that's a very good point about using Regular Expressions. I haven't used them in my JDAPI app because I wanted to keep all my .fmbs 6i-compatible for the short-term, and a posting I saw somewhere recommended sticking to Java 1.3. Which rules out the regex facility, which only appeared in Java 1.4. Now, though, I think I needn't have worried - it surely shouldn't matter which version of Java I use to make the changes to the .fmbs. My stupid!
James -
Hello,
I'm trying to find an efficient and clean way to do an action tha can be triggered by different things without having to repeat the piece of code itself at various places in my VI (after the said trigger things).
An example (because my explanation is pretty clumsy):
- The "action" (piece of code) is reading a file displaying the results (tiny more complicated than that but that shows the idea)
- I want that action to happen when for example I save data in the file, open an existing file or press a button
- Right now Im using the same piece of code at each places (when I write in the file, open existing file and press the button) using local variables
I'm trying to find a more efficient way to do that, so I can write the code only once.
FYI the whole thing is in a big while loop. The VI Im working on is pretty huge and complex so It doesnt really make sense to share it.
Hope my question is clear. Thanks !Application Design Patterns: State Machines
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
Showing more than one row at the same time, trigger necessary?
hi
I'm an absolute beginner in oracle forms, so i have a fundamental problem. i have a forms with 3 data-tables/data-blocks with following names and columns:
table "connection type": con_id, con_descr
table "connection": con_con_id (foreign key to "con_id" from "connection_typ"), sales_id (foreign key to "s_id" from "sales")
table "sales": s_id, s_descr
now i'm trying to get the following thing: when i'll execute an execute-query on "con_id" from data-block one (table "connection") i want see all records in block two (table "connection") and at the same time for each record in block two the description from "sales". so for each record in "connection" exists a record in "sales". the current problem is that i just see the "s_descr" from the selected/current record in "connection", but not all "s_descr" of every record.
i think i need a post-query-trigger but i don't know the code i need...
i hope someone understand my problem and might help me. thanks!So, let me try to summarize:
Connection has a foreign key to both ConnectionType and to Sales
When you select a ConnectionType in blok1, you want to see all Connections for that type in block 2. That's a clasic Master-Detail relationship and it looks like you've got that cracked.
If you also use a Master-Detail relationship between Connection and Sales, it will make sure Oracle Forms queries the Sales block based on the value of the current record in Connection. Hence it is showing all the Sales record for the current Connection. That's always one (or none if the sales-id is optional).
You probably don't want to use a separate block for Sales with a relationship to Connection. Don't you want just a number of lookup fields. In the Connection block you also want to show the Description from the Sales table.
To accomplish that, add an extra field to the Connection block to hold the Sales Description. Then write a post-query trigger on the Connection block. That trigger will fire for each record being fetched. In that trigger you can do something like:
select description into :connection.sales_descr from sales where id=:connection.sales_id;
Alternatively you can also base the Connection block on a query in stead of directly on the Connection table. That allows you to write a Select statement that (outer) joins Connection to Sales and use that query result as the basis for the block. -
What exactly is happening in the code mentioned?????
Hi all,
I want to know the working of the below code:
The below code is the WHEN_BUTTON_PRESSED Trigger for the ENTER_QUERY (Push Button):
DECLARE
IT_ID1 ITEM;
IT_ID2 ITEM;
IT_ID3 ITEM;
BEGIN
IT_ID1 := FIND_ITEM('BUTTON.EN_QUERY');
IT_ID2 := FIND_ITEM('BUTTON.CA_QUERY');
IT_ID3 := FIND_ITEM('BUTTON.EX_QUERY');
SET_ITEM_PROPERTY(IT_ID3,ENABLED,PROPERTY_TRUE);
if :system.mode<>'ENTER-QUERY' THEN
set_item_property (it_id1,label,'CANCEL QUERY');
GO_BLOCK(GET_APPLICATION_PROPERTY(CURRENT_FORM_NAME));
CLEAR_BLOCK(NO_VALIDATE);
ENTER_QUERY;
set_item_property (it_id1,label,'ENTER QUERY');
ELSE
EXIT_FORM;
END IF;
END;
Can You please tell me what exactly is happening in the above code?
I want to know the working of it. Help me plz.
Thank You.
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
Oracle Forms 6i.what does if :system.mode<>'ENTER-QUERY' THEN mean??
SYSTEM.MODE indicates whether the form is in Normal, Enter Query, or Fetch Processing mode. The value is always a character string.
and what does GO_BLOCK(GET_APPLICATION_PROPERTY(CURRENT_FORM_NAME)); do?
GET_APPLICATION_PROPERTY Returns information about the current Oracle Forms application. CURRENT_FORM_NAME Returns the name of the current form as indicated by the form module Name property.
GO_BLOCK navigates to an indicated block. If the target block is non-enterable, an error occurs.
As per the code, After i press the button, the label ENTER QUERY should become CANCEL QUERY, (that is when system is in ENTER_QUERY mode) .
So when in the system is in ENTER_QUERY mode, it must display CANCEL QUERY, Right??
in your post, you also said..
The below code is the WHEN_BUTTON_PRESSED Trigger for the ENTER_QUERY (Push Button):
We see 3 button in your code. How can we know which one is ENTER_QUERY button. Your code says...
ENTER_QUERY;
set_item_property (it_id1,label,'ENTER QUERY');
So, it says.. BUTTON.EN_QUERY label will be ENTER QUERY
Then why the code, (if :system.mode<>'ENTER-QUERY' THEN set_item_property (it_id1,label,'CANCEL QUERY');) ?? which says if system mode is not equal to ENTER_QUERY,
then it tells to display CANCEL QUERY.
it says.. BUTTON.EN_QUERY label will be CANCEL QUERY -
How to Track the table using Trigger or any other Object
Hi Folks
I need to audit Inserts, deletions, updates to inserted into other tracking table. I was planning on using a trigger to do this,
Can you please help me how can I wright code for trigger for this. or else using any other object we can do this operation.
can you please help me thanks in advance.
Thank in advance.Also you can use an OUTPUT clause ( need to modify your DML operations)
create table itest ( i int identity not null primary key, j int not null unique )
create table #new ( i int not null, j int not null)
insert into itest (j)
output inserted.i, inserted.j into #new
select o.object_id from sys.objects as o
select * from #new
drop table #new, itest;
go
The example below shows code that uses OUTPUT clause in UPDATE and DELETE statements to insert rows into an audit table.
create table t ( i int not null );
create table t_audit ( old_i int not null, new_i int null );
insert into t (i) values( 1 );
insert into t (i) values( 2 );
update t
set i = i + 1
output deleted.i, inserted.i into t_audit
where i = 1;
delete from t
output deleted.i, NULL into t_audit
where i = 2;
select * from t;
select * from t_audit;
drop table t, t_audit;
go
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How to find the code in standard transaction from where event is trigered
I have a configuration in SWEC, to trigger an event, when a PR is change
For the Transaction ME52 (Change Purchase requisition), I want to go to the portion of the code, from where the function module for triggering the event is executed.
I have learnt that F.Ms for trigerring events programatically are
1. SWE_EVENT_CREATE.
2. SWE_EVENT_CREATE_IN_UPD_TASK.
3. SWE_EVENT_CREATE_FOR_UPD_TASK
So, I tried debugging the transaction ME52 by setting breakpoints at the following function modules.
1. SWE_EVENT_CREATE.
2. SWE_EVENT_CREATE_IN_UPD_TASK.
3. SWE_EVENT_CREATE_FOR_UPD_TASK.
But none of these were encountered.Hi Sameer,
Why not follow the reverse approach! First check the event getting triggered and then move backwards to the source of triggering the event.
Activate event trace from SWELS and then check the event getting triggered in SWEL.
I doubt if putting break-points in the FM would help...
Check if the event is being triggered by the BO method.
You can check the where-used list of the method and find out the source of the event triggering.
Hope this helps!
Regards,
Saumya -
F9 doesn't work even after the code that I put it inside KEY-F9
IN KEY-F9 I PUT :-
SHOW_KEYS;
and in run time , when i press F9 nothing happen !
why the code didn't execute ?!
I attached the fmb file in this link :-
http://www.zshare.net/download/16231588ffb4d1df/
, and it work with HR schemaI modified the file fmrweb.res and did that :-
from
120 : 3 : "Shift+Ctrl+F9" : 91 : "Function 9"
to
120 : 3 : "F9" : 91 : "Function 9"
and even although I programmed the KEY-F9 trigger to
if show_lov('LOV4') then
message('OKayyyyyyyyyyyyyyy');
else
message('NOOOOOOOOOOOOOOOOO');
end if;
but in Run Time when I press F9 nothing happened , but when I press Shift+Ctrl+F9 the LOV appear !!!!
what's went wrong here ? -
How to subtotal in alv? Please correct the code!!!!
hi,
I have an alv layout like following:
ZZZ 300100089 1050
ZZZ 300100089 1050
subtoal 2100
90256243 300100000 193410
90256242 300100000 173250
90256241 300100000 173250
90256240 300100000 173250
90256239 300100000 173250
90256238 300100000 173250
90256237 300100000 173250
subtotal 1232910
when the second numbers are the same,
I need to sum up as
300100089 2100
300100000 1232910
I write the coding as the following, but it did not work. I go dump in function module. Please
help and correct it!!
DATA I_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA WA_SORT TYPE slis_sortinfo_alv.
WA_SORT-fieldname = 'H_BETRG'. " speicfy field name..
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO I_SORT.
CLEAR WA_SORT.
IN FM.
it_sort = i_sort
I do not know what is the file name I should put into the WA_SORT-fieldname, I tried "wrbtr" and some other name, but I got the same dump when I excute the program. Please help me to correct the code.
Thank you.Hi,
The dump is as following:
What happened?
The current application program detected a situation which really
should not occur. Therefore, a termination with a short dump was
triggered on purpose by the key word MESSAGE (type X).
Error analysis
Short text of error message:
Technical information about the message:
Message classe...... "0K"
Number.............. 000
Variable 1.......... " "
Variable 2.......... " "
Variable 3.......... " "
Variable 4.......... " "
Variable 3.......... " "
Variable 4.......... " "
Trigger Location of Runtime Error
Program SAPLSLVC
Include LSLVCU10
Row 36
Module type (FUNCTION)
Module Name LVC_SORT_COMPLETE
31 LOOP AT CT_SORT INTO LS_SORT.
32
33 READ TABLE IT_FIELDCAT ASSIGNING <LS_FIELDCAT>
34 WITH KEY FIELDNAME = LS_SORT-FIELDNAME BINARY SEARCH.
35 IF SY-SUBRC NE 0.
>>>> MESSAGE X000(0K).
37 ENDIF.
38
39 LS_SORT-SELTEXT = <LS_FIELDCAT>-SELTEXT.
40
41 * Zwischensummenstufen ermitteln
42 IF NOT LS_SORT-SUBTOT IS INITIAL.
43 L_COUNT = L_COUNT + 1.
Please help, thank you!! -
Batch Code to trigger bat file whenever there is an error in Eventvwr log error
Batch Code to trigger bat file whenever there is an error in Eventvwr log error
Hello,
You can create a windows service which can look into EventVwr and update you accordingly
Sample code:
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EventViewer
class Program
static void Main(string[] args)
//logType can be Application, Security, System or any other Custom Log.
string logType = "Application";
EventLog ev = new EventLog(logType, System.Environment.MachineName);
int LastLogToShow = ev.Entries.Count;
if (LastLogToShow <= 0)
Console.WriteLine("No Event Logs in the Log :" + logType);
// Read the last 2 records in the specified log.
int i;
for (i = ev.Entries.Count - 1; i >= LastLogToShow - 10; i--)
EventLogEntry CurrentEntry = ev.Entries[i];
Console.WriteLine("Event ID : " + CurrentEntry.EventID);
Console.WriteLine("Entry Type : " + CurrentEntry.EntryType.ToString());
Console.WriteLine("Message : " + CurrentEntry.Message + "\n");
Console.ReadKey();
ev.Close();
Alternative way is to use below link
http://blogs.technet.com/b/jhoward/archive/2010/06/16/getting-event-log-contents-by-email-on-an-event-log-trigger.aspx
Thanks
Abhishek -
Using LV Class Property Nodes in In-place Element structure causes the code to halt
I have some code written in LV RT 2010 that uses property nodes from a LVOOP class that I created. I am using access the property node from inside an in-place element structure. When the code reaches the property node, LabVIEW stops running. (as if the abort button was pressed). I verified this behaviour using highlight execution. When I remove the in-place structure code runs fine.
Is this is know bug in LabVIEW? Is there a CAR to resolve this created for a future release?Bob,
I tried to reproduce the behavior you're seeing by recreating the Trigger and Trigger List classes, but I have not been able to reproduce it. Please take a look at my version of the project in the attached zip file. Take a look at Test.vi, and feel free to modify and repost it to show me how to make the problem occur. I would like to file a CAR to make sure we get the problem fixed, but I will need to be able to reliably reproduce it first.
On a similar note, you can get much better performance out of the Process Triggers VI by preallocating the list array, instead of using build array in a loop. Take a look at Process Triggers2.vi in my project. You can run Benchmark.vi to see the performance difference between the two different approaches.
Chris M
Attachments:
triggerlist test.zip 165 KB -
Where is the code behind buttons?
Hi,
I need to modify some forms developed several years ago. There are some buttons on a horizontal toolbar. They all work ok except one button. I tried to find code behind these buttons by clicking the "+" sign in front each button item, but it looks like no trigger is attached to any of the buttons. Where can the code be hidden? Even if the buttons are inherited from object group or property class, I should be able to see some code, right? Any idea?
Thanks.
SherryHi,
I think if the buttons do default actions e.g Exit does EXIT_FORM, tnen there is no need for triggers - try creating a WHEN-BUTTON-PRESSED trigger under one of the items with MESSAGE('Hello World'); and see what happens. Forms can work with no triggers at all if all that is required is default functionality. When you require, for example, conditional validation/navigation a trigger is needed. Take a text item: pressing RETURN will fire the NEXT_ITEM built-in unless you explicitly change Forms behaviour by coding a KEY-NEXT-ITEM trigger (which could contain any PL/SQL e.g. EXECUTE_QUERY if you want a query block to execute a query upon hitting RETURN from an item.
Hope this helps -
Labview code to trigger and scan spectra from HR4000 spectrometer?
has anyone used labview code to trigger and scan spectra from HR4000 spectrometer? When I use one of the device drivers (Spectral Acquisition.vi), i miss lots of trigger when I run it for more than 100 iterations?
I was wandering if anyone is working with it or had in the past and if you could share your insight.
ThanksInconsistent times are one thing, overall slowing down is another, although they may have common source. I guess it is the XY plot in your case. Do you have it AutoScaled? If so, try turning autoscaling of both axes off.
Secondly, I don't quite understand the reason for the inner loop with number of iterations = constant 1. What happens if you remove the loop? I understand you want to change the number of iterations in future, but let's test the simplest things first. Removal will require indexing the Wavelength array explicitly with an apropriate block. By the way, it is customary that you EITHER define the number of iterations of a FOR loop by connecting the N input OR by indexing of an input array - NEVER both at the same time. Maybe, changing the multiple XY plot into a single XY plot won't be necessary, maybe it will, try for yourself.
Thirdly, I suggest you try enclosing the XY plot block alone in a case structure (say, in its TRUE window) and set the true condition to occur at some fraction of the total iterations, not every cycle. You do this using the index "i" of the main iteration loop, calculate modulo something (e.g. 10) and test if it is true or false. This way you update the XY plot every 10th iteration only and by choosing different modulo divider you can test, if the plot's display is or isn't the beast slowing things down.
Finally, I suspect it is not necessary to use a Local Variable of the seconds 2 indicator. How about simply wiring the output of your To-double block to the input of the subtraction block? That should let you remove seconds 2 local variable with no harm done.
Daniel -
Question: How does the "KEY-COMMIT" trigger work?
Hello All,
What is the “KEY-COMMIT” Trigger for the BLK_UPDATE data block for? When is the Trigger being activated? Where can I find the information regarding the "KEY-COMMIT" Trigger (FYI, I have looked at the ORACLE Form online document and the help in the Forms 6i Builder, but so far I found nothing)?
Any information regarding to the "KEY-COMMIT" Trigger would be greatly appreciated!
Thanks in advance,
Jinlan
--From my other post, I got the following information from Andreas Weiden and just want to share with you all here:
"If you want the code inside your KEY-COMMIT-trigger executed, you will have to do a DO_KEY('COMMIT_FORM'); instead"
This information really clarifies the def and use of the "KEY-COMMIT" trigger. Great thanks to Andreas for sharing.
Maybe you are looking for
-
Exported Captivate PDF won't open in 10.1.5 update
The latest update 10.1.5 does not open Captivate files exported as a PDF. Adobe 11 doesn't open those files either, only X would open the files. Any suggestion to fix this issue? Is there another update that is available that will run the files in fo
-
2504 N+1 HA Configuration
Hi all, I've installed two WLC 2504 (Code 7.5.102.0) with HA N+1 following this documentation http://www.cisco.com/en/US/docs/wireless/technology/hi_avail/N1_High_Availability_Deployment_Guide.pdf See bellow the configuration : Primary WLC : (Cisco C
-
ITunes can play only once, then I need to quit in order to play again.
Hi I have lots of video to play, one day I couldn't play my video without quitting iTunes first. Now whenever I want to play a video, I need to quit iTunes because I didn't quit from after the previous time that I was playing a video clip from my lib
-
I have found a bug in Logic Pro 10.0.3.
In the Environment Window, go to "Clicks & Ports" & create a new object. Go to Fader/Specials/Cable Switcher. In the parameter window- Set the Style to "As Text", then change the Range to anything other then 0-127. Instant crash every time. Also, if
-
I just updated my X7 with Belle and everything seems to be fine except 2 things. 1) Whenever I try to send a message through my WhatsApp Messenger keeping my phone horizontal,it just doesn't go.I mean I can type the message but I can't send it.And wh