SQLLDR: How to fill empty columns with specific default data ?

Hello,
We are in 11G
Here is a complete exemple:
1) The table definition:
create table IMPORT_PRJ_TIMESHEETS
  RESSOURCE_CODE VARCHAR2(20),
  REFERENCE_DATE VARCHAR2(20),
  STATUS         VARCHAR2(20),
  PROJET_CODE    VARCHAR2(50),
  TACHE_ID       VARCHAR2(100),
  TACHE_DESC     VARCHAR2(250),
  RAF            NUMBER,
  JOUR1          NUMBER,
  JOUR2          NUMBER,
  JOUR3          NUMBER,
  JOUR4          NUMBER,
  JOUR5          NUMBER,
  JOUR6          NUMBER,
  JOUR7          NUMBER,
  IMPORT_DATE    DATE
);2) the CTL:
LOAD DATA
CHARACTERSET WE8ISO8859P1
   APPEND INTO TABLE IMPORT_PRJ_TIMESHEETS
-- Pour eliminer la ligne d'en-tete
WHEN PROJET_CODE != 'ID projet'
   FIELDS TERMINATED BY '*-*' OPTIONALLY ENCLOSED BY '"'
( RESSOURCE_CODE       CONSTANT '!RESSOURCE_CODE!'
, REFERENCE_DATE       CONSTANT '!REFERENCE_DATE!'
, STATUS               CONSTANT '!STATUS!'
, PROJET_CODE          CHAR
, TACHE_ID             CHAR
, TACHE_DESC           CHAR
, RAF                  CHAR "TO_NUMBER( :RAF, '999G999D99')"
, JOUR1                CHAR
, JOUR2                CHAR
, JOUR3                CHAR
, JOUR4                CHAR
, JOUR5                CHAR
, JOUR6                CHAR
, JOUR7                CHAR
, IMPORT_DATE          SYSDATE
{code}
3) the datafile :
{code}
ID projet*-*ID tâche*-*Tâche/Description*-*RàF*-*lun. 13/07*-*mar. 14/07*-*mer. 15/07*-*jeu. 16/07*-*ven. 17/07*-*sam. 18/07*-*dim. 19/07*-*
FR-FR-NT2300135*-* *-*GAMMAWEB - Coordination*-*0,00*-* *-* *-* *-*8,00*-*8,00*-* *-* *-*
*-* *-*Holiday*-* *-* *-*8,00*-* *-* *-* *-* *-* *-*
*-* *-*Special leave*-* *-*8,00*-* *-* *-* *-* *-* *-* *-*
*-* *-*Vacation*-* *-* *-* *-*8,00*-* *-* *-* *-* *-*
{code}
- As you can see, the datafile delimiter is "*-*" .... there's no pb about this.
- Also, there are 5 lines in the datafile. Currently, the _*load status*_ is :
   - Line 1 is the header  >>> not loaded, and that's fine with me.
   - Line 2 is successfully loaded
   - Line 3 / Line 4 / Line 5 : are not loaded .. but I need these lines ...
*What I'd like to get is to successfully load lines 3 to 5 with a default values for the first 3 columns (project/task ID/ task desc)*
I hope it's clear enough and that you will be able to provide a good answer ..
Thanks in advance,
  Olivier                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Thanks for your reply ... it was helpful..
here is the current CTL I use with the datafile above:
LOAD DATA
CHARACTERSET WE8ISO8859P1
   APPEND INTO TABLE IMPORT_PRJ_TIMESHEETS
   FIELDS TERMINATED BY '*-*' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
( RESSOURCE_CODE       CONSTANT '!RESSOURCE_CODE!'
, REFERENCE_DATE       CONSTANT '!REFERENCE_DATE!'
, STATUS               CONSTANT '!STATUS!'
, PROJET_CODE          CHAR "NVL(:PROJET_CODE, 'INDIRECT')"
, TACHE_ID             CHAR
, TACHE_DESC           CHAR
, RAF                  CHAR "TO_NUMBER( :RAF, '999G999D99')"
, JOUR1                CHAR
, JOUR2                CHAR
, JOUR3                CHAR
, JOUR4                CHAR
, JOUR5                CHAR
, JOUR6                CHAR
, JOUR7                CHAR
, IMPORT_DATE          SYSDATE
{code}
I have removed line "  WHEN PROJET_CODE != 'ID projet'   "  , because when I use it, because column is NULL .. it doesn't take the NULL into consideration... and as a results, there is only one line loaded, and not the 3 others !
Now, when I remove line "  WHEN PROJET_CODE != 'ID projet'   " , I get the results that I want (4 lines loaded), BUT a BAD file is created (with the first row, the one that starts with 'ID projet' )   
I understand that this is normal behaviour with this CTL.
But would it be possible to not put this 'ID projet' line into the BAD file (so that the directory is not polluted with numerous BAD files)
   I was thinking with something like this :   "  WHEN NVL( PROJET_CODE, 'none') != 'ID projet'  "
       But this doesn't work..
Do you have any advice to provide ?
Thanks in advance
  Olivier                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • In sm30, when save, how to fill the table with the system data in the table

    Hi all, in SM30, we have user name and time fields, when we create record, after we click the SAVE button, it will automatically fill the fields with the system data, how can we realize it?

    Hi ,
    Do like this.
    1. Go to SE11 -> give your table name and press on change button .
    2.Go to Menu->Utilities-> Table Maintainance Generator , then it will take you another screen .
    3.Assign Functin group if already have one , other wise create function group and assign
    4.Go to Menu->Environment->Modification->Events , again it will take you to another screen
    5.Click on new entries
    ->Now press F4 in T column . Select<u> "01" - Before saving the data in the database</u> and in form routinue give any name of the routinue like "SAVE_USER_DATA" and press enter then u can see an editor symbol in next column click on that it will take you ABAP editor there type this code .
    ztable-username = sy-uname.
    ztable-createtime = sy-uziet.
    check and activate the code .
    With this your job will be complete . Now while entering data just leave columns blank , they will insert corresponding username and time
    Don't forget award points if it helps you.
    Regards,
    Raghav

  • How to fill empty cells with previous non empty value?

    Hello 
    rows where cat=2 do not have price and i want to fill it with previous value wich cat=1 for every item
    Table named tb
    id        item_no     price         cat 
    1           I1             5           1
    3           I1                          2          the price must be 5   
    4           I1                          2          the price must be 5  too
    9           I1             2           1
    10         I2             10          1
    11         I2             5           1
    15         I2              10        1       
    28         I2                          2        the price must be 10  
    30         I2             2           1
    32         I2             10          1
    filled table must be like that:
    id        item_no     price       cat 
    1           I1             5           1
    3           I1            
    5           2          
    4           I1            
    5          2          
    9           I1             2          1
    10         I2             10        1
    11         I2             5          1
    15         I2             10        1       
    28         I2            
    10        2      
    30         I2             2          1
    32         I2             10         1
    How can i do that?

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. You have no idea,
    do you? Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. Why are you so rude to people? Now we have to guess a everything and try to fix your mess. 
    There is no generic “id” in RDBMS; it has to be an industry identifier or “<something in particular>_id”. I like the GTIN. Was that useless vague name supposed to be “<something>_cat” as a category scale? 
    CREATE TABLE Items
    (foo_seq INTEGER NOT NULL, 
     gtin CHAR(15) NOT NULL, 
     unit_price DECIMAL (12,2), 
     foobar_cat CHAR(1) NOT NULL
         CHECK (foobar_cat IN ('1', '2')), 
    CREATE PROCEDURE Add_New_Item
    INSERT INTO Items
    VALUES
    (1, 'I2', 5.00, 1), 
    (3, 'I1', NULL, 2), -- unit price must be 5.00
    (4, 'I1', NULL, 2), -- unit price must be 5.00
    (9, 'I1', 2.00, 1), 
    (10, 'I2', 10.00, 1), 
    (11, 'I2', 5.00, 1), 
    (15, 'I2', 10.00, 1), 
    (28, 'I2', NULL, 2), -- unit price must be 10
    (30, 'I2', 2.00, 1);
    >> rows where cat=2 do not have price and I want to fill it with previous value which cat=1 for every item <<
    Rows in a table are not ordered! There is no concept of “previous row” in RDBMS. This is fundamental. Are you using a sequence that you erroneously call “id”? 
    But that makes no sense! Look at (1, 'I2', 5.00, 1) and then (3, 'I1', NULL, 2). Why does item 'I2' have anything to do with the price of item 'I1'? 
    Can you explain? 
    Table named tb
    id   item_no   price   cat 
    1    'I1',  5    1
    3    'I1',  NULL   2  -- the price must be 5   
    4    'I1',  NULL   2  -- the price must be 5  too
    9    'I1',  2    1
    10   'I2',  10   1
    11   'I2',  5    1
    15   'I2',   10   1   
    28   'I2',  NULL   2   -- the price must be 10  
    30   'I2',  2    1
    32   'I2',  10   1
    filled table must be like that:
    id   item_no   price   cat 
    1    'I1',  5    1
    3    'I1',  5    2   
    4    'I1',  5   2   
    9    'I1',  2   1
    10   'I2',  10   1
    11   'I2',  5   1
    15   'I2',  10   1   
    28   'I2',  10   2   
    30   'I2',  2   1
    32   'I2',  10   1
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to update a Column with specific Serial ?

    I have serial in the first table on primary key from 1 to 4 , and I want to repeat this serial in the foreign key in the second table .
    that what I want to appear in the foreign key , I want the repeating take place till the end of the last record in the second table.
    *1*
    2
    3
    4
    1
    2
    3
    4
    1
    2
    3
    4
    1
    2
    3
    4
    1
    *2*
    I tried with FOR .. LOOP but doesn't work with me :-(
    What should I do ?!

    CREATE SEQUENCE seq_cycle START WITH 1 MAXVALUE 4  CYCLE CACHE 3;
    SELECT seq_cycle.NEXTVALUE FROM dual;
    /

  • How to fill grid column combobox with data?

    Hi Experts,
    I have a question about ComboBox column in a Grid item. I know how to set column to be a combobox, but question is - how to fill this combobox with ValidValues?
    I execute query for data table binded with grid and then change column's type to combobox.
    Regards
    Szymon Lipnicki

    Hi Szymon,
    You need to add the Value and Description to the Combo's ValidValue collection, just like with a normal Combo.
    I leave you a sample that shows how to fill a Combo from a RecordSet.
                Dim oRS As SAPbobsCOM.Recordset = oCompany.GetBusinessObject(BoObjectTypes.BoRecordset)
                oRS.DoQuery("SELECT T0.ListNum, T0.ListName FROM [dbo].[OPLN] T0")
                If oRS.RecordCount > 0 Then
                    Dim oGrid As SAPbouiCOM.Grid = oForm.Items.Item("grid").Specific
                    Dim oColumn As SAPbouiCOM.Column = oGrid.Columns.Item("PriceLst")
                    For i As Integer = 1 To oRS.RecordCount
                        oColumn.ValidValues.Add(oRS.Fields.Item(0).Value.ToString, oRS.Fields.Item(1).Value.ToString)
                        oRS.MoveNext()
                    Next
                End If
    Best Regards,
    Vítor Viera

  • How to make text columns with adobe muse

    Hi,How to make text columns with adobe muse (like InDesign)?

    Multiple columns can be acheived with CSS - http://www.w3schools.com/css/css3_multiple_columns.asp
    div
    -moz-column-count:3; /* Firefox */
    -webkit-column-count:3; /* Safari and Chrome */
    column-count:3;
    I'm surprised that Muse does not support text columns yet, but perhaps the custom CSS can be added in style tags on page properties. Haven't tried it, but don't see why it wouldn't work.

  • How to fill a symbol with color

    How to fill a symbol with color?

    Good day!
    What do you mean by »symbol« in this case?
    Is this on a Layer of its own or is it part of a photograph?
    Could you please post a screenshot with the Layers Panel visible?
    Regards,
    Pfaffenbichler

  • How can i register column with in the query

    hi all
    how can i register column with in the query?

    Thanks.
    In my business one, the column width was registed.
    But I don't know how can I do it.
    So I try to save the query again after change column width.
    Then the query was opend with changed column width.
    Is it right function?
    Is there any way to register the column width?
    It's very troublesome to change column width every time.
    seiichi

  • I HOW I FILL PDF FORM WITH HEBROW ON CHROME ?

    I HOW I FILL PDF FORM WITH HEBROW ON CHROME ?

    Chrome uses its own (incompatible) PDF viewer.
    Download the PDF to your local disk, then fill it from there with Adobe Reader.  Or use a browser that uses the Adobe PDF plugin.

  • Fill empty cell with '0'

    Hi,
    I have a crosstab table and some of the cells within the table are empty purely because there is no data in the database which is reasonable.
    For presenation purposes, what are my options to fill these empty cells with '0'?
    I was hoping to find an option to default empty cells to '0', but failed to find such feature.
    Thanks in advance.
    Regards
    Tom

    Hi Tom
    Steps to fill empty cell with '0':-
    1. Select intersection cell in cross tab.
    2. Go to properties tab.
    3. In Text Format section, click on Number Format button.
    4. Select Format type is 'Number' and check the Custom check box.
    5. Enter 0 in all text boxes(Positive, Negative, Equal to zero, and Undefined).
    6. Click ok.
    Now you can see 0 in the Emply cells of cross tab.
    If you want decimal values, enter 0.00 in Positive box.

  • How to fill internal table with selection screen field.

    Hi all,
    i am new to sap . pls tell me how to fill internal table with selection screen field.

    Hi,
    Please see the example below:-
    I have used both select-options and parameter on the selection-screen.
    Understand the same.
    * type declaration
    TYPES: BEGIN OF t_matnr,
            matnr TYPE matnr,
           END OF t_matnr,
           BEGIN OF t_vbeln,
             vbeln TYPE vbeln,
           END OF t_vbeln.
    * internal table declaration
    DATA : it_mara  TYPE STANDARD TABLE OF t_matnr,
           it_vbeln TYPE STANDARD TABLE OF t_vbeln.
    * workarea declaration
    DATA : wa_mara  TYPE t_matnr,
           wa_vbeln TYPE t_vbeln.
    * selection-screen field
    SELECTION-SCREEN: BEGIN OF BLOCK b1.
    PARAMETERS : p_matnr TYPE matnr.
    SELECT-OPTIONS : s_vbeln FOR wa_vbeln-vbeln.
    SELECTION-SCREEN: END OF BLOCK b1.
    START-OF-SELECTION.
    * I am adding parameter value to my internal table
      wa_mara-matnr = p_matnr.
      APPEND wa_mara TO it_mara.
    * I am adding select-options value to an internal table
      LOOP AT s_vbeln.
        wa_vbeln-vbeln =  s_vbeln-low.
        APPEND  wa_vbeln TO  it_vbeln.
      ENDLOOP.
    Regards,
    Ankur Parab

  • Matrix exporting to excel with empty columns, with page break option of "Between each instance of a group" selected.

    I am working with Report Builder 3.0 I am using a matrix to produce grouped data on separate worksheets in excel.
    The select is:
    SELECT ID, Measurement, Value, [Date] FROM Measurements_Report. (please ignore the underscores they are just for formatting) 
    The contents of the Measurements_Report table:
    ID__Measurement__Value__[Date]
    1___Hot_________33_____10/1/2014
    2___Hot_________44_____10/2/2014
    3___Cold_________55_____10/2/2014
    The matrix contains a single row group based on the field "measurement". The Measurement group has the page break option of "Between each instance of a group" selected. 
    There is a column group based on the field "Date". 
    When this is matrix is exported to excel on the first worksheet (Hot) there are three columns as shown below:
    ID__10/1/2014____10/2/2014___10/2/1014
    1___33
    2_______________44
    Notice the last column doesn't have a value.
    On the second worksheet (Cold) there are also three columns as shown below:
    ID__10/1/2014___10/2/2014___10/2/1014
    3__________________________55
    This time notice there is only one row and only a value in the last column.
    I only want the columns with data for that worksheet to show up. How can I remove these empty/duplicate columns? Hopefully there is a simple fix. Thanks ahead of time.

    With the following contents of the Measurements_Report table:
    ID__Measurement__Value__[Date]
    1___Hot_________33______10/1/2014
    2___Hot_________43______10/1/2014
    2___Hot_________44______10/2/2014
    3___Cold________55______10/2/2014
    Returns on the first tab (Hot):
    ID__10/1/2014____10/1/2014____10/2/2014
    1___33
    2_________________43
    2______________________________44
    In the excel worksheet it contains a separate column for each date with a value. Thanks again!
    Why is the same date repeating on multiple columns? Do you've the time part also returned from database?
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to fill empty parameter (selection-option)

    Hi!
    On selection screen I have two parameters (s_egrid and s_empid). If user enter something in first (but not in second) one, second one should be filled from database.
    The problem is that I don't know how to fill the empty parameter.
    Let's say that i have an internal table i_zemployee with list of all necessary employee Id's (stored in field empid)
    if I Ioop like this
    loop at i_zemployee into wa_zemployee.
        insert wa_zemployee-empid into s_empid.
      endloop.
    ... I did something stupid but i hope that you understand what i need:
    s_emipd[1] = 'u1'.
    s_emipd[2] = 'u7'.
    s_emipd[3] = 'u9'.
    ... like array of user id's.
    and this s_empid I need in my next SELECT statement like
    SELECT * FROM ...
        WHERE empid in s_empid.
    if someone knows the solution thanks in advance!
    T.

    HI try something like this...
    tables: mara, makt.
    data: begin of itab occurs 0,
    matnr like mara-matnr,
    end of itab.
    data : begin of btab occurs 0,
    maktx like makt-maktx,
    end of btab.
    ata mak like makt-maktx.
    DATA : return like ddshretval occurs 0 with header line.
      data: begin of dynpfields occurs 3.
              include structure dynpread.
      data: end of dynpfields.
    select-options: p_matnr for mara-matnr.
    select matnr from mara into table itab where matnr IN p_matnr.
    loop at itab.
    write: / itab-matnr.
    endloop.
    Initialization.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr.
    REFRESH ITAB.
    SELECT matnr FROM mara INTO TABLE ITAB.
    call function 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
    retfield = 'MATNR '
    dynprofield = 'P_MATNR '
    dynpprog = sy-REPID
    dynpnr = sy-dynnr
    value_org = 'S'
    TABLES
    value_tab = ITAB
    return_tab = return.
    select single maktx from makt into  mak where matnr = return-fieldval.
    p_matnr = return-fieldval.
    refresh return.
    clear return.
    move 'P_MAKTX' to dynpfields-fieldname.
    move mak to dynpfields-fieldvalue.
    append dynpfields.
    CALL FUNCTION 'DYNP_VALUES_UPDATE'
      EXPORTING
        dyname                     = 'SY-REPID'
        dynumb                     = '1000'
      tables
        dynpfields                 = dynpfields
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    refresh return.
    clear return.
    validate according to ur requirement.
    Regards
    Syed A

  • How to fill internal table with no data in debugging mode

    Hi all,
             I modified one existing program.Now I want to test it.I am not given test data.So in the middle of my debugging, I found that one internal table with no data.My problem is how to fill that internal table with few records in that debugging mode just as we change contents in debugging mode.If I want to proceed further means that internal table must have some records.
    Please I dont know how to create test data so I am trying to create values temporarily in debugging mode only.
    Thanks,
    Balaji

    Hi,
    In the debugging do the following..
    Click the Table button..
    Double click on the internal table name..
    Then in the bottom of the screen you will get the buttons like CHANGE, INSERT, APPEND, DELETE..
    Use the APPEND button to insert records to the internal table..
    Thanks,
    Naren

  • How to update a column with default in a tabular form.

    We have a tabular form that has a submit button that does a multi row update. We would like to update a column with a defaut like APP_USER = updated user when the row is updated. Is this possible and how?

    used lovs and conditions.

Maybe you are looking for

  • My ipad will no longer connect to the tv after software upate

    until recently my ipad connected to tv with adaptor no problem,since update it says not compatable with ipad

  • Time machine with network drive?

    I heard I could use time machine with the hard drive I have connected to my airport extreme.  Problem is I can't get the disk to appear in the time machine set up window as an option

  • Event won't open

    It isn't at all rare that I cannot open an event to find details such as what time, where, etc. Usually when this happens, I go upstairs and check my wife's iCal which is synchronized with mine. A couple of days later, I can open that same event on m

  • Cpu utilisation

    i have a mac pro 2x dual core and a macbook 1x dual core. my problem is this: on my mac pro when doing some very heavy cpu tasks like rendering video etc my cpu usage seems to max out at 50% all 4 cores are being utilised equally but nothing i do can

  • Illustrator eps saving problem - this file is in use

    I use Illustrator CS5.1 eps drawings in my Quark 9.3.1.1 files. I've recently been getting a new problem when altering these and saving them while the Q9 document containing the original illustration is open. Illustrator says it can't save as the fil