Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> update multiple rows

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: update multiple rows
 khubeb  Posted: Jun 26, 2008 06:32:54 AM

 Total Post: 108
 Joined: Apr, 2007






 UPDATE T_LOC SET address_desc = (SELECT ap_locn FROM T_ACPT,t_str where t_str.ST_TRMNL_ID=t_acpt.AP_ID and t_str.ST_TRMNL_ID is not null)

01427 single qry return multile rows.

 shake
Posted: Jun 26, 2008 06:47:50 AM  

 Total Post: 84
 Joined: Jun, 2008






 
Your SELECT surely returns multiple records. It is not possible to assign all these (record values) addresses into the SET condition. In your SET address_desc, you can obviously set a single address description of varchar2 of any length but not multiple records.

Try differently:
UPDATE T_LOC SET address_desc = (SELECT ap_locn FROM T_ACPT, t_str where t_str.ST_TRMNL_ID=t_acpt.AP_ID and t_str.ST_TRMNL_ID is not null AND t_str.ST_TRMNL_ID = <a particular value>);

 khubeb
Posted: Jun 26, 2008 06:52:38 AM  

 Total Post: 108
 Joined: Apr, 2007






 
there are so may st_trmnl_id we cant asign it..

plz chk it

update t_loc set address_desc=(select ap_locn from t_acpt) where location_code=(select location_code from t_Str where st_trmnl_id is not null)..
same error

we have to update thousand of rows plz me send soln...

 shake
Posted: Jun 26, 2008 07:24:47 AM  

 Total Post: 84
 Joined: Jun, 2008






 
You can update any no. of records with the new values. It's not an issue. But you must be very clear about the criteria which bring the changes. I mean that you give UPDATE with WHERE clause too to effect the changes on particular records. If you dont, all records of your table get updated.
Another thing is you cannot try to place multiple addresses in a condition as you have given.

Try this:

UPDATE T_LOC SET address_desc = 'Bangalore' WHERE T_LOC.f1 = v1;

f1 -> field1
v1 -> value1

If it works fine, replace the string 'Bangalore' with your own condition which returns a single value of address description.

 shake
Posted: Jul 03, 2008 02:57:18 AM  

 Total Post: 84
 Joined: Jun, 2008






 
Try this:

select count(location_code) from t_Str where st_trmnl_id is not null

This query will definitely return count value more than 1. If it returns exactly 1, it would work.

The problem is both of your subqueries return MULTIPLE records. Plz understand the problem and change the query which should return a single record(only one row).

 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Gopu Gopi334
  Gitesh Trivedi322
  Vinoth Kumar264
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software