Defaulting values SQL Loader

Hi All ,
  I have a use case in sql loader where in i have two columns A and B in a Table.
   My Use case for control file is to get B from csv ( which is a mandatory column)  . A is optional in CSV . if A is populated take that value for A . If not default if from B.
  Thing i have tried is :
B                        ,    
A  EXPRESSION : "NVL( :A, :B) " ,
This is failing saying that
Invalid bind variable A in SQL string for column A.
Any ideas ? I know we could define a function. . But any better way to do with control files itself ?
Thanks,
Bibin

Remove the word EXPRESSION.
SCOTT@orcl12c> host type test.csv
bval1,aval1,
bval2,,
SCOTT@orcl12c> host type test.ctl
load data
infile test.csv
into table a_table
fields terminated by ','
trailing nullcols
(b,
a "nvl (:a, :b)")
SCOTT@orcl12c> create table a_table
  2    (b  varchar2(5),
  3     a  varchar2(5))
  4  /
Table created.
SCOTT@orcl12c> host sqlldr scott/tiger control=test.ctl log=test.log
SQL*Loader: Release 12.1.0.1.0 - Production on Fri Nov 15 13:46:40 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.
Path used:      Conventional
Commit point reached - logical record count 2
Table A_TABLE:
  2 Rows successfully loaded.
Check the log file:
  test.log
for more information about the load.
SCOTT@orcl12c> select * from a_table
  2  /
B     A
bval1 aval1
bval2 bval2
2 rows selected.

Similar Messages

  • DFF default value - SQL Statement

    Hi Friends,
    I have a mandatory DFF segment on the Sales Order Header and I want to default a value in that segment only for a specific Order Type, not all.
    So, When I create a US Order Type, it should default from a value set and the value will be "00000", which is the default value in the value set.
    For all other Order Types, it should not default and the user has to select it. How can I write the SQL for this. Thanks.

    Hi,
    Typically, this is possible only if you make use of DFF contexts.
    But using context from each order type is not a good idea.
    Why dont you use a personalization that would populate ATTRIBUTEx on the data block if the condition based on order type is true?
    If the form is coded correctly, the value will get defaulted into respective column.
    Thanks,
    Hrishikesh

  • Personalization default-value with readonly (p13n)

    Hello,
    I have a simple application with a field. I'm starting the application sap-config-mode=X and would like set an inputfield with a default-value and as readonly.
    I'm tiping in the inputfield (e.g. "XXX") and start the personalization via right mouse click.
    Value: Specify Default
    Read-Only Access: Yes
    If I close the window, the field is readonly and filled with "XXX".
    But, If I restart the application the field is readonly and empty.
    It's a bug or a feature?
    If I set the Read-Only Access = No Personalized and restart the application the default value was loaded.
    Thanks

    Hi,
    the value "XXX" should ideally be saved as a default in the input field.
    it would be saved under implicit personalization.
    I have alternatively suggested a way which would come under explicit personalization.
    You can monitor the same by running the application of "WD_ANALYZE_CONFIG_USER" web dynpro component and enter youe username and you can view what data is personalized against the entered username.
    Regards
    Anurag Chopra

  • How to load a default value in to a column when using sql loader

    Im trying to load from a flat file using sql loader.
    for 1 column i need to update using a default value
    how to go about this?

    Hi!
    try this code --
    LOAD DATA
       INFILE 'sample.dat'
       REPLACE
       INTO TABLE emp
       empno   POSITION(01:04) INTEGER EXTERNAL NULLIF empno=BLANKS,
       ename   POSITION(06:15)  CHAR,
       job         POSITION(17:25)  CHAR,
       mgr       POSITION(27:30)  INTEGER EXTERNAL NULLIF mgr=BLANKS,
       sal        POSITION(32:39)  DECIMAL EXTERNAL NULLIF sal=BLANKS,
       comm   POSITION(41:48)  DECIMAL EXTERNAL DEFAULTIF comm = 100,
       deptno  POSITION(50:51)  INTEGER EXTERNAL NULLIF deptno=BLANKS,
       hiredate POSITION(52:62) CONSTANT SYSDATE
      )-hope this will solve ur purpose.
    Regards.
    Satyaki De.

  • SQL Loader, nested tables and default values

    Is there a way to specify a default value for a nested table entry when SQL*Loader encounters a 'null' value?
    I want to avoid this:
    Record 5: Rejected - Error on table LEVEL_DESC, column LEVELS.
    NULL nested table element is not allowed

    Use the NULLIF parameter in your control file for the nested table objects.
    e.g
    LOAD DATA
    INFILE 'level_data.dat'
    INTO TABLE LEVEL
    (LEVEL_ID POSITION (01:05) CHAR
    LEVEL_NAME POSITION (07:20)
    LEVEL_DESC COLUMN OBJECT
    (LEVELS POSITION (22:25) CHAR NULLIF LEVEL_DESC.LEVELS=BLNAKS,
    ... ))

  • SQL Loader- Default value is not inserted in table by direct method

    Hi All,
    I am trying to load data from a file to a table by SQL Loader. There is a particular date column which I am not loading from the File but have used a Default constraint to put SYSDATE in it. When I am using direct method load then it is not inserting nothin in this column but in conventional method it is inserting SYSDATE. But I want to do the load by direct method. Can anybody provide me a solution as how to load default value in direct method?
    Thanks & regards.
    Sudipta

    For this special case, you can specify:
    column_name SYSDATE
    in your SQL*Loader control file.

  • Defaulting org id value into a table through SQL Loader program

    Hi ,
    We have a requirement that we need to load some data from flat file to a table.we are using sql loader to do that. so far no problem but now the requirement is that we need to populate the org id from which we are running the program.
    I tried fnd_profile.value('ORG_ID') and it is populating site level org id.
    Coudl any one please help me how to default org id or request id into a table through sql loader program.
    Thanks,
    Y

    user12001627 wrote:
    Hi Srini,
    Thanks for looking into this!!
    We are on EBS 11.5.10 and OS is solaris.
    I tried fnd_profile,fnd_global but no luck.
    Here is the control file which we are using to load data.
    load data
    infile *
    replace into table XXXX_YYYY_STAG
    trailing nullcols
    (line POSITION(1:2000)
    I would like to populate org id when I load the data from file.unfortunately there is no identifier in the file that says for which org id the data is in the file.Only the way to identify the file org is based on file name
    Where do you want to populate the ORG_ID ? There is no column for it in your stage table above
    Is there way we can pass through concurrent program parameters?
    Thanks
    YHTH
    Srini

  • SQL Loader needs to load default value instead of null

    I am loading data from the flat file into the table. The table primary key consists of 5 fields. One of these fields might be empty in the text file, so on the load I need to substitute it with some default value like "***", for instance. Is there any way to make some conditions in the control file?

    You can either make use of the suggession given by Warren Tollentino or alter table by adding default constraint for the column.

  • Setting a Default Value in SQL Query Report

    Hello:
    We are using a SQL Query Report to provide a mass update to a table. We are using the apex.collection and having it display a number of records in a SQL Query Report for mass update. We have 14 columns in the report, for which the first 11 are populated via the collection. The remaining 3 are open for input but the individual making the updates. We've were able to provide a default value for 2 of the remaining 3 columns using a named LOV's - however the fourth column we would like to default a sysdate - but we are not successful.
    We've attempted many things but none seem to work, including adding that column to the collection and assigning it a default sysdate value. We've also tried changing the settings in the report attributes --> Tabular Form Elements by setting the Display as to: Datepicker, Default type to PL/SQL Expression and setting the default to sysdate. We've also tried caputuring a date on the previous page and loading it onto the report page and trying to default the date column to a page item default.
    I'd appreciate any help.
    Thanks
    FYI - we are using version 3.2

    use as default
    to_char(sysdate, 'dd/mm/yyy') where the format is your application or item date format

  • Spaces value in sql loader

    Is there a way to load in spaces using Sql*Loader given that the table it is loading to has a not null column but has a default value. My data file has spaces for a number field instead of zeros. Since my table column is declared as not null, it's failing even if I have a default value of '0' in my column.

    You can tackle this in the control file. Here is a snippet from Oracle OnLine books - hopefully this will help out! Cheers.
    ==========================================
    Setting a Column to Null or Zero
    If you want all inserted values for a given column to be null, omit the column's specifications entirely. To set a column's values
    conditionally to null based on a test of some condition in the logical record, use the NULLIF clause; see NULLIF Keyword. To set a
    numeric column to zero instead of NULL, use the DEFAULTIF clause, described next.
    DEFAULTIF Clause
    Using DEFAULTIF on numeric data sets the column to zero when the specified field condition is true. Using DEFAULTIF on
    character (CHAR or DATE) data sets the column to null (compare with Numeric External Datatypes). See also Specifying Field
    Conditions for details on the conditional tests.
    DEFAULTIF field_condition
    A column may have both a NULLIF clause and a DEFAULTIF clause, although this often would be redundant.
    Note: The same effects can be achieved with the SQL string and the DECODE function. See Applying SQL Operators to
    Fields
    NULLIF Keyword
    Use the NULLIF keyword after the datatype and optional delimiter specification, followed by a condition. The condition has the same
    format as that specified for a WHEN clause. The column's value is set to null if the condition is true. Otherwise, the value remains
    unchanged.
    NULLIF field_condition
    The NULLIF clause may refer to the column that contains it, as in the following example:
    COLUMN1 POSITION(11:17) CHAR NULLIF (COLUMN1 = "unknown")
    This specification may be useful if you want certain data values to be replaced by nulls. The value for a column is first determined from
    the datafile. It is then set to null just before the insert takes place. Case 6: Loading Using the Direct Path Load Method provides
    examples of the NULLIF clause.
    Note: The same effect can be achieved with the SQL string and the NVL function. See Applying SQL Operators to Fields.
    Null Columns at the End of a Record
    When the control file specifies more fields for a record than are present in the record, SQL*Loader must determine whether the
    remaining (specified) columns should be considered null or whether an error should be generated. The TRAILING NULLCOLS
    clause, described in TRAILING NULLCOLS, explains how SQL*Loader proceeds in this case.
    ==========================================

  • Calculate timestamp filed using sql default value

    I am using jdeveloper 11.1.2
    I have entity with two Date fields in it and one number field called PERIOD
    first field is "PLAN_APPROVED_DATE"
    second is "WORK_DUE_DATE"
    workDueDate value is PLAN_APPROVED_DATE+ PERIOD
    in the workDueDate field I defined the default value as "SQL" and this is my sql
    SELECT TO_TIMESTAMP(add_months(PLAN_APPROVED_DATE,TA_SCI.PERIOD), 'DD-Mon-RR HH24:MI:SS.FF') from TA_SCI
    when I run my application module tester i hae this error
    oracle.jbo.AttributeLoadException: JBO-27021: Failed to load custom data type value at index 56 with java object of type oracle.jbo.domain.Number due to java.sql.SQLException.
    Caused by: java.sql.SQLException: Invalid column index

    You may some additional details here: Is this a bug in Jdeveloper 11g (11.1.2.1.0)

  • Setting a default value for SQL based LOV

    Hi There,
    Is there a way to set the default value in an LOV. Like lets say the LOV gets distinct to_Char(date_field,'YYYY') from a table. I want that the highest year is the default value. Currently, since I have the null option also, when the page loads, the lov is always null. I need to change it manually.
    Thanks,
    Sun

    You can easily set the dynamic item defaults
    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21674/bldapp_item.htm#HTMDB28287
    for example select the default type as PL/SQL Function Body and enter the following code
    declare
    v_return date;
    begin
    select max(date_field) into v_return from your_table;
    return to_Char(v_return,'YYYY');
    exception when others then
    return null;
    end;

  • How to Get Default Value of a Data Type in SQL Query.

    Hi all,
    I am creating a procedure which will take input the table name and Column Name.
    In the Output i would like to have the data type and default value of that data type which will be used by a another procedure to blank the selected column in the database.
    I tried with SET NULL on the column but as the database is of navision the table have property set to NOT NULL.
    Here is what i have done till now.
    Create Procedure Get_Column_type
    @parm_table_name nvarchar(200),
    @parm_column_name nvarchar(20),
    @parm_result nvarchar(20)OUTPUT
    AS
    BEGIN 
    select @parm_result =
    DATA_TYPE from INFORMATION_SCHEMA.COLUMNS IC
    where TABLE_NAME = '[' + @parm_table_name +']' and COLUMN_NAME = '[' + @parm_column_name + ']'
    END
    GO
    Now instead on write a case statement for so many data types in SQL, i was thinking is it possible someway that above procedure also returns the default value which i can set in another procedure.
    Let me know if its possible or not? Thanks in advance.

    Do you looking for something like this?
    create table t10 ( c int default 1)
    SELECT so.name AS table_name, 
              sc.name AS column_name, 
              sm.text AS default_value
         FROM sys.sysobjects so
         JOIN sys.syscolumns sc ON sc.id = so.id
    LEFT JOIN sys.syscomments SM ON sm.id = sc.cdefault
        WHERE so.xtype = 'U' 
          AND SO.name = 't10'
     ORDER BY so.[name], sc.colid
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Is it possible to define default value of a variable in sql scripts

    Hi,
    I was thinking of a way to assign a default value to a variable without any prompt by the script as we do in shell script.
    To make my query more clear, consider the example.
    suppose we have a sql script like test.sql with contents
    ===========================================
    define x=&1
    declare
    x1 number;
    begine
    x1:=nvl(&x,10);
    dbms_output.put_line(x1);
    end;
    ===========================================
    even though I am using nvl it will prompt for value of 1 which needs user interference. for example if I run test.sql output is as below:
    =============
    SQL> @test
    Enter value for 1:
    10
    =============
    Is there any way to avoid sql from prompting for values of variables for which we want it to take a default value (if not specified as input argument)
    Thanks
    now if i run this as
    sql>@test 10
    it executes

    I wan't to accept the value as command line argument. say the whole statement is written into an sql file say test.sql so that &1 will hold any value specified as input.
    So the issue is although sql will execute the procedure if no value is specified but it will still prompt once for any variable (&x or &1). if you don't specify anything and just press enter than only the default value is taken.
    I wan't the script to be executed on cron without user interference. So, was looking if there's a way to specify default value for cron script.

  • Loading a default value to a text  field

    Hi All...
       I  have some input fields say account no.. , i want that these input fields should be loaded with default values. How can i specify default values to these input fields.
    Plz help...

    hi bichoo..
              all your input fields would be bound to different attributes..... for every attribute you have an option called default value... in the context... you can make use of that...
                   or
               in the wddoinit method, you  can pass teh values to these attributes dynamically using set_attribute method.
    ---regards,
       alex b justin

Maybe you are looking for

  • Which fico plan to order

    I know CreditKarma is Fako score , but why would my score drop 23pts when my opensky secured card just landed on my report july1? my util is only at 12% and opensky doesnt do a hardpull on my credit...im going to breakdown and order the myfico monito

  • Permissions Question

    Hello, I am consistently getting this return on my permissions: Started verify/repair permissions on disk disk0s2 Macintizzle HD Permissions differ on "private/var/log/secure.log", should be -rw------- , they are -rw-r----- Group differs on "private/

  • PDF fies stopped opening online

    the phone was working normally but few days back i was trying to open the attachments (PDF) file from the emails with no action. I tried downloading the attachments to open it offline but also not opened. I opened the Adobe Reader to open the downloa

  • Submit Button in adobe interactive form

    Hi All, Anyone have step by step how to use SUBMIT button in adobe interactive form? The scenario is: I am using ABAP Program (SE38) to display the form, then user will enter value some required fields in the form. After user klik SUBMIT button in th

  • Inner Joins vs For All Entries - performance query

    Hi All, I'm a bit confused here...  I see lots and lots (and lots...) of postings from people asking how to get data from multiple tables. To me the immediate answer is to use joins in my select statement to reduce the database load but more and more