Solved

ORACLE  PL/SQL BULK INSERT

Posted on 2007-11-23
4
27,462 Views
Last Modified: 2013-12-19
Hi experts,
I have PL/SQL procedure, which fetchs row and concatenate  rows into a column with a delimiter  and insert on to table. This process is done row by row.
For example,
source table
COLUMN1           COLUMN2
1                           A
1                           B
1                           C
2                            D
2                             E
3                            F
3                            A
output  table
 COLUMN1           COLUMN2
1                           A,B,C
2                            D,E
3                            F,A

Could any one provide/suggest how to   process and insert the records in bulk.
Thanks
sree
0
Comment
Question by:sreej
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 300 total points
ID: 20340704
there is a "easy" way to do it, shown/explained here:
http://halisway.blogspot.com/2006/08/oracle-groupconcat-updated-again.html

if you need help implementing it, please ask
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 100 total points
ID: 20340826
CREATE OR REPLACE TYPE "STRING_AGG_TYPE" AS OBJECT(
    total   VARCHAR2(4000),
    STATIC FUNCTION odciaggregateinitialize(sctx IN OUT string_agg_type)
        RETURN NUMBER,
    MEMBER FUNCTION odciaggregateiterate(
        SELF    IN OUT   string_agg_type,
        VALUE   IN       VARCHAR2
    )
        RETURN NUMBER,
    MEMBER FUNCTION odciaggregateterminate(
        SELF          IN       string_agg_type,
        returnvalue   OUT      VARCHAR2,
        flags         IN       NUMBER
    )
        RETURN NUMBER,
    MEMBER FUNCTION odciaggregatemerge(
        SELF   IN OUT   string_agg_type,
        ctx2   IN       string_agg_type
    )
        RETURN NUMBER
);
/


CREATE OR REPLACE TYPE BODY STRING_AGG_TYPE
IS
    STATIC FUNCTION odciaggregateinitialize(sctx IN OUT string_agg_type)
        RETURN NUMBER
    IS
    BEGIN
        sctx := string_agg_type(NULL);
        RETURN odciconst.success;
    END;
    MEMBER FUNCTION odciaggregateiterate(
        SELF    IN OUT   string_agg_type,
        VALUE   IN       VARCHAR2
    )
        RETURN NUMBER
    IS
    BEGIN
        SELF.total := SELF.total || ',' || VALUE;
        RETURN odciconst.success;
    END;
    MEMBER FUNCTION odciaggregateterminate(
        SELF          IN       string_agg_type,
        returnvalue   OUT      VARCHAR2,
        flags         IN       NUMBER
    )
        RETURN NUMBER
    IS
    BEGIN
        returnvalue := LTRIM(SELF.total, ',');
        RETURN odciconst.success;
    END;
    MEMBER FUNCTION odciaggregatemerge(
        SELF   IN OUT   string_agg_type,
        ctx2   IN       string_agg_type
    )
        RETURN NUMBER
    IS
    BEGIN
        SELF.total := SELF.total || ctx2.total;
        RETURN odciconst.success;
    END;
END;
/

CREATE OR REPLACE FUNCTION stragg(input VARCHAR2)
    RETURN VARCHAR2 PARALLEL_ENABLE AGGREGATE
    USING string_agg_type;

stragg is also from Tom Kyte.  His new method of using hierarchical queries is interesting but more expensive than using his original method of stragg.

0
 
LVL 28

Assisted Solution

by:Naveen Kumar
Naveen Kumar earned 100 total points
ID: 20344971
just browse thru the below links to understand the different methods availabe to get the result output you wanted.

http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php 

Thanks
0
 

Author Comment

by:sreej
ID: 20347782
Thanks Experts. All answers are excellent. However i have assigned maxmimun points for the first expert comment.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question