Simple problem with triggers
Hi all,
Initially I have written a trigger for testing .But im not able to write it as per the requirement.Actually I have written the trigger for a table "test" when a row is inserted into it then my trigger will insert a row in another table.In the same way if an row is UPDATED then that same field of the same row is to be updated in another table.how can I do this by modifying this trigger code.Im in a confusion of doing this.
Table: test.
Name Null? Type
ID NOT NULL NUMBER(38)
UNAME VARCHAR2(15)
PWD VARCHAR2(10)
Table : test123.
Name Null? Type
ID NUMBER
UNAME VARCHAR2(30)
PWD VARCHAR2(30)
the trigger is as follows:
CREATE OR REPLACE TRIGGER inst_trigger
AFTER INSERT OR UPDATE
ON test
FOR EACH ROW
DECLARE
id number;
uname varchar2(20);
pwd varchar2(20);
BEGIN
id := 1245;
uname :='abc';
pwd := 'xyz';
IF INSERTING THEN
INSERT INTO test123 VALUES (id,uname,pwd);
END IF;
END test_trigger;
how can i modify this for the above mentioned use.
Thanks in advance,
Trinath Somanchi,
Hyderabad.
Hallo,
naturally , you have not assign values directly in trigger. They come automatically
in trigger with :new - variables.
CREATE OR REPLACE TRIGGER scott.inst_trigger
AFTER INSERT OR UPDATE
ON scott.test
FOR EACH ROW
BEGIN
IF INSERTING THEN
INSERT INTO scott.test123 VALUES (:new.id,:new.uname,:new.pwd);
ELSE
UPDATE scott.test123
set uname = :new.uname, pwd = :new.pwd
where id = :new.id;
END IF;
END inst_trigger;Nicolas, yes, merge here is very effective, but i think, that OP can starts with simpler version von "upsert".
Regards
Dmytro
Similar Messages
-
A simple problem with sateful Session beans
Hi,
I have a really novice problem with stateful session bean in Java EE 5.
I have written a simple session bean which has a counter inside it and every time a client call this bean it must increment the count value and return it back.
I have also created a simple servlet to call this session bean.
Everything seemed fine I opened a firefox window and tried to load the page, the counter incremented from 1 to 3 for the 3 times that I reloaded the page then I opened an IE window (which I think is actually a new client) but the page counter started from 4 not 1 for the new client and it means that the new client has access to the old client session bean.
Am I missing anything here???
Isn�t it the way that a stateful session bean must react?
This is my stateful session bean source.
package test;
import javax.ejb.Stateful;
@Stateful
public class SecondSessionBean implements SecondSessionRemote
private int cnt;
/** Creates a new instance of SecondSessionBean */
public SecondSessionBean ()
cnt=1;
public int getCnt()
return cnt++;
And this is my simple client site servlet
package rezaServlets;
import java.io.*;
import java.net.*;
import javax.ejb.EJB;
import javax.servlet.*;
import javax.servlet.http.*;
import test.SecondSessionRemote;
public class main extends HttpServlet
@EJB
private SecondSessionRemote secondSessionBean;
protected void processRequest (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
response.setContentType ("text/html;charset=UTF-8");
PrintWriter out = response.getWriter ();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet main</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Our count is " + Integer.toString (secondSessionBean.getCnt ()) + "</h1>");
out.println("</body>");
out.println("</html>");
out.close ();
protected void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
processRequest (request, response);
protected void doPost (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
processRequest (request, response);
}You are injecting a reference to a stateful session bean to an instance variable in the servlet. This bean instance is shared by all servlet request, and that's why you are seeing this odd behavior.
You can use type-leve injection for the stateful bean, and then lookup the bean inside your request-processing method. You may also save this bean ref in HttpSession.
@EJB(name="ejb/foo", beanName="SecondBean", beanInterface="com.foo.foo.SecondBeanRemote")
public MyServlet extends HttpServlet {
ic.lookup("java:comp/env/ejb/foo");
} -
Problem with triggering process chain
Hi
We have a remote process chain that calls a process chain in another system.The process chain in the other system is not getting triggered with the remote chain.
We have 3 such remote chains and we are facing such a problem with only one of them.
The process chain in the other system has a start variant which gets triggered( i suppose) and gives an instance id...the next step in the process chain is to load data into a ODS.Now this step remains yellow forever.When i manually try to schedule this step it gives me records and the request in the monitor screen turns green.But the process chain step continues to remain yellow.
What can be a way out for triggering the process chain or where could the problem be?
Please help
Thanks,
SuchiHi Suchitra,
Even though ur process seems to be in yellow your data loading may be completed and the reason for it may be the delay in activation of ODs by ur PC.
For your information please go through the below infm provided in SAp Library
Note when loading into an ODS object and for the subsequent, event-controlled update:
If you switched on the automatic activation in the ODS maintenance or administration, the monitor status for the request remains yellow after the load was successfully completed. Nevertheless, the subsequent processing for the InfoPackage is started, because the loading process is successfully completed.
[http://help.sap.com/saphelp_nw04/helpdata/en/65/163d3873130057e10000009b38f842/content.htm]
I hope ur doubt is clear.
Regards,
Rajkandula -
Simple problem with transitions
Hi everyone
I am having a small bit of a problem with transitions....
When I drag a clip from the viewer over the canvas to get the menu bar pop up, and select insert with transition ( cross dissolve ) it puts in a transition but its very short and too fast and when i select it and try to make adjustments it doesn't seem to let me make any changes to the cross dissolve.
I wander what i am doing wrong?
Many thanks TimHi
Just as David Harbsmeier indicates. Handles
Transitions are handled differently in iMovie resp FinalCut.
• iMovie - material that builds the transition is taken from the videoclips = the total length remains same
• FinalCut (as pro- works) . You have to set of a piece of material in each end of the video clips.
This is called In- resp. Out-points. The remaining parts are called Handles
Transitions here are using material from these = Total lenght of movie increase
per transition.
I find books/DVDs by Tom Wolsky - Very valubale - Enjoyed them very much.
• Final Cut Express 4
• Final Cut Pro 6 - DVD course (now probably version 7)
Yours Bengt W -
hi!
i've a problem with user input in my application:
Code:
BufferedReader F_reader = new BufferedReader (new InputStreamReader(System.in));
Fs_line = F_reader.readLine();
My problem is that i've to press the return key for two times, before the JDK returns the line! Does anybody know a better solution with JDK 1.4.2?
thanks for help
mikeit was a mistake of our own implementation! code ist correct! any circumstances are our eval!
thanks mike -
Simple problem with a list initialization.
hello ! i have a class Contact and i would like to make a list of lists of Contact variables .. but when i try to run my code , it says "IndexOutOfBoundsException: Index: 0, Size: 0" . I know that every list of the list must be initialized .. but i don't know how .
here is the declaration of the List
static List<List<Contact>> lolContact=new ArrayList<List<Contact>>();and i know that i should do something like :
lolContact.get(0)=new ArrayList<Contact>();to initialize every list of the list but i don't know how . please helpbadescuga wrote:
and i know that i should do something like :
lolContact.get(0)=new ArrayList<Contact>();
Couple of problems with that.
1. You can never do methodCall() = something in Java. The result of a method call is not an L-value.
2. You're trying to assign a ContactList to a Contact variable. Basically, you're trying to do
Contact c = new ArrayList<Contact>();3. Even if you changed it to
Contact c = lolContact.get(0);
c = new Contact();it would not put anything into the list. That would just copy the first reference in the list and stick it into variable c, so that both c and the first list item point to the same object (remember, the list contains references, not objects--no object or data structure ever contains an object in Java), and then assigns a completely different reference to c, forgetting about the one to the object pointed to by the list. It would not affect the list in any way.
4. You can't do get(0) until you've first put something into the list. -
Probably simple problem with while loops
I was programming something for a CS class and came across a problem I can't explain with while loops. The condition for the loop is true, but the loop doesn't continue; it terminates after executing once. The actual program was bigger than this, but I isolated my problem to a short loop:
import java.util.Scanner;
public class ok {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String antlol = "p";
while(antlol == "p" || antlol == "P"){
System.out.println("write a P so we can get this over with");
antlol = scan.nextLine();
//it terminates after this, even if I type "P", which should make the while condition true.
}Thanks, that worked.
I think my real problem with this program was my CS
teacher, who never covered how to compare strings,Here's something important.
This isn't just about comparing Strings. This applies to comparing ANY objects. When you use == that compares to see if two references refer to the same instance. equals compares objects for equality in the sense that equality means they have equal "content" as it were. -
Simple problem with popup message before adding document on system form
Hi all,
We have an AddOn that validates price lines on system Sales Order form matrix, so that if prices fall below a certain value, a popup is show to ask to continue or not, when user presses ADD button.
The problem is that if he chooses yes (to continue), the Sales Order is not added since the button ADD keeps being selected ....
Here is my code:
[B1Listener(BoEventTypes.et_CLICK, true)]
public virtual bool OnBeforeClick(ItemEvent pVal)
int iResult = B1Connections.theAppl.MessageBox("Price lines fall bellow minimum! Continue?", 1, "NO", "YES", "");
if (iResult == 1) // NO
// Show error
B1Connections.theAppl.StatusBar.SetText("OK", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
return false;
// YES: Continue to add Sales Order
return true;
The problem is somehow related with the popup message being shown: if user says YES to continue, the system form does not continue with the standard process of adding the Sales Order (when I move the cursor above the ADD button is shows it already pressed...).
Do I have to do anything more to force the process to continue, when the user says YES?
Regards,
Manuel DiasThtas known problem. The solution for this is declare global variable as boolean, when user selects Yes, then set this variable to true and emulate click to add button again where before the message box check if its varaible sets to true - in this case dont show message box, only set variable to false.
The concept of code will be
dim continue as boolean = false
in item event
if continue = false then
x = messagebox...
if x = 1 then
continue = true
items.item("1").click
end if
else
continue = false
end if -
Simple Problem with Stacked Canvas, I hope
Hello all,
I am become a bit frustrated with what I thought would be a simple form development solution. I am trying to create a form with a stacked canvas that will display about 20 fields that can be scrolled through. This is the detail
Total of 25 fields
5 Fields on the content canvas
20 Fields on the stacked canvas
I created the first canvas that originally contained all 25 fields. Then I created the stacked canvas and moved the appropriate fields to the stacked canvas. Using the forms builder editor, I positioned my stacked canvas as such so that it would not overlap the last field on the content canvas or visa versa. This is a form being developed for Oracle EBus. Whenever I run the form in the apps, the stacked canvas is not visible. It only becomes visible when the 1st field on the canvas has focus. When the stacked canvas becomes visible, it shows all of the items of the stacked canvas and not just the ones that I included in the viewpoint. Once I tab through the last field of the stacked canvas, it goes back to the first field on the content canvas and the stacked canvas disappears. At this point I am not doing anything complicated, but for whatever reason this just is NOT working. Any advice anyone can provide, I would very much appreciate it. This is VERY frustrating.
Thank you in advance.Step No. 1
Set the STACKED CANVAS's property VIEWPORT WIDTH AND VIEWPORT HEIGHT
This property determines what viewable width and height of the stacked canvas at runtime.
Set SHOW HORIZONTAL SCROLL BAR or SHOW VERTICAL SCROLL BAR or BOTH as YES so that you can scroll down to view all the items in the CANVAS.
Step NO.2
In your WHEN-NEW-FORM-INSTANCE trigger, write the code to make the canvas visible
SHOW_VIEW('stack_canvas_name'); -
Having a simple problem with MDK
I am using eclipse+MDK to develop/debug the MAM and MAU applications. I have been using MAM with MDK no problem. About a month ago, I even used MAU with MDK no problem.
But now when I try to run MAU with MDK, the following error occurs only via eclipse, running via MAM alone works fine.
Error: 500
Location: /CMAU/home/home_mgmt.do
Internal Servlet Error:
javax.servlet.ServletException: cannot find message associated with key : dispatcher.forwardException
at org.apache.tomcat.facade.RequestDispatcherImpl.doForward(RequestDispatcherImpl.java:238)
at org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:162)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:423)
at 0002fmam0005fstart_0002ejspmam_0005fstart_jsp_0._jspService(_0002fmam_0005fstart_0002ejspmam_0005fstart_jsp_0.java:62)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:806)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:752)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:479)Hi Ezatullah,
Did you find a solution to ur problem.if yes plz tell what changes u did to make it run I am also facing the same problem..
bye
Anand -
A simple problem with natural join
i have 2 tables what have columns with distinct's names are referenced.
natural join not works 'cose only foreign key reference this 2 tables.
Have something to make table join in using an specific foreign key??
I'm using oracle9i
Example:
table a( a_cod number, a_name varchar2(20))
table b( b_cod number, b_month_year date, b_salary number)
ALTER TABLE b ADD ( CONSTRAINT b_a_FK FOREIGN KEY (b_cod)
REFERENCES a (a_cod));
select * from a natural join b
where trunc(b_month_year) = trunc(sysdate)I'm not express me correctly.
We have 2 tables like this:
CREATE TABLE PPTBA001
PPA001_GROUP NUMBER(3) NOT NULL,
PPA001_PEOPLECODE VARCHAR2(20 BYTE) NOT NULL,
PPA001_NAME VARCHAR2(60 BYTE) NOT NULL,
PPA001_DATEOFBIRTHDAY DATE NOT NULL);
CREATE TABLE CLTBA001
CLA001_GROUP NUMBER(3) NOT NULL,
CLA001_CLIENTCODE VARCHAR2(20 BYTE) NOT NULL,
CLA001_SITUATION NUMBER(1) DEFAULT 1);
SELECT * FROM PPTBA001 NATURAL JOIN CLTBA001;
ALTER TABLE CLTBA001 ADD (
CONSTRAINT CLA001_PPAA001_FK1 FOREIGN KEY (CLA001_GROUP, CLA001_CLIENTCODE)
REFERENCES PPTBA001 (OFA001_GROUP,OFA001_PEOPLECODE));
the select returns without results. 'cose does not have columns like same name.
Natural join use a columns with same name. I need something use an foreign key.
Why?? Now i have a problem .. i need aggregate one more column in primary key
and i need change all selects that have join with PPTBA001 and put manualy a new column.. if have a other possibility like natural join to using a foreign key to join the selects problems is so more easy to resolve.
Message was edited by:
jonas.lima -
A few simple problems with dreamweaver 8
Hello,
Please watch these 20 second clips so you can see my problem.
First video (quite fuzzy, sorry):
http://tinypic.com/player.php?v=qsp10x&s=5
I want it so it goes down 1 line instead of 2 lines at a
time..
Second video:
http://tinypic.com/player.php?v=8wgt93&s=5
I want to put something in that massive area next to the
buttons table area, but it keeps going underneath..Hello,
I don't think I've seen screenshot video showing a question
before. Clever.
1. Use CSS to set the margins for the <p> tags.
p {margin: 0px;}
or
p {margin: 0.2em 0em}
Adjust as needed.
2. That's how HTML works. Elements follow the normal flow and
block level
elements, like a table, usually begin on a new "line."
You could make the table with your navigation in it a 2
column table.
Insert the navigation in the first column.
Insert a new table in the second column.
Then, the new table will sit to the right of the navigation.
You could also use divs and CSS to float them next to each
other.
Your best bet is to set DW aside for a little while and learn
HTML and CSS.
DW will be far easier to use if you understand how HTML
works.
Then you'll understand why things happen like they do, what
is possible and
how to do it.
If you don't, DW will be a very frustrating adventure with a
hard learning
curve.
A good place to start:
http://www.w3schools.com/
Take care,
Tim
"jimmyharr" <[email protected]> wrote in
message
news:gn77dk$82e$[email protected]..
> Hello,
>
> Please watch these 20 second clips so you can see my
problem.
>
> First video (quite fuzzy, sorry):
>
[url]http://tinypic.com/player.php?v=qsp10x&s=5[/url]
> I want it so it goes down 1 line instead of 2 lines at a
time..
>
> Second video:
>
[url]http://tinypic.com/player.php?v=8wgt93&s=5[/url]
> I want to put something in that massive area next to the
buttons table
> area,
> but it keeps going underneath..
> -
Hi All,
I am facing a problem which now I am finding difficult to get to the root cause.
I have a trigger which inserts a row in a table whenever a column is updated in a table or a new row(s) gets added in the table.However , for update it checks that the updated value should be different from the existing value, if yes, then only it inserts in the Audit table.
For some reasons I can see same rows in the Audit table with same column values based on applying CreatedOn Desc.
Table Schema :(deliberately made small for demo)
CREATE TABLE Relationship
RelationshipID INT NOT NULL PRIMARY KEY ,
ProfileStageID INT NOT NULL ,
CreatedBy VARCHAR(128) NOT NULL,
CreatedOn DATETIME NOT NULL
GO
ALTER TRIGGER [dbo].[Relationship_AuditProfileStageProgress] ON [dbo].[Relationship]
AFTER INSERT,UPDATE
AS
IF UPDATE(ProfileStageID) AND EXISTS (SELECT * FROM inserted I INNER JOIN deleted D ON I.ProfileStageID <> D.ProfileStageID AND I.RelationshipID = D.RelationShipID)
BEGIN
INSERT INTO ProfileStageProgress(ProfileStageID,RelationshipID,CreatedBy,CreatedOn)
SELECT ProfileStageID,RelationshipID,UpdatedBy,GETDATE() FROM INSERTED
END
IF EXISTS (SELECT * FROM INSERTED) AND NOT EXISTS (SELECT * FROM DELETED)
BEGIN
INSERT INTO ProfileStageProgress(ProfileStageID,RelationshipID,CreatedBy,CreatedOn)
SELECT ProfileStageID,RelationshipID,CreatedBy,GETDATE() FROM INSERTED
END
This is the sample data which is indeed incorrect based on trigger definition :
ProfileStageProgressID
ProfileStageID
RelationshipID CreatedBy
CreatedOn
469477 6
209771 Admin
2014-05-17 03:59:36.870
469450 6
209771 MGDK QA
2014-05-16 11:59:28.790
Can anybody give me some insight of what may be happening here.
Thanks
Thanks and regards, Rishabh Kreason is you're just checking that condition outside using EXISTS so even if there's atleast one record in update with different value it become true and will insert all records from INSERTED. I think what you want is this ie checking condition at the time
of insert
ALTER TRIGGER [dbo].[Relationship_AuditProfileStageProgress] ON [dbo].[Relationship]
AFTER INSERT,UPDATE
AS
IF UPDATE(ProfileStageID) AND EXISTS (SELECT * FROM inserted I INNER JOIN deleted D ON I.ProfileStageID <> D.ProfileStageID AND I.RelationshipID = D.RelationShipID)
BEGIN
INSERT INTO ProfileStageProgress(ProfileStageID,RelationshipID,CreatedBy,CreatedOn)
SELECT ProfileStageID,RelationshipID,UpdatedBy,GETDATE()
FROM INSERTED i
WHERE EXISTS (SELECT 1
FROM DELETED D
WHERE I.ProfileStageID <> D.ProfileStageID AND I.RelationshipID = D.RelationShipID
END
IF EXISTS (SELECT * FROM INSERTED) AND NOT EXISTS (SELECT * FROM DELETED)
BEGIN
INSERT INTO ProfileStageProgress(ProfileStageID,RelationshipID,CreatedBy,CreatedOn)
SELECT ProfileStageID,RelationshipID,CreatedBy,GETDATE() FROM INSERTED
END
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Must be simple problem with wiring...surely??
Hi all,
I've just moved into a new house and it has a VERY simple phone wiring. Master socket in the kitchen, and internal wiring that goes to one further socket in the living room.
I can not get my router working on either of the sockets. The only one it works on is the test socket behind the faceplate at the socket.
I have attached some photos in case anyone can spot the problem..?
Any help greatfully recieved!@ imjolly
Thanks for that. I didn't realise.......
It does occur to me though that if one end of the cable has been wired in the "old style", then it seems unusual that the other end isn't wired the same, as presumably it would have been carried out by the same person ?
If you found this post helpful, then please click the star on the left, after all, I'm only trying to help........ -
Hi,
I want to do this: When a signal reaches an established level, the trigger act and begins the recording data during a time.
So, im trying to use a trigger fixing a positive value. But the recording data begins when I start the measurement.(clicking the run button).
How could I do what i wish?
Other question.
Is possible to record data when the signal reaches a level and stop the recording when the signal value dicrease? How can I do that?
Thanks a lot.Hi jcastan,
The answer to the first of your answers is yes, you should be able to do that.
Try to configure your task as it appears in the attached snapshot
"trigger.jpg", just change the triggering value according to your application. It should work, in my case I've wired a square
waveform to channel no.1 and I am using it to trigger the task.
The answer to your second question is a litlle bit more tricky, first try to add a Limit
test (see snapshot "test.jpg"). It is a quite straight forward
implementation but it may work, in my simple case it showed to behave
correctly. Test it and let me know if it worked.
Hope
you found it helpful.
Best.
Attachments:
test2.JPG 183 KB
trigger.jpg 184 KB
Maybe you are looking for
-
Wireless printer and wifi wont connect at same time
Hello I have a Mac Mini with software version 10.6.8 I also have a HP wireless printer and for some reason cannot get my wirless internet and wireless printer to connect at the same time, to print anything I have to disconnect from the internet and
-
The font I used while editing a cp4 slide changes when previewed in the web browser. This does not happen with other slides in my project. What can i do to prevent this?
-
1TB LaCie won't connect w/ thunderbolt cable
Whats up people :C
-
No Compatibility for AS2 FLAs? Absurd.
Will you consider adding compatibility please?? Love the dark interface - been waiting a long time for that actually. Never knew why it didn't happen when Photoshop got it. But very dissapointed that I cannot open FLAs with AS2 in them, perform an up
-
I reloaded my computer OS and of course lost my Itunes stuff on the hard drive. Now I want to save what is on my IPT 2g to the newly reloaded Itunes. The sync messages indicate they will erase the (music, videos, etc) on the IPT and replace with what