Results 1 to 2 of 2

Thread: update table

  1. #1
    Join Date
    Oct 2002
    Posts
    78

    Unanswered: 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

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •