Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Posts
    143

    Unanswered: Best way to code this

    I am looking for a suggestion as to the best practice of coding this. I can do this with lots of IF statements, but if there is something better and shorter, would appreciate to hear about it...

    I have a table T1 with fields
    T1_1
    T1_2
    T1_3
    T1_TYPE
    T1_ID

    I have another table T2 with fields
    T2_1
    T2_2
    T2_3
    T2_TYPE
    STATUS
    T2_ID

    T1_ID is the primary key in T1 and its foreign key is T2_ID in T2.
    I wanted to write a PL/SQL code that will only pick up records in T2 for which the STATUS column is NULL.

    It should then check if the T2_TYPE variable value is 'SVC', 'TR' or 'RMD'.

    If T2_TYPE is an SVC, then compare value of T1_1 with T2_1 and T1_3 with T2_3.
    If both comparisons match, update column STATUS = 'MATCH' else update it as 'MISMATCH'

    If T2_TYPE is a TR, then compare value of T1_1 with T2_1 only.
    If they match, update column STATUS = 'MATCH' else update it as 'MISMATCH'

    If T2_TYPE is a RMD, then compare value of T1_2 with T2_2 only.
    If they match, update column STATUS = 'MATCH' else update it as 'MISMATCH'

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    It appears you did NOT read & follow the posting guidelines found in the STICKY post at top of this forum.
    Let us see what you've tried & explained why they still have problems.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

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