Solved

PLSQL Question

Posted on 2013-06-30
6
263 Views
Last Modified: 2013-07-26
Hi All,

I am inseting data into tables using nested loops and at last I am performing commit of the entire transaction. Now I want to do a update on the same table into which I am inserting. So how do I do this?
Because before commit I cannot do the update on same table. And if I write update statement after commit then I cannot refer cursor variables as all my loops are closed.

Thanks for your help.
0
Comment
Question by:pp89
  • 3
  • 2
6 Comments
 
LVL 20

Expert Comment

by:flow01
ID: 39288585
After insert you can update the same record,  no commit needed.

But depending on what you need for update,  you can also store records to insert in a pl/sql-collection, update a record in the collection and insert the whole collection with one forall-statement.
0
 
LVL 28

Accepted Solution

by:
Naveen Kumar earned 500 total points
ID: 39288744
update can be done in the loop itself and that one final commit will do to make those inserts/updates permanent.

out of curiosity, does the updates what you are planning to do in the loop have any relation to the inserts/data which is getting processed in the loop or how is that ?
0
 

Author Comment

by:pp89
ID: 39288755
Requirement is to insert record by record using nested loops and finally before last loop I am performing a commit operation.
So after insert in a loop can I update the same table in which I am inserting?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 39288813
yes, you can as already mentioned.
0
 

Author Comment

by:pp89
ID: 39318008
Thanks all. It worked.
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 39319871
good and thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Clone Oracle 12c Database 5 42
sql query Help 12 52
ORA-01008: not all variables bound. 6 37
Oracle - SQL Where clause causing Invalid Number Error 4 26
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now