How to handle the trigger sequence
I really do not have any idea for this question.
the trigger need to implement:
An employee can not work on more than 2 projects supervised by any given department.
DEPARTMENT (dname, dnumber, mgrssn, mgrstartdate) KEY: dnumber.
PROJECT (pname, pnumber, plocation, dnum) KEY: pnumber.
CREATE TABLE WORKS_ON
( ESSN VARCHAR2(9) NOT NULL,
PNO NUMBER NOT NULL,
HOURS NUMBER(3,1) NOT NULL,
PRIMARY KEY (ESSN, PNO));
DESC WORKS_ON;
INSERT INTO WORKS_ON VALUES
('123456789',1,32.5);
INSERT INTO WORKS_ON VALUES
('123456789',2 ,7.5);
INSERT INTO WORKS_ON VALUES
('666884444',3 ,40.0);
INSERT INTO WORKS_ON VALUES
('453453453',1 ,20.0);
INSERT INTO WORKS_ON VALUES
('453453453',2,20.0);
CREATE TABLE PROJECT
(PNAME VARCHAR2(15) NOT NULL,
PNUMBER NUMBER NOT NULL,
PLOCATION VARCHAR2(15),
DNUM NUMBER NOT NULL,
PRIMARY KEY (PNUMBER), UNIQUE(PNAME));
DESC PROJECT;
INSERT INTO PROJECT VALUES(
'ProjectX',1, 'Bellaire',5);
INSERT INTO PROJECT VALUES(
'ProjectY',2, 'Sugarland',5);
INSERT INTO PROJECT VALUES(
'ProjectZ',3,'Houston',5);
INSERT INTO PROJECT VALUES(
'Computerization',10,'Stafford',4);i create package and two trigger like following in order to avoid mutating table.
PACKAGE "HW4AIDB" AS
TYPE EmploadY IS RECORD(
Empessn varchar2(9),
Empprojectcount number,
Empdepartcount number
TYPE EmploadarrayY is table of EmploadY
index by BINARY_INTEGER;
Empload EmploadarrayY;
Emploadsize number;
END;
create or replace
TRIGGER TPROJECTA AFTER INSERT OR UPDATE OR DELETE ON WORKS_ON
DECLARE
i number:=0;
BEGIN
HW4AIDB.Emploadsize :=0;
for m in (select w.essn empessn,
count(w.pno) empprojectcount, count(distinct p.dnum) empdepartcount
from works_on w, project p
where w.pno=p.pnumber
group by w.essn)loop
i :=i+1;
HW4AIDB.Empload(i).Empessn := m.empessn;
HW4AIDB.Empload(i).Empprojectcount := m.empprojectcount;
HW4AIDB.Empload(i).Empdepartcount := m.empdepartcount;
dbms_output.PUT_LINE('TPROJECTA '||' '||m.empessn||' '||m.empprojectcount||
' '||m.empdepartcount);
end loop;
HW4AIDB.Emploadsize :=i;
dbms_output.PUT_LINE('==================================');
END;TRIGGER TSALARYB BEFORE INSERT OR UPDATE OR DELETE ON EMPLOYEE
FOR EACH ROW
DECLARE
w HW4AID.EmploadX;
i number;
mypos number;
BEGIN
mypos :=-1;
for i in 1..HW4AID.Emploadsize loop
if(:new.ssn = HW4AID.Empload(i).Empssn) then
w.Empmgrsalary := HW4AID.Empload(i).Empmgrsalary;
w.Empsalary := HW4AID.Empload(i).Empsalary;
mypos :=i;
exit;
end if;
end loop;
i :=mypos;
dbms_output.put_line('NEW '||:new.ssn||'-'||:new.salary);
if updating then
dbms_output.put_line('updating......');
if(:new.salary > w.Empmgrsalary) then
raise_application_error(-20005,'the salary is higher than that of department manager');
end if;
dbms_output.PUT_LINE('update done');
end if;
END;
i defined two trigger for AFTER, trigger run orders are acorrding to. before statement level, before row-level, after row level and after statement level.
so my trigger actually can not implement requirement. how to handle it. now i try to use this rule: select w.essn, w.pno,p.pnumber, p.dnum from works_on w, project p where w.pno=p.pnumber; in statement level trigger. howerver in row-level trigger i can not get value i need(p.dnum i can not get its count). if you guy have any other ideas, pls give me some advise. my brain is really run out of.
Thanks for your help!!!
I would recommend creating a package/procedure that is the only way to insert a user into the works_on table. Then inside this procedure you need to serialize access to the works_on table by using a select for update. Then you can count the number of projects and ensure that the new works on is valid.
If you try to use triggers then due to Oracle's mutli-versioning, if two users insert the same data at the same time, the data integrity will be violated.
You will obviously have an employee table. I have created one here as follows:
create table employee (essn varchar2(9) primary key);
insert into employee values ('999999999');
Then you can use this table to serialize access to the works_on table by issuing a select for update against it. If you don't do this then two users executing the procedure at the same time will violate the constraint. It is important that you understand this and try it out with multiple sessions so that you understand it.
create or replace procedure insert_works_on
(p_essn varchar2, p_pno number, p_hours number)
as
l_essn varchar2(9);
l_count number;
begin
select essn
into l_essn
from employee
where essn = p_essn
for update;
select count(*)
into l_count
from works_on w
join project p on p.pnumber = w.pno
where w.essn = p_essn
and p.dnum = (select dnum
from project
where pnumber = p_pno);
if l_count < 2
then
insert into works_on values (p_essn, p_pno, p_hours);
else
dbms_output.put_line('Employee works on more than 1 project for dept');
end if;
end;
Then you can try it out:
begin
insert_works_on('999999999',1, 10);
end;
commit;
begin
insert_works_on('999999999',2, 20);
end;
commit;
begin
insert_works_on('999999999',3, 30);
end;
commit;
The first two will succeed and the last will fail. Try it out in multiple session as well to ensure it works for a multi-user scenario.
Similar Messages
-
How to handle user exit sequence
how do handle the userexit sequence i,e in which order the user exits are stored?
one and state solution
go to debugger mode make breakponint on statement call fm.
and press f8 continiously and check exit fm one by one. -
How to handle format trigger in bi publisher report
Hi all,
anyone have idea how to handle format trigger in bi publisher report....
also if someone will illustrate the how exactly we use the triggers in bi publisher reports.
regards
RatneshHi,
there's no direct support for the format triggers out of Oracle Reports. Therefore they are mentioned in the log file and in the created layout after conversion the objects with format triggers are colored red to show, that there you had to do some additional work.
Currently you had to built the logic of format triggers in BI Publisher new. Hve a look in the User Guide, there are some examples for if or choose statements.
regards
Rainer -
How to handle the OK button of the parameters prompt of a crystal report
Hi,
how to handle the OK button of the parameters prompt of a crystal report in vba.NET?
I want to use the parameter prompt from the crystal report itself and I want to know when the report is ready. I need to export programatically by sending email to a list of employees after the parameters has been set. The emails I send depends on the results of the report.
Im using a CrystalReportViewer control in VS2010 and Crystal Report for VS2010 v13.0.1.220.Right. But the parameter screen is driven by the viewer. Unless you create your own parameter screen and pass the parameters to the report via code.
Another thing I am not sure about:
"Then by code I want to read all the employees id from the report and send email to them with specified pages of the report. (1 page per employee)"
How do you plan on reading the employee ID from the report? I am not aware of any API that will read a value in a report so that you can then decide what page to send to whom.
I think you're approaching this kinda backwards. A question to ask is; can you do what you are trying to do in code in the CR designer? If not, using APIs will not work either. I suspect your approach should be a report that uses an employee filter. Run the report for employee x, get the report populated with the data for that employee and email it. Repeat for employee x1, employee x2, etc.
- Ludek -
How to create the Access sequence for the Vendor+material+plant combination
Hi all
Please let me know How to create the Access sequence for the Vendormaterialplant combination..
Whats the use? What its effect in purhcase and taxe..
brief me pleaseHi,
you are asked to maintain the access sequence for the tax condition for which you are putting 7.5%.
goto OBQ1 or img..financial accounting new...global settings.... taxes on sales and purchases ......basic settings.....
find the tax condition type. see in it which access sequence is attached.
if there is none then use JTAX used for taxes in India.
or you can create the similar one for your.
to create the same goto OBQ2.
new entry or copy JTAX.
and assign the access sequence to condition type.
this will resolve your problem if you just need to assign the access sequence.
regards,
Adwait Bachuwar -
How to handle the control records in case of file to idoc scenario.
Hi All,
can you please clarify me how to handle the control records in case of file to idoc scenario.Hi,
In File to Idoc scenario even though you selected apply control record values from payload and you are not getting those correct values which you have provided in the mapping.
Also check the checkboxes Take sender from payload and Take receiver from payload along with the Apply control record values from payload checkbox
Regards
Seshagiri -
How to handle the different pricing conditions changes in BI.
Dear Friends
can any one send me Regarding
How to handle the different pricing conditions changes in BI.
Thanks & Regards
RamanaHi,
Take a look at the 0sd_o06 ODS and 2lis_13_vdkon datasource for sales billing conditions.
http://help.sap.com/saphelp_nw70/helpdata/EN/36/8188408bc0bb4de10000000a1550b0/frameset.htm
http://help.sap.com/saphelp_nw70/helpdata/EN/7f/0f8c4037fba62be10000000a1550b0/frameset.htm
Regards. -
How to handle the stale cheques in EBRS
Dear Guru's
Can any bady explain me how to handle the stale cheque cases in EBRS, and what are the possible transaction codes using for that.
Any help can be greatly appreciated.
Regards,
kishroeHi
any bady know about this plz respond.
Thanks in Advance
kishore -
How to handle the extended vo in the extended controller
Hi,
I want to know how to handle the extended vo attributes in the extended controller.
I extended CompetenceElementsVO as 'CompetenceElementsEx' with 2 transient attributes called col1 and col2.
Here i want to pass value according based on some condition. for this i want to know how to handle these attributes.
I tried by using the extended vo name in the controller, if i use means then it is throwing error after the extended controller is implemented.
Same time if i try to refer this attributes from the original vo definition, jdev itself showing error.
please tell me how to handle this?
Thanks in advance,
SANHi San,
You have to extend the controller where your region is associated with,
And in that controller you get the AM(if there is more than one AM and your VO is associated with a child AM, first you have to get your required AM) and then
get the ViewObject(standard).
Then you should be able to get your newly added attributes.
Please find the below sample code to get the AM handle and VO from there, update the code according to your requirement,
Get all the VOs under the Root AM
writeLog(pageContext, "Room AM"+ pageContext.getRootApplicationModule());
String[] rootViewNames = pageContext.getRootApplicationModule().getViewObjectNames();
/* writeLog(pageContext," Length of the VOs from Rootm AM "+rootViewNames.length);
for (int j =0 ;j<rootViewNames.length ;j++ )
writeLog(pageContext,j +" Value "+rootViewNames[j]);
// Get requested AM from Root am
public OAApplicationModule getRequestedAM(OAPageContext pageContext, String requestedAMName)
writeLog(pageContext,"Requested AM called to check the AM "+requestedAMName );
String amName = "";
String objectivesAMName = requestedAMName;//"ObjectivesAM";
String nestedAMArray[] = pageContext.getRootApplicationModule().getApplicationModuleNames();
pageContext.writeDiagnostics(this,"Root AM=>"+pageContext.getRootApplicationModule().getName() + " Child AMs=>"+ nestedAMArray.length,1);
OAApplicationModule currentAM = null;
currentAM = (OAApplicationModule)pageContext.getRootApplicationModule();
for(int i = 0; i < nestedAMArray.length; i++)
amName = nestedAMArray;
pageContext.writeDiagnostics(this,"Nested AM Name=>"+amName + "and amName.indexOf(objectivesAMName) "+amName.indexOf(objectivesAMName),1);
currentAM = (OAApplicationModule)pageContext.getRootApplicationModule().findApplicationModule(amName);
//Get the view names
String[] viewNames = currentAM.getViewObjectNames();
for (int i =0 ;i<viewNames.length ;i++ )
writeLog(pageContext,i +" Value "+viewNames[i]);
if(!(amName.indexOf(objectivesAMName)==-1))
pageContext.writeDiagnostics(this,"Found Handle to My Nested AM " + amName ,1);
break;
return currentAM;
Get the VO from the AM
OAViewObject objAssessmentVO = (OAViewObject)yourAM.findViewObject("yourVO");
Thanks.
With Regards,
Kali.
OSSi. -
How to handle the call transaction in method of a custom business object
Hello all,
There is a custom report " RPTCORAPP" for approving leaves . As per my requirement i have develop a copy of leave workflow and for approval process i have call "RPTCORAPP" in Custom method of custom object. i have made a transaction for this custom report for approving attendances. I am calling this method though call transaction statement within method.
Problem: while approving the attendance workitem is not disappearing from the portal. Problem is due to call transaction statement.
once workitem come to the user, user click on it. control goes to the report, which display all the leave to approve on
the portal.
If after approving/ rejecting attendance user close the screen.workflow remain in the "process" status.Control wont come back after call transaction statement in the method.
At the same time if user clicks on back button inspite of closing the screen. it is working fine. workitem disappears from the portal.
How to handle the scenarion. if after approving/rejecting, i want the control to come back to the NEXT STATEMENT after call transactionstatement in my method.
Please help it out........:)Hi swami,
thanks for reply. but i am not using BDC in my method. iam just calling a custom transaction thriugh statement
Call transaction 'ZHR_APPROVE_CLINOUT'. This transaction directly run the report RPTCORAPP and display all the request. -
How to handle the table control in bapi?
how to handle the table control in bapi? example va01.
i pass multiple line item what is the procedure?
header detail same .
eample ship to party
sale to party.
line item mulptiple
10 mat1
2o mat2
30 mat3.
in bapi we can pass sinle line item.
any way to handle multiple line item pass through the bapi.
Message was edited by:
Karthikeyan PanduranganBAPI is not going through the screen flow logic so you need not to worry about the table control. Just check in the BAPi there must be one table parameter for line items just pass one int table with your data to that table parameter it will automatically update the tables.
Regards
shiba dutta -
How to handle the #error in ssrs expression
hi
Please any one help me to resolve this #error ,
I have a calculated filed in that expression i given a if condition like below
data of column is coming like this 0 , 0.0
=IIF(Fields!Column1.Value=0,0,((Fields!Column2.Value - Fields!Column1.Value)/( Fields!Column1.Value)))
how to handle the #error
Please let me know any oneHi deepuk23,
According to your description, when you use the IIF() function in the report you got some error,right?
The issue can be caused by the column1 and column2 have different datatype, I assumed that one is integer and another is float, when the Column1 is 0 or null, because IIF() function always evaluates both the true part and the false part, even
though it returns only one of them, it will throw out the error.
To resolve the issue, you should use a nested IIF() function to avoid the zero-divisor in any rate like below:
=IIF(Fields!Column1.Value=0,0,((Fields!Column2.Value - Fields!Column1.Value)/(IIF(Fields!Column1.Value=0,1,Fields!Column1.Value))))
For more information, please refer to this article:
FAQ: Why does the “Attempted to divide by zero” error still happen?
If you still have any problem, please feel free to ask.
Regards,
Vicky Liu
Vicky Liu
TechNet Community Support -
How to handle the errors in transformations
Hi
I am using SOA, JDev 10.1.3.3.
How to handle the exceptions in transformations.
If any thing goes wrong in transformation then how to handle that situation.
I am not getting any kind of instances like errored out..
Please help me out
Regards
PavankumarI think your issue is that your process is going into manual recovery.
In the console click on the tab BPEL processes. There is a link on the left for manual recovery. Do you see your processes there?
What happens if you put your transformation into a scope. The in that scope you have a catch All. In this catch All routine just do a terminate. This will error your process but you should see it appear in the console.
cheers
James -
How to handle the multiple line items in the Inbound idoc FM
Hi ,
Can any body give me how to handle the multiple line item in the idoc when we reprocessing it from workitem....
Thanks in Advance,,,,
Regards,
BharaniHi ,
Can any body give me how to handle the multiple line item in the idoc when we reprocessing it from workitem....
Thanks in Advance,,,,
Regards,
Bharani -
How to handle the 500 Internal Server Error + ADF
Hi,
How to handle the 500 Internal error ADF application? I tried with giving the error page in web.xml but it does not work
Please advicei'm not sure if this is related, but we also have the following in the web.xml file
<filter-mapping>
<filter-name>adfFaces</filter-name>
<url-pattern>*.jsp</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>adfFaces</filter-name>
<url-pattern>*.jspx</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
Maybe you are looking for
-
So I am surfing the net or watching something online then all of a sudden firefox 4 crashes it says its suppose to restore my tabs but it never does. please i want this fixed it is so annoying in addition my tabs do not save any more like they used t
-
Transferrring parameter values from URL (by query strings)
Hello, Is it possible to transfer username and password by a Url link with query strings? (http://help.sap.com/saphelp_nw04/helpdata/en/ce/3dd23a09313b37e10000000a11405a/content.htm ) I tried the following URL pattern, but it didn't work.. http://xxx
-
"Track this list in Access" not working
I have a PC with Microsoft Office *2003*, Access 2003, and Windows XP. We use SharePoint 2010. With this configuration, I am able to create a linked table in Access. I have a laptop with Microsoft Office *2010*, Access 2003, and Windows XP. When I us
-
Let's say, in finished good A, component C is the substitude of component B. Assuming the usage of both components in A is 1 unit. Finished Good A: Demand: 100 Primary Component B Onhand Qty : 20 PO: 20 Substitude Component C Onhand Qty: 10 PO: 10 H
-
Mass component substitution in Task List
Hi Gurus, I'have so many Task Lists, and total have hundreds of line operations. But, now there material substitution. Let say, previously in Taks List using Material/Component "A", and now material "A" substituted become material/compenent "B". How