Solved

PLSQL Question

Posted on 2013-06-30
6
260 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 28

Expert Comment

by:Naveen Kumar
Comment Utility
yes, you can as already mentioned.
0
 

Author Comment

by:pp89
Comment Utility
Thanks all. It worked.
0
 
LVL 28

Expert Comment

by:Naveen Kumar
Comment Utility
good and thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

772 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

9 Experts available now in Live!

Get 1:1 Help Now