Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2004
    Posts
    113

    Unanswered: Please help.............

    update tjuggernaut
    set tv_mth = tv
    from tv t, tjuggernaut j
    where t.market_code = j.market_code
    and t.list_acct_no = j.list_acct_no;

    I am getting the error that the sql command is not properly ended.

    what is wrong?

  2. #2
    Join Date
    Jul 2003
    Posts
    2,296
    UPDATE does not use a FROM clause
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  3. #3
    Join Date
    Jul 2003
    Posts
    2,296
    something along these lines might work.
    PHP Code:
    update tjuggernaut j
    set j
    .tv_mth = (select t.tv from tv t 
                     where t
    .market_code j.market_code
                   
    and t.list_acct_no j.list_acct_no)
    where (j.market_codej.list_acct_noIN
          
    (select t.market_codet.list_acct_no from tv t 
             where t
    .market_code j.market_code
             
    and t.list_acct_no j.list_acct_no); 
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  4. #4
    Join Date
    Apr 2004
    Posts
    113
    Is this better? I am brand new to this....

    update (select market_code, list_acct_no
    from tv t, tjuggernaut j
    where t.market_code = j.market_code
    and t.list_acct_no = j.list_acct_no)
    set tv_mth = tv;

  5. #5
    Join Date
    Apr 2004
    Posts
    113
    Thank you so much Duck!

  6. #6
    Join Date
    Jul 2003
    Posts
    2,296
    see above.
    I am assuming the "tv" value in the SET clause is coming from the "TV" table.
    If not, let me know.
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  7. #7
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Quote Originally Posted by newbie2004
    Is this better? I am brand new to this....

    update (select market_code, list_acct_no
    from tv t, tjuggernaut j
    where t.market_code = j.market_code
    and t.list_acct_no = j.list_acct_no)
    set tv_mth = tv;
    That might work, if (a) you specified tv_mth in the SELECT part of the query, and (b) assuming that tv is "key-preserved" in the query - i.e. there is a defined foreign key from tv referencing tjuggernaut being used in the join. Try:
    Code:
    update (select t.tv_mth
               from tv t, tjuggernaut j
               where t.market_code = j.market_code
               and t.list_acct_no = j.list_acct_no)
               set tv_mth = tv;

  8. #8
    Join Date
    Apr 2004
    Posts
    113
    Is there a website or book I can locate to help me with pl/sql?

  9. #9
    Join Date
    Jul 2003
    Posts
    2,296
    all books:
    Code:
    http://download-west.oracle.com/docs/cd/B10501_01/nav/docindex.htm
    SQL Reference Guide:
    Code:
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/toc.htm
    Last edited by The_Duck; 08-16-04 at 13:26.
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  10. #10
    Join Date
    Apr 2004
    Posts
    113
    How about this one? I tried this one myself:

    OLD:

    update sumjug
    set ad_flag = 'A'
    from sumjug s, tjuggernaut j
    where s.list_phone_no = j.list_phone_no
    and j.ad_flag = 'Y'


    NEW:

    update sumjug s
    set s.ad_flag = (select j.A from tjuggernaut j
    where s.list_phone_no = j.list_phone_no)
    where (j.list_phone_no, j.list_phone_no) IN
    (select s.list_phone_no, s.list_phone_no from sumjug s
    where s.list_phone_no = j.list_phone_no
    and j.ad_flag = 'Y'

  11. #11
    Join Date
    Jul 2003
    Posts
    2,296
    Quote Originally Posted by newbie2004
    How about this one? I tried this one myself:
    NEW:
    Code:
    update sumjug s 
    set s.ad_flag = (select j.A from tjuggernaut j 
                     where s.list_phone_no = j.list_phone_no) 
    where (j.list_phone_no, j.list_phone_no) IN 
          (select s.list_phone_no, s.list_phone_no from sumjug s 
             where s.list_phone_no = j.list_phone_no 
             and j.ad_flag = 'Y'
    almost, your where clause is incorrect.
    - The_Duck
    you can lead someone to something but they will never learn anything ...

Posting Permissions

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