Home » Developer & Programmer » Forms » updation is not happening when do insrt and update in same procedure in oracle forms (oracle 10g)
updation is not happening when do insrt and update in same procedure in oracle forms [message #608846] Tue, 25 February 2014 07:35 Go to next message
rvsri
Messages: 26
Registered: February 2014
Location: Chennai India
Junior Member
***Hi,Good day..am a new entry level SE in oracle forms..i will gladly appreciate if someone help me..***

i have a insrt and update statement on the same procedure..the form looks like this ,the canvas has a text field for the :Column1 upon
click on the link on this canvas shows another stacked canvas that have a list with some values to be selected for :Column2.

By default if we wont give any values for :Column2 it saves the not null value

my problem is even i select :colum2 value from List also it saves the not null value only to the database and not the value which am selecting from the list.



PROCEDURE PROCESS_ON_INSERT_UPDATE IS
BEGIN
Insert into table_name(column1,column2)
values(:column1,' ');

//updaing the not null value(column2) (in the next screen-stagged canvas-upon clicking the link from the first canvas)

IF :column2 IS NOT NULL THEN
UPDATE table_name
SET column2= :COlumn2
where
colum1=:column1 ;
END if;
End;

[Updated on: Tue, 25 February 2014 07:41]

Report message to a moderator

Re: updation is not happening when do insrt and update in same procedure in oracle forms [message #608847 is a reply to message #608846] Tue, 25 February 2014 07:48 Go to previous messageGo to next message
cookiemonster
Messages: 13923
Registered: September 2008
Location: Rainy Manchester
Senior Member
Please read and follow How to use [code] tags and make your code easier to read?

The code you've posted is too simple to misbehave, so presumably the problem lies elsewhere. What trigger is this code called from?
Actually why do you have an insert and an update? Why not just work out the correct value for column2 and just insert it at the same time as column1?
Re: updation is not happening when do insrt and update in same procedure in oracle forms [message #608848 is a reply to message #608847] Tue, 25 February 2014 08:00 Go to previous messageGo to next message
rvsri
Messages: 26
Registered: February 2014
Location: Chennai India
Junior Member
Thanks for the quick response..Sure i will follow the coding standards from this point of time.
the code is getting called from on-insert trigger.
the purpose of Insert and update in the same procedure is,even if the user forgets to enter values to the field it will store a not null value automatically and at the same time if he wants to select some values form the list it can store that value to the database-table field(the exact problem is after saving, upon requering the :column2 field is always shows not null value and table entry is also not null)
Re: updation is not happening when do insrt and update in same procedure in oracle forms [message #608849 is a reply to message #608848] Tue, 25 February 2014 08:23 Go to previous messageGo to next message
cookiemonster
Messages: 13923
Registered: September 2008
Location: Rainy Manchester
Senior Member
Is the insert and update in the same procedure?
Re: updation is not happening when do insrt and update in same procedure in oracle forms [message #608850 is a reply to message #608849] Tue, 25 February 2014 08:26 Go to previous messageGo to next message
rvsri
Messages: 26
Registered: February 2014
Location: Chennai India
Junior Member
yes..please see in the PROCEDURE PROCESS_ON_INSERT_UPDATE where the insert and update statement present.
Re: updation is not happening when do insrt and update in same procedure in oracle forms [message #608851 is a reply to message #608850] Tue, 25 February 2014 08:49 Go to previous messageGo to next message
cookiemonster
Messages: 13923
Registered: September 2008
Location: Rainy Manchester
Senior Member
If that code is not giving the results you expect then there are two options:
1) :column2 isn't set to the value you think it is.
2) Some other code is also updating column2 and setting it to a different value.

But it seems to me you're making this more complicated than it needs to be.

Why isn't the code simply this:
Insert into table_name(column1,column2)
 values(:column1,nvl(:COlumn2, ' ');


Or even scrap the on-insert trigger and just put this in pre-insert:
:column2 := nvl(:COlumn2, ' ');


You should never need to update a row immediately after inserting it.
You should never need to use on-insert, unless you're working against a non-oracle database.

In addition - why are you using a stacked canvas? What's wrong with an LOV?
Re: updation is not happening when do insrt and update in same procedure in oracle forms [message #608852 is a reply to message #608851] Tue, 25 February 2014 08:50 Go to previous messageGo to next message
cookiemonster
Messages: 13923
Registered: September 2008
Location: Rainy Manchester
Senior Member
Actually there's a third option (variation on the 2nd) - there's a database trigger on the table modifying column2 as you update it.
icon14.gif  Re: updation is not happening when do insrt and update in same procedure in oracle forms [message #608854 is a reply to message #608852] Tue, 25 February 2014 09:23 Go to previous message
rvsri
Messages: 26
Registered: February 2014
Location: Chennai India
Junior Member
Thank you Cookiemonster..it was a great input..let me modify this Code..have a great time:)
Previous Topic: Call report from Form.
Next Topic: How to ENABLE/DISABLE an item dynamically during Form6i run-time
Goto Forum:
  


Current Time: Thu May 16 21:49:56 CDT 2024