Inserting data from a query to an existing table

How do I change my code to make it work correctly? It currently compiles I think because the program believes that the size of v_stats_5d_1 can be different from c_stats_5d_1. I have these errors:

LINE/COL ERROR

-------- ------------------------------------

30/10 PL/SQL: statement ignored

30/23 PL/SQL: ORA-00947: not enough values

CREATE OR REPLACE PACKAGE IN THE PKG_RISK_MONITOR

PROCEDURE CREATE_STATS_5D)

P_CONTEXT_DATE IN VARCHAR2

);

END PKG_RISK_MONITOR;

/

CREATE OR REPLACE PACKAGE BODY PKG_RISK_MONITOR AS

PROCEDURE CREATE_STATS_5D)

P_CONTEXT_DATE IN VARCHAR2

)

IS

l_ct NUMBER;

CURSOR c_stats_5d_1

IS

SELECT MIND_ACCOUNTS. CLIENT_ID, MIND_ACCOUNTS. CLIENT_NAME, SUM (DATA. CREATED_TRANSACTIONS_NUMBER) AS SUM_CREATED_TRX_NUMBER, SUM (DATA. CREATED_refunds_NUMBER) SUM_CREATED_REFUNDS_NUMBER, SUM (DATA. CREATED_TRANSACTIONS_value * Conversion_rate) CREATED_TRX_EUR_VALUE, DATA. PROCESSING_DATE

OF (MIND_ACCOUNTS INNER JOIN DATA ON MIND_ACCOUNTS. ACCOUNT_ID = DATA. CURRENCY_conversion INNER JOIN MERCHANT_CID) ON THE DATA. CURRENCY = CURRENCY_conversion. CURRENCY

GROUP OF MIND_ACCOUNTS. CLIENT_ID, MIND_ACCOUNTS. CLIENT_NAME, DATA. PROCESSING_DATE

(DATA. PROCESSING_DATE > = TO_DATE (P_CONTEXT_DATE, 'dd-mm-yyyy')-4) and DATA. PROCESSING_DATE < = TO_DATE (P_CONTEXT_DATE, ' dd-mm-yyyy "")

;

v_stats_5d_1 "TMP_STATS_5D_1" % rowtype;

BEGIN

-Insert subquery data into an empty table

OPEN c_stats_5d_1.

LOOP

SEEK c_stats_5d_1 INTO v_stats_5d_1;

EXIT WHEN c_stats_5d_1% NOTFOUND;

INSERT INTO 'TMP_STATS_5D_1 '.

VALUES (v_stats_5d_1);

END LOOP;

END CREATE_STATS_5D;

END PKG_RISK_MONITOR;

/

DISPLAY ERRORS

THX. Managed to get there in the end:

CREATE OR REPLACE PACKAGE IN THE PKG_RISK_MONITOR

PROCEDURE CREATE_STATS_5D)

P_CONTEXT_DATE IN VARCHAR2

);

END PKG_RISK_MONITOR;

/

CREATE OR REPLACE PACKAGE BODY PKG_RISK_MONITOR AS

PROCEDURE CREATE_STATS_5D)

P_CONTEXT_DATE IN VARCHAR2

)

IS

l_ct NUMBER;

v_sql VARCHAR2 (1000);

BEGIN

-Determine whether the table exists.

Select count (*) in l_ct

from user_tables

where table_name = 'TMP_STATS_5D_1 ';

-Remove the table if it exists.

If l_ct = 1 then

run immediately "drop table TMP_STATS_5D_1;

end if;

v_sql: = q'[CREATE TABLE 'TMP_STATS_5D_1' AS

SELECT m.client_id,

m.client_name,

Sum (d.created_transactions_number) AS sum_created_trx_number,

Sum (d.created_refunds_number) AS sum_created_refunds_number,

Sum(d.created_transactions_value * conversion_rate) AS created_trx_eur_value,

d.processing_date

M 'MIND_ACCOUNTS '.

INNER JOIN 'DATA' m.account_id d = d.merchant_cid

INNER JOIN 'CURRENCY_CONVERSION' c ON d.currency = c.currency

WHERE (d.processing_date > = To_date ('] '))

|| P_CONTEXT_DATE |

q'[(', ' dd-mm-yyyy') (-4) AND d.processing_date]<=>

|| P_CONTEXT_DATE |

q'[',' dd-mm-yyyy ")"]

GROUP OF m.client_id, m.client_name, d.processing_date] ";

immediately run v_sql;

END CREATE_STATS_5D;

END PKG_RISK_MONITOR;

/

DISPLAY ERRORS

Tags: Database

Similar Questions

  • inserting data in a column in an existing table

    Hi the gems...

    I have an existing table TABLE_1 which has more data in it. This table has no primary key. now, I added a new column 'ID' and want to make it a primary key for this table. currently it is not allowed because the column is null...

    so I need to insert data into the column.
    now, my plan is to fill the column with the data as well as rownumber.

    means that if there are 15 records in this table, then the 'ID' column should contain data from 1 to 15. After that, I'll do the column as a primary key...

    the script I wrote for this:

    declare
    number of v_rownum;

    Start
    Select max (rownum) in the v_rownum from TABLE_1;
    because me in 1.v_rownum
    loop
    Update t set i = t.id TABLE_1 where rownum = i;
    commit;
    end loop;

    end;



    but it refreshes only the first record and the rest of the records are not updated.

    Please help... Thanks in advance...

    Select max (rownum) in the v_rownum from TABLE_1;

    How many rows do you think that this query will retrieve?

    Why not just

    Update TABLE_1 t
    the value t.id = rownum;

  • I need to insert data from the parent to the child table inheritance

    Hi everyone I m using jdeveloper 12

    I have this use EDC:

    I m trying to have mini-programm in which i

    create porject, used to create and assign an employee as the project manager:

    It is therefore my phyiscal using uml data model

    cap1.PNG

    cap2.PNG

    My problem is: I need to see the values in the employee table, choose an employee id s and with the form create in this table: Project Manager: insert the employee with the s project id id

    but when I navigate to the form it is already full of I don't know why

    I did not understand your problem clearly.

    Could you please explain the problem with some screen shots and step by step flow?

    See you soon

    AJ

  • How can I insert data from another table into a table containing a timestamp column

    How you insert data from another table in a table if the target table contains a timestamp column. I tried to set the default value of GETDATE() column in the target table, but it does not work.


    I use MS SQL

    Sorry, I managed to get around this by inserting null as the value

  • Insert data from one table to another

    I have two tables SALES_MASTER and SALESMAN_MASTER which is described below.

    SQL > desc SALES_MASTER;
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    NO VARCHAR2 (6)
    NAME VARCHAR2 (20)
    PIN NUMBER (8)
    CITY VARCHAR2 (20)
    VARCHAR2 (20) STATE



    SQL > desc SALESMAN_MASTER;
    Name Null? Type
    ----------------------------------------- -------- -----------------------
    SALESMANNO VARCHAR2 (6)
    SALESMANNAME VARCHAR2 (20)
    ADDRESS1 VARCHAR2 (30)
    ADDRESS2 VARCHAR2 (30)
    CITY VARCHAR2 (20)
    PIN NUMBER (8)
    VARCHAR2 (20) STATE
    SALAMT NUMBER (8.2)
    TGTTOGET NUMBER (6.2)
    YTDSALES NUMBER (6.2)
    REMARKS VARCHAR2 (60)

    I want to insert data from SALESMAN_MASTER (2nnd table) to SALES_MASTER(first table). I want to insert only two columns NO, NAME and PIN code. All of these columns are compatible. I tried this command. But it's not working. Help me.

    SQL > insert into SALES_MASTER
    2 (NO., NAME, PIN CODE)
    3 values
    4. Select SALESMANNO, SALESMANNAME, PIN code
    5 SALESMAN_MASTER;
    Select SALESMANNO, SALESMANNAME, PIN code
    *
    ERROR on line 4:
    ORA-00936: lack of expression
    INSERT INTO SALES_MASTER
       ( NO
       , Name
       , PINCODE )
       SELECT SALESMANNO
            , SALESMANNAME
            , PINCODE
         FROM SALESMAN_MASTER;
    

    Kind regards
    Christian Balz

  • How to migrate data from a source to multiple targets (tables)?

    How to migrate data from a source to multiple targets (tables)? Describe the General steps, please or point me to a tutorial

    Yes, a table in a mapping element can be source and target at the same time (i.e. a target can be reused as a source for the rest of the map on the right side of the table).

    Don't forget to check the order of loading (in the property map), to ensure that the reused as source is loaded before the final table target table.

    I tested it and it works. However, the documentation is not said in the link I gave you above:

    "Each element of data store that has entries but no exits in the logical diagram is considered a target."

    Usually, I tend not to do. I am in favour of a Divide and Conquer approach and try to have my mapping as simple as possible. It is easier to debug and maintain.

  • Insert data from a particular region.

    I have two region report...

    I use apex item to insert data into a table. When I try to insert the data from the 2nd report region, region 1 data get insert instead of the 2nd region report data.

    How to distinguish the point of apex from one region to another region?

    This is my 2nd region (doc) report
    insert into doc values(apex_application.g_f02(i),apex_application.g_f03(i),apex_application.g_f04(i));
    How to solve this problem?

    SKUD.

    Hello

    Make sure that the columns of report 2 region should not have same value p_idx.
    Example-

    Report 1 query
    
    select apex_item.text(1 , null);
    
    Report 2 query
    
    select apex_item.text(1, null);
    

    In the example above if you see the both the query have same p_idx value in 1...

    In this case, if you try to save the data in the second report it will save the data in the first report.

    To avoid this, you must make sure that the p_idx value is different... This is... If you the first query has five columns with p_idx the value 1, 2, 3, 4, 5... so for next report make sure that the value of p_idx must be greater than 5... for example... 6, 7, etc.

    Kind regards
    Shijesh

  • Getting error while inserting data from source to the target in the procedures?

    Hello

    I want to insert the data from the source to the target in the procedures, have the same schema.

    For this, I did as follows

    Command on the source:

    Technologies: oracle

    Schema: EDWHCMB

    Command:

    SELECT COMPANY_NAME, COMPANY_CODE OF

    EDWHCMB. DWT_COMAPNY

    Command on the target:

    Technologies: oracle

    Schema: EDWHCMB

    command:

    INSERT INTO EDWHCMB. TEMP

    VALUES)

    COMPANY_CODE,

    COMPANY_NAME)

    I have run the procudere then I got error as follows

    ODI-1228: SAMPLE1 (procedure) task fails on ORACLE EDWH connection target.

    Caused by: java.sql.BatchUpdateException: ORA-00984: column not allowed here.


    How to insert the data from the source to the target in the proceedings?

    Please send any document to this...

    Please help me.

    Thanks in advance,

    A.Kavya.

    Hi Bruno.

    If your tables are on the same schema then why do you use command on the source and the command on the target? You can simply do the following on the command on the target

    INSERT INTO EDWHCMB. TEMP

    SELECT COMPANY_NAME, COMPANY_CODE OF

    EDWHCMB. DWT_COMAPNY


    If you really want at all to use the command on the source and target both then I think you need to change the following code on your order on the target

    INSERT INTO EDWHCMB. TEMP

    VALUES)

    : COMPANY_CODE,.

    (: COMPANY_NAME)

    Hope your TEMP table has only these 2 columns.

    Thank you

    Ajay

  • Insert data from 3 tables of diff with some transpose logic

    Hi all

    I need to create a MS which will have three settings:

    Mast_report_id number, posted_on_date date, number of redord_id

    I have four tables which one is the destination and reset three source tables:

    The source tables:

    1 - mast_report

    create the table MAST_REPORT

    (

    MAST_REPORT_ID Number (38) not null,

    ANNUAL NUMBER (38),

    TITLE VARCHAR2 (500),

    STATUS VARCHAR2 (10),

    DATE OF POSTED_ON,

    NO_OF_PAGES NUMBER (8).

    BILLABLE_PAGES NUMBER (8).

    MAST_LANGUAGE VARCHAR2 (20).

    CONTRIBUTOR VARCHAR2 (80).

    CRAWL_DATE TIMESTAMP (6) default sysdate,.

    FILE_NAME VARCHAR2 (30),

    PAGE_PRICE NUMBER (10,2).

    DOC_PRICE NUMBER (10,2).

    CONTRIBUTOR_ID NUMBER (20)

    );

    2 - report_details:

    create the table REPORT_DETAILS

    (

    RECORD_ID Number (38) not null,

    DOC_ID Number not null, (38)

    ATTRIBUTE_TYPE VARCHAR2 (10),

    ATTRIBUTE_VALUE VARCHAR2 (200),

    REPORT_TYPE VARCHAR2 (100),

    ATTRIBUTE_ID VARCHAR2 (80)

    );

    3 - filters_for_docid:

    create the table FILTERS_FOR_DOCID

    (

    FILTER_ID Number not null, (38)

    CONTRIBUTOR VARCHAR2 (100),

    AUTHOR VARCHAR2 (100) default not null, "No. FILTERS".

    COUNTRY VARCHAR2 (100) default not null, "No. FILTERS".

    VARCHAR2 (100) region "No. FILTERS" not null default,

    COMPANY VARCHAR2 (100) default not null, "No. FILTERS".

    INDUSTRY VARCHAR2 (100) default not null, "No. FILTERS".

    VARCHAR2 (100) of the default OBJECT not null, "No. FILTERS".

    CREATED_DATE TIMESTAMP (6) SYSTIMESTAMP not null default,

    REPORT_TYPE VARCHAR2 (100) default not null, "No. FILTERS".

    NOM_FLUX VARCHAR2 (200),

    CHANNEL_ID NUMBER (8).

    NUMBER OF CU_ID

    );

    Destination table: filtered_document

    database version:

    BANNER
    1Oracle Database 11 g Release 11.2.0.1.0 - 64 bit Production
    2PL/SQL Release 11.2.0.1.0 - Production
    3CORE11.2.0.1.0Production
    4AMT for Linux: Version 11.2.0.1.0 - Production
    5NLSRTL Version 11.2.0.1.0 - Production

    As I menteioned above the user will pass three parameters: Mast_report_id, posted_on_date, redord_id

    Here, I need to take more condition (>) to the three parameters.

    For the extraction of data, the logic is below:

    Mast_report table has two columns mast_report_id and posted_on, we need to take a larger than the condition as:

    "Select * from mast_report where and mast_report_id > 7326280 and posted_on > 25 may 2015;

    It will show many recordings roughly 10,000 with all the columns including annual column, this annual column is card with doc report_details of the table

    Now report_details table, we need recover data with annual report_details = (all the table of mast_report annual that we extract our first query) and record_id > settings of this sp record id.

    lets assume he'll again get 10000 files with all the columns.

    Now the main logic is to extract the data of using our highest performance and the third table FILTERS_FOR_DOCID.

    Assume that this is the result of our query above:

    RECORD_IDANNUALATTRIBUTE_TYPEATTRIBUTE_VALUEREPORT_TYPEATTRIBUTE_ID
    17057411269222703COMPANYTGS NOPEC GEOPHYSICAL COMPANY ASASOCIETY REPORT100203621
    27112370469222704COMPANYVOLVO ABSOCIETY REPORT100062389
    37096287469222713COMPANYPARTNERRE LTD.SOCIETY REPORT100037448
    47056915069222713COMPANYPARTNERRE LTD.SOCIETY REPORT100037448
    57056788869222729COMPANYVITAMIN SHOPPE INC.SOCIETY REPORT108008193
    67038574869222749COMPANYABB LTD.SOCIETY REPORT100096991
    77096286569222756COMPANYMETTLER-TOLEDO INTERNATIONAL INC.SOCIETY REPORT100081108
    87056897869222756COMPANYMETTLER-TOLEDO INTERNATIONAL INC.SOCIETY REPORT100081108
    97038576169222777COMPANYSUNCOR ENERGY INC.SOCIETY REPORT100063497
    107056938969222784COMPANYSYMANTEC CORP.SOCIETY REPORT100043382
    117112676469222786COMPANYARROW ELECTRONICS INC.SOCIETY REPORT100084937

    here if using separate attribute_type of report_details, we have:

    Select distinct report_details attribute_type;

    ATTRIBUTE_TYPE
    1Object
    2INDUSTRY
    3COUNTRY
    4REGION
    5AUTHOR
    6COMPANY

    Here you can see over the structure of the third table table FILTERS_FOR_DOCID where above these distinct values of the second table are the columns of the third:

    And you can see the output of the query above to report_details table, including the attribute_type and attribute_type value.

    Here, we need to find in the third table with each attribute_type and values of his attribute_type_value with the topic of the third table columns, industry,... He values.

    as: consider attribute_type values 'COMPANY' and its "TGS NOPEC GEOPHYSICAL COMPANY ASA" attribute_value now we need to find

    in SOCIETY the third table cloumn with value "TGS NOPEC GEOPHYSICAL COMPANY ASA"... same for others...

    I must now go look for these lines of the third table which all combinations get matched, need us compare with like operator between the attribute_type column value and the value of the columns in the third diff table.


    Thanks in advance

    I have impleted above the requirement using pivot, CTE, and cases in where clause.

    Thanks for all the help

  • Inserting data from one table to another table

    Hello

    I have the following SQL where I am updating a table by adding new data from another table, but without success.

    INSERT INTO
    () TOP_PROSPECTS
    COMMON_ID
    DATE_ADDED
    REVIEW_RANK
    EVAL_DATE
    PM_ASSIGN
    WHY_NOTES)
    SELECT
    t.COMMON_ID
    t.DATE_ADDED
    t.REVIEW_RANK
    t.EVAL_DATE
    t.PM_ASSIGN
    t.WHY_NOTES
    Of
    TEMP_IVAN_MARY t
    WHERE
    COMMON_ID <>t.COMMON_ID

    Any suggestions?

    Thank you.

    Published by: user13822709 on August 14, 2012 09:14

    Published by: user13822709 on August 14, 2012 09:15

    Is that what you're trying to do with the insert. I think there may be a sign {noformat}<{noformat}{noformat}>{noformat} missing in the where clause. This site eat those, so you need to use the equivalent! = post here.

    If I'm wrong about the missing trader, then it looks like you want to insert rows in temp_ivan_mary that are not already in top_prospects. If Yes, then you need something like:

    insert into top_prospects
       (common_id, date_added, review_rank, eval_date, pm_assign,
        why_notes)
    select t.common_id, t.date_added, t.review_rank, t.eval_date,
           t.pm_assign, t.why_notes
    from temp_ivan_mary t
    where t.common_id not in (select common_id from top_prospects
                              where common_id is not null)
    

    Function index and data available volumnes etc. then a mergr can be more effective. Something like:

    merge into top_prospects p
       using (select common_id, date_added, review_rank, eval_date,
                     pm_assign, why_notes
              from temp_ivan_mary) t
       on (p.common_id = t.common_id)
       when not matched then
          insert (common_id, date_added, review_rank, eval_date, pm_assign,
                  why_notes)
          values (t.common_id, t.date_added, t.review_rank, t.eval_date,
                  t.pm_assign, t.why_notes)
    from temp_ivan_mary t
    

    John

  • Insert data from variables in the Ref Cursor

    I do not know how to return data from ref cursor variables That's what I've tried so far...
    CREATE OR REPLACE type num_obj as object (
      t_number number ,
      t_type varchar2(10) ,
      t_desc varchar2(40)
    ); 
    CREATE OR REPLACE type num_table as table of num_obj; 
    
    procedure get_all_data(p_p1 in varchar2, p_rc OUT SYS_REFCURSOR) is
       l_dat1 number := 2;
       l_dat2 varchar2(10);
       l_dat3 varchar2(40);
       t_num_o num_obj;
       t_num_t num_table;
    begin
      for l_indx in 1..5 loop
         l_dat1 := l_dat1 + l_indx;
         if ( mod(l_dat1,2)=0) then
           l_dat2 := 'EVEN';
         else
           l_dat2 := 'ODD';
         end if;
         l_dat3 := 'Number ' || l_dat1 || ' is ' || l_dat2 || ' number'; 
         l_num_o := num_obj (l_dat1, l_dat2, l_dat3);
         l_num_t := num_table(l_num_o);
      end loop;
      open p_rc for select * from table(l_num_t);
      close p_rc;
    end;
    At the end, to achieve this in Ref Cursor:
    t_number | t_type | t_desc
    ---------------------------------------
    3        | ODD    | Number 3 is ODD number
    5        | ODD    | Number 5 is ODD number
    8        | EVEN   | Number 8 is EVEN number
    12      | EVEN    | Number 12 is EVEN number
    17      | ODD     | Number 17 is ODD number
    Can something like that, where I did wrong?

    BTW. I did this with the function in pipeline, now I want to try a different method.

    The refcursor can not be closed in the procedure - you must return refcursor open to the appellant.
    the appellant must read and then close it.
    There are also some errors in the names of variables and an assignment to the collection.

    Try this version:

    CREATE OR REPLACE
    PROCEDURE GET_ALL_DATA(P_P1 IN VARCHAR2, P_RC OUT SYS_REFCURSOR) IS
       l_dat1 number := 2;
       l_dat2 varchar2(10);
       L_DAT3 VARCHAR2(40);
       L_NUM_O NUM_OBJ;
       l_num_t num_table := num_table() ;
    BEGIN
      for l_indx in 1..5 loop
         l_dat1 := l_dat1 + l_indx;
         if ( mod(l_dat1,2)=0) then
           l_dat2 := 'EVEN';
         else
           l_dat2 := 'ODD';
         end if;
         l_dat3 := 'Number ' || l_dat1 || ' is ' || l_dat2 || ' number';
         L_NUM_O := NUM_OBJ (L_DAT1, L_DAT2, L_DAT3);
         L_NUM_T.EXTEND;
         l_num_t( l_indx ) := l_num_o;
      end loop;
      OPEN P_RC FOR SELECT * FROM TABLE(L_NUM_T);
    END;
    /
    
    SQL> variable xx refcursor
    SQL> execute GET_ALL_DATA( '', :xx );
    
    PL/SQL procedure successfully completed.
    
    SQL> print :xx
    
      T_NUMBER T_TYPE     T_DESC
    ---------- ---------- ----------------------------------------
          3 ODD           Number 3 is ODD number
          5 ODD           Number 5 is ODD number
          8 EVEN       Number 8 is EVEN number
         12 EVEN       Number 12 is EVEN number
         17 ODD           Number 17 is ODD number
    
  • Move the data from the partitions again tablespace - direct table filled by ETL

    Hello

    We have a large composite table date-range/hash partitioned table (using time partitioning 11.2.0.3 range)

    1 partition for each month and each such partition 4 under separate partitions.

    We want to move some data from most significant storage but also direct table and inserted in all the days as part of the data warehouse and large table want to ensure

    operations below result in errors in the data loading procedure

    Suppose also should not take long to run lines 40 million or more each month.

    Select *.

    Of user_tab_partitions

    Where table_name = 'CUSTOMER_TRANSACTION '.

    And nom_partition like 'SYS % '.

    1. (1) Alter table retailer_transaction and rename partition < nom_partition > CUST_PART_ < YYYYMM >

    1. (2) tablespace create dedicated for the month of the affected partition

    1. ((3) alter table retailer_transaction move tablespace subpartition < sys... > < partition_tablespace > created in 2) above

    ALTER table retailer_transaction change the default attributes for the partition < CUST_PART < YYYYMM > < tablespace in 2 above > tablespace)

    4 global index which would eventually rebuild afterwards due to the transition if movement makes no valid.

    Several local bitmap indexes that belong to partitions.

    Thoughts?

    Thank you

    I agree in a good store of data, everything should be according to the best practices ETL or guideline. I guess it is a FACT table, because it's big enough. A method that I can share (followed in the real world big DW) is "ELP" IE Partition Exchange loading. You can find the basic architecture of the Internet.

    The basic architecture is as

    The source (in your case partitioned) Table--> (unpartitioned) intermediate Table--> Table possible target (partitioned)--> the cleaning activities (and overtime).

    You can use any ETL tool for this (I won't mention any other reasons).

    Later, you can delete the original table and use that new table as your FACT table, your application will be available all the time. There are drawbacks as most uses of double-spaced, other than normal ETL these work will take certain amount of resources so that other ALS etc. In addition, if you load a few current days during these activities you plan / program accordingly.

    Your demo is also fine, but regular ETL may fail because you rename the partitions (some uses of ETL tool partition name, in case you ever ELP) also unusable global indexes can cause failure (you have local too?).

  • Load the data from a text file into a table using pl/sql

    Hi Experts,

    I want to load the data from a text file (sample1.txt) to a table using pl/sql

    I used the pl/sql code below

    ***********************************
    declare
    f utl_file.file_type;
    s varchar2 (200);
    c number: = 0;
    Start
    f: = utl_file.fopen('TRY','sample1.txt','R');
    loop
    UTL_FILE.get_line (f, s);
    insert into sampletable (a, b, c) values (s, s, s);
    c: = c + 1;
    end loop;
    exception
    When NO_DATA_FOUND then
    UTL_FILE.fclose (f);
    dbms_output.put_line('No. deles de lignes insérées: ' || c);
    end;

    ***************************************

    and my sample1.txt file looks like

    ***************************************
    1
    2
    3
    ***************************************

    Gets the data inserted, with way below

    Select * from sampletable;

    A, B AND C

    1-1-1
    2-2-2
    3 3 3

    I want that data to get inserted as

    A, B AND C

    1 2 3

    The text file I have is to have three lines, and the first value of each line should go to each column

    Help, please...

    Thank you
    declare
    f utl_file.file_type;
    s1 varchar2(200);
    s2 varchar2(200);
    s3 varchar2(200);
    c number := 0;
    begin
    f := utl_file.fopen('TRY','sample1.txt','R');
    utl_file.get_line(f,s1);
    utl_file.get_line(f,s2);
    utl_file.get_line(f,s3);
    insert into sampletable (a,b,c) values (s1,s2,s3);
    c := c + 1;
    utl_file.fclose(f);
    exception
    when NO_DATA_FOUND then
    if utl_file.is_open(f) then utl_file.fclose(f); ens if;
    dbms_output.put_line('No. of rows inserted : ' || c);
    end;
    

    SY.

  • Importing data from a text file in a table

    Hi Experts,

    I have the following flat file
    weekly_eft_repo  1.0                                                                                                       Page: 1
    CDC:00304 / Sat Oct-31-2009     Weekly EFT Sweep for 25/10/09 - 31/10/09  Effective Date 03/11/09         Sat Oct-31-2009 22:06:14
    ----------------------------------------------------------------------------------------------------------------------------------
    
    Bill to
    Retailer Retailer Name                  Name on Bank Account           Bank ABA   Bank Acct            On-line Amount  Instant Amount  Total Amount
    ======== ============================== ============================== ========== ==================== =============== =============== ===============
     0200101 Triolet Popular Store          Triolet Popular Store          111111111  62030100130659            10,868.00            0.00       10,868.00
     0200103 Le Cacharel Snack              Le Cacharel Snack              111111111  62030100130813             9,728.00            0.00        9,728.00
     0200104 Advanced Co-operative Self Ser Advanced Co-operative Self Ser 111111111  111111111                  7,334.00            0.00        7,334.00
     0200105 Chez Popo Supermarket          Chez Popo Supermarket          111111111  61030100044898            30,932.00            0.00       30,932.00
     0200106 Vana Supermarket               Vana Supermarket               111111111  111111111                 17,775.00            0.00       17,775.00
     0200107 Mont Choisy Store              Mont Choisy Store              111111111  62030100130804             8,840.00            0.00        8,840.00
     0200108 Vijay Store                    Vijay Store                    111111111  62030100131229            16,416.00            0.00       16,416.00
     0200109 Neptune Confection             Neptune Confection             111111111  62030100130931            11,077.00            0.00       11,077.00
     0200110 Antoine Store                  Antoine Store                  111111111  111111111                  2,470.00            0.00        2,470.00
     0200111 P.S.C Cold Storage             P.S.C Cold Storage             111111111  111111111                 10,431.00            0.00       10,431.00
     0200113 Mini Prix Boutique             Mini Prix Boutique             111111111  62030100131501            26,315.00            0.00       26,315.00
     0200114 Hotel Cassim                   Hotel Cassim                   111111111  111111111                135,147.00            0.00      135,147.00
     0200116 Aman Snack                     Aman Snack                     111111111  62030100129481             7,334.00            0.00        7,334.00
     0200117 Best For Less Company Ltd      Best For Less Company Ltd      111111111  111111111                  3,325.00            0.00        3,325.00
     0200118 Central Way                    Central Way                    111111111  111111111                 25,137.00            0.00       25,137.00
    I need to insert the data that it contains in the following table
    TABLE weekly_eft_report_temp
     Name                                      Null?    Type                        
     ----------------------------------------- -------- ----------------------------
     BILL_TO_RETAILER                          NOT NULL VARCHAR2(15)                
     RETAILER_NAME                                      VARCHAR2(100)               
     NAME_ON_BANK_ACCOUNT                               VARCHAR2(100)               
     BANK_ABA                                           VARCHAR2(1)                 
     BANK_ACCT                                          VARCHAR2(1)                 
     ON_LINE_AMOUNT                                     NUMBER                      
     INSTANT_AMOUNT                                     NUMBER                      
     TOTAL_AMOUNT                                       NUMBER 
    What is the easiest and best to proceed on this?

    Thank you
    Kevin

    If that's what you're looking for, then you can do

    with t
    as
    (
    select 'BILL_TO_RETAILER' col1 from dual union all
    select 'Some unwanted info' from dual union all
    select 'Some unwanted info' from dual union all
    select '==============' from dual union all
    select 'Actual Data' from dual union all
    select 'Actual Data' from dual union all
    select 'BILL_TO_RETAILER' from dual union all
    select 'Some unwanted info' from dual union all
    select 'Some unwanted info' from dual union all
    select '==============' from dual union all
    select 'Actual Data' from dual union all
    select 'Actual Data' from dual
    )
    select col1
      from (
             select col1, last_value(val ignore nulls) over(order by rno) val1
               from (
                     select t.*,
                            case when col1 = 'BILL_TO_RETAILER' then 1 when regexp_like(col1,'=+') then 0 else null end val,
                            rownum rno
                       from t
                    )
           )
     where val1 = 0
       and not regexp_like(col1,'=+')
    
  • Create the trigger to insert data from one user to another user in same Databas

    Dear Sir, I created a trigger as follows

    CREATE OR REPLACE TRIGGER TRIGGER1
    BEFORE INSERTING
    ON table1
    FOR EACH LINE
    BEGIN
    INSERT IN THE TEST. TABLE2
    VALUES (: NEW.) COLUMN1,: NEW. COLUMN2,: NEW. COLUMN3,: NEW. COLUMN4);
    END;
    /

    I want here to insert my user to user Test data. In this Situation when I Execute The above Trigger it shows error PL/SQL: ORA-00942: table or view does not exist

    Help, please

    What do you mean by run the trigger?
    Do you compile?
    Can be open as a TEST and do the following and try to compile your code of the trigger again.

    grant insert on TEST.TABLE2 to youruser;
    

    See you soon,.
    Manik.

Maybe you are looking for