If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > update table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-04-03, 09:09
mohan mohan is offline
Registered User
 
Join Date: Oct 2002
Posts: 78
update table

Hai
My scenerio is like this
SQL> select * from cust;

NO NAME
---------- --------------------
PERSON(ADDRESS, CITY, STATE, REGION, COUNTRY)
------------------------------------------------------------------------

1 mohan
ADDRESS1('aaaaa', 'ccc', 'sss', 'rr', 'ccc')




create or replace procedure cust_u(no number,name varchar2,add varchar2,
city varchar2,state varchar2,region varchar2,country varchar2) as
begin
update cust set name=name,person= ADDRESS1(add,city,state,region,country) WHERE NO=NO;
end;
/



I want to change all attributes based on NO .I has followed as


SQL> exec cust_u(1,'Rajesh','paramilanagar','hyd','a.p','kap ra','india');

PL/SQL procedure successfully completed.



SQL> select * from cust;

NO NAME
---------- --------------------
PERSON(ADDRESS, CITY, STATE, REGION, COUNTRY)
-----------------------------------------------------------------------------

1 mohan
ADDRESS1('paramilanagar', 'hyd', 'a.p', 'kapra', 'india')




Its still showing mohan insteaded of Rajesh.I want to change name attribute also.How to do it

Thanks in advance
mohan
Reply With Quote
  #2 (permalink)  
Old 03-04-03, 10:02
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: update table

You need to give your parameters names that are distinct from the column names - like p_name, p_no. How is Oracle supposed to know what you mean by "WHERE no=no"? It assumes you mean "WHERE cust.no = cust.no", i.e. every row. Same for all the other parameters: "SET name=name" does nothing useful.

An alternative, though not common practise, is to prefix the parameters:

WHERE cust.no = cust_u.no
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On