Results 1 to 5 of 5

Thread: Add Exception.

  1. #1
    Join Date
    May 2014
    Posts
    3

    Unanswered: Add Exception.

    Hi,

    Kindly guide me to add exceptions in Plsql script.

    In brief, It will load data from one table to another table and validtes existence of record and performs Merge..Update..Insert... operations using cursor in procedure.

    Thanks.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >Kindly guide me to add exceptions in Plsql script.
    rarely needed

    > performs Merge..Update..Insert... operations using cursor in procedure.
    row by row is slow by slow

    >It will load data from one table to another table
    INSERT INTO TARGET_TBL SELECT FROM SOURCE_TBL WHERE ........
    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.

  3. #3
    Join Date
    May 2014
    Posts
    3
    Hi,

    My requiremnts are,

    1. To load data from source table to target table and I have to make multiple column values into one row based on id and seprating by comma(,) from the source table and I have to insert that rows into target table.

    2. Before inserting, it should check whether the records exist in the target table before data loading from source data.

    I have to make this as procedure and also I have to add exception.

    So can you give syntax for this?

    Thanks in advance.

  4. #4
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Thumbs down

    Quote Originally Posted by Kumarappan S M View Post
    Hi,
    . . . I have to make multiple column values into one row based on id and seprating by comma(,) . . .
    It is against all best practices and good Database design to record a delimited list of values into one table column.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  5. #5
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Quote Originally Posted by anacedent View Post
    ...
    ...
    >It will load data from one table to another table
    INSERT INTO TARGET_TBL SELECT FROM SOURCE_TBL WHERE ........
    I thought that anacedent gave enough suggestions.


    Starting from the INSERT statement suggesed by anacedent...
    1. ... to make multiple column values into one row based on id and seprating by comma(,) from the source table ...
    Use LISTAGG function to make multiple column values into one row, like...
    INSERT INTO TARGET_TBL SELECT ... , LISTAGG(...) ... , ... FROM SOURCE_TBL WHERE .... GROUP BY id ...

    2. ... it should check whether the records exist in the target table before data loading from source data.
    Then, how about to use NOT EXISTS predicate, like...
    INSERT INTO TARGET_TBL SELECT ... , LISTAGG(...) ... , ... FROM SOURCE_TBL WHERE .... AND NOT EXISTS(SELECT 0 FROM target_tbl WHERE ...) GROUP BY id ...

Posting Permissions

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