I want to use deafault value in sql loader

hello to all......
i want to insert user tty number ,so i can differentiate the data in the
table...here i am using the deafault key word but it is not work...
can any one give best way?
here is my table tmp
(tmp_field1 CHAR(256),
TMP_TTYNO CHAR(9));
here is my coding to insert int he table...
:global.tmp_ttyno:='1212';
Text_Io.Put_Line(fctl, 'LOAD DATA');
     Text_Io.Put_Line(fctl, 'INFILE '||:fl_name );
     Text_Io.Put_Line(fctl, 'APPEND INTO TABLE tmp' );
     Text_Io.Put_Line(fctl, 'fields terminated by "|" optionally enclosed by '''||'\\'||''' trailing nullcols' );
     Text_Io.Put_Line(fctl, '(' );
     Text_Io.Put_Line(fctl, 'tmp_field1 CHAR(256)' );
----->>>> Text_Io.Put_Line(fctl, 'TMP_TTYNO CHAR(9),DEFAULT='||:global.tty_no );

You have asked this question in the forum reserved to discuss issues with downloadiung or obtaining Oracle software. I am not quite sure how your question relates to the forum.
You might want to check the Database - General forum

Similar Messages

  • Using constant values in SQL Loader control file

    Hi,
    I have a requirement where I need to migrate the data of 6 tables from MS Access into Oracle data base. I have written SQL Loader scripts so that I can create CSV files based on MS Access data and then migrate into Oracle. But in Oracle tables we have 4 common columns like Create_By, Created_Date,Updated_By and Update_Date, and those fields should be taken care by system. So, basically system should update login user ID and sysdate values in respective columns. My question here is, I do not have above mentioned common columns in MS Access tables. So, can I hard code those values in control file by saying
    Created_By CONSTANT user,
    Create_Date CONSTANT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS'),
    Updated_By CONSTANT user,
    Updated_Date CONSTANT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS')
    Please let me know your valuable suggestions.

    You do it without it constant
    --sample data file
    1,2,,
    3,4,,
    LOAD DATA
    INFILE 'D:\d.csv'
    INTO TABLE ABC
    FIELDS TERMINATED BY ","
    ( A,
      B,
      C sysdate,
      D "USER"
    )Edited by: J99 on Jul 23, 2009 12:14 PM
    OR use to avoid extra ',' in datafile.
    --sample data file
    1,2
    3,4
    LOAD DATA
    INFILE 'D:\d.csv'
    INTO TABLE ABC
    FIELDS TERMINATED BY "," TRAILING NULLCOLS
    ( A,
      B,
      C sysdate,
      D "USER"
    )

  • How to use Conditional statements in SQL Loader control file

    Hi,
    I am using sql loader to load a flat file to the table. I am using control file for this purpose as show below:
    LOAD
    INTO TABLE store_shrink
    TRUNCATE
    FIELDS TERMINATED BY "     "
    TRAILING NULLCOLS
    SITE_ID char,
    ST_SHRINK char,
    ST_REVENUE char,
    SHRINK_PR char ":ST_SHRINK/:ST_REVENUE"
    My question is this. If in the flat file the value of 'ST_REVENUE' is '0', then I want 'SHRINK_PR' to be '0' as well, and skip the calculation (:st_shrink/:st_revenue).
    How to achieve this with the conditional statement or using any Oracle function?
    Any help or suggestion is greatly appreciated.
    Thanks in advance.

    Hi there,
    I tried the following in my above query and it doesn't work somehow. Anyone has an idea? I have been on internet throughout but to no avail. Please help:
    LOAD
    INTO TABLE store_shrink
    TRUNCATE
    FIELDS TERMINATED BY "     "
    TRAILING NULLCOLS
    SITE_ID char,
    ST_SHRINK char,
    ST_REVENUE char,
    SHRINK_PR char "case (when :st_revenue<>'0.00' then :SHRINK_PR=:ST_SHRINK/:ST_REVENUE else :SHRINK_PR='0.00') end"
    )

  • 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.
    ==========================================

  • Using User function in SQL*Loader

    Hi, I have created the following control file. I am using DIRECT path insert. I am using a function to retrieve the column system_date. However, when I am running sql*loader, the fields system_date and load_date are loaded with null value.
    OPTIONS (ERRORS=999999999, DIRECT=TRUE, ROWS=100000, SKIP=1)
    LOAD DATA
    INFILE 'Z:\xx.csv'
    APPEND
    PRESERVE BLANKS
    INTO TABLE TB_RAW_DATA
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    REFERENCE_NUMBER,     
    SYSTEM_DATE "pkg_ken_utility.Fn_ken_get_param_value('SYSTEM_DATE','SYSTEM_DATE')",
    LOAD_DATE "SYSDATE"
    )

    No,
    You can not call PL/SQL functions in DIRECT PATH mode, also this is documented, so you should not need to ask.
    Sybrand Bakker
    Senior Oracle DBA

  • Using oracle sequence in SQL Loader

    I'm using oracle sequence in control file of sql loader to load data from .csv file.
    Controlfile:
    LOAD DATA APPEND
    INTO TABLE PHONE_LIST
    FIELDS TERMINATED BY "," TRAILING NULLCOLS
    PHONE_LIST_ID "seqId.NEXTVAL",
    COUNTRY_CODE CHAR,
    CITY_CODE CHAR,
    BEGIN_RANGE CHAR,
    END_RANGE CHAR ,
    BLOCKED_FREE_FLAG CHAR
    Datafile:
    1516,8,9,9,B
    1517,1,1,2,B
    1518,8,9,9,B
    1519,8,9,9,B
    1520,8,9,9,B
    1521,8,9,9,B
    1) As first column uses oracle sequence, we have not defined that in datafile.
    This gives me error "Can not insert NULL value for last column"
    Is it mandatory to specify first column in datafile, even though we are using sequence?
    2) Another table is referencing PHONE_LIST_ID column (the one for which we using sequence) of this table as a foreign key.
    So is it possible to insert this column values in other table simultaneously? Sequence no. should be same as it is in first table...
    Kindly reply this on urgent basis....

    use BEFORE INSERT trigger
    with
    select your_seq.nextval into :new.id from dual;

  • Filtering column values in sql loader control file

    Hi all,
    i have a file that contains data such as
    111 Test ####### #testme juio# ###
    as you can see, the data is fix length and separate by spaces
    some field will have value such as ### and some column will contain alpha numeric with some # such as juio#
    i am trying to write a ctl file that read the data using position. ex position 1-3 will get 111 and 4-8 for example gets Test and so on.
    what i am trying to do is when a column value contain all # then i want to set to null. if a value contain alpha-numeric and # then load that value
    ex. ####### will translate to null. #testme will be load it as it is since it contain alphanumeric
    can someone help me write a ctl file that read the field by position and apply null to value that contain all #. again, if a field contain # and alphanumeric such as juio#, then that value should be loaded as is. it is only when the value contain all # it should be set to null
    Th

    You do it without it constant
    --sample data file
    1,2,,
    3,4,,
    LOAD DATA
    INFILE 'D:\d.csv'
    INTO TABLE ABC
    FIELDS TERMINATED BY ","
    ( A,
      B,
      C sysdate,
      D "USER"
    )Edited by: J99 on Jul 23, 2009 12:14 PM
    OR use to avoid extra ',' in datafile.
    --sample data file
    1,2
    3,4
    LOAD DATA
    INFILE 'D:\d.csv'
    INTO TABLE ABC
    FIELDS TERMINATED BY "," TRAILING NULLCOLS
    ( A,
      B,
      C sysdate,
      D "USER"
    )

  • Use of WHEN in SQL Loader Control File

    Does anyone know of a way, using the CTL file below, to NOT LOAD (i.e. discard) any record where field G is null -OR- substr(G,1,3)='CON'+ (the first 3 characters of field G are "CON")?
    The WHEN clause seems very limited in what it can test and all my attempts to use a compound condition, much less the SUBSTR function, have failed. The documentation indicates that only very simple conditions can be specified.
    (Oracle 10g, Unix)
    Thanks
    LOAD DATA
    TRUNCATE
    INTO TABLE TEST_TABLE
    WHEN (G <> '')
    FIELDS TERMINATED BY "^"
    TRAILING NULLCOLS
    A ,
    B FILLER,
    C FILLER,
    D FILLER,
    E FILLER,
    F FILLER,
    G "LTRIM(:G,'0')",
    H FILLER,
    I FILLER,
    J FILLER,
    K SYSDATE,
    L CONSTANT "SQLLDR"
    )

    Hello MTM.
    The WHEN clause in SQL*Loader, despite what you might read, doesn't seem to evaluate the value of the column you specify after SQL clauses are processed. Therefore, the only way you can guarantee to NOT LOAD a record is by using a function to raise an application error when the column data meets your criteria. You'll need to do some basic comparisons between bad data and discarded data in the bad data file to isolate these.
    You can still discard the null data using (replace ne with greater and less than)WHEN (g ne '')Hope this helps,
    Luke
    Please mark the answer as helpful or answered if it is so. If not, provide additional details.
    Always try to provide create table and insert table statements to help the forum members help you better.

  • Index is unusable after using Direct path of SQL Loader

    When using the Direct path of SQL Loader to load records from a comma(,) seperated file into a table, the index which I specify the records are sorted in becomes unusable. In the log file created by SQL Loader the error: "ORA-01409: NOSORT option may not be used; rows are not in ascending order" occurs. I am pre sorting the data in the order of the index, the index is a multi column index. The index and table prior to initiating SQL Loader are not empty and contain existing records.
    Can anybody suggest a reason as to why this is happening even thought I am pre sorting the data in ascending order as per the index?
    Brad.

    Thanks for reply Gerald!
    After further investigation I kind of answered my own question and found that the data I was loading was not in the order that Oracle was expecting. The problem stems from how the UNIX command SORT works compared to how data is ordered by in Oracle by the ORDER BY statement. I was using UNIX's SORT command to pre sort my data before loading it directly into Oracle.
    UNIX's SORT seems to order Null's before anything else in ascending order, where as Oracle's ORDER BY order's Null values last for ascending order!
    I got around this by putting in my pre-sorted data the highest printing ASCII character when ever a field was Null. The highest printing ASCII character is 'tilde' (~). As UNIX's SORT uses the ASCII collating sequence to determine the sort order the post-sorted data was sorted as per Oracle expected. And to not actually load up "~" into my Oracle table I just specified in the SQL*Loader control file for these fields, NULLIF (field_name = "~").

  • How to use nvl() function in SQL Loader

    I am trying to use nvl() funtion in my SQL Loader control file and I keep geting errors. Would someone please tell me where I can find the syntax reference to this?
    Thanks a lot!

    I just answered a similar question like this last Thursday.
    SQL*LOADER how to load blanks when data is null

  • Using passed values in SQL statements

    Using Adobe Livecycle Designer 7, we wish to populate a pdf document with values from a MS SQL database. The values will change depending on the ID of the record called for.
    We can already populate the form using SQL (SELECT firstname FROM names WHERE id = 1), but we need to populate it based on a 'passed' value in a url (http://www.mysite.com/mypdf.pdf?id=1).
    When we try to include this into the SQL (SELECT firstname FROM names WHERE id = request.id) we get an error. Could anyone provide us with the correct syntax that will allow us to populate the form based on the ID passed in a URL?
    Many Thanks
    Craig

    Hi all of you,
    I do have a problem with coding correctly a form I am designing sing the Adobe Livecycle . In one of the field, there is an underlying field that when you exit the first name field or the Middle Initial field or the last name, it should all pass the respective values to the underlying field which becomes visible on printout. I do have this code I wrote on the exit event, but do not understand why it it not working. Please, can anyone tell me why it is not working or help me out on a better way of making it work.
    xfa.host.messageBox("Check this");
    if (EMPFNAME.rawValue <> " " ){
    xfa.host.messageBox("EMPFNAME");
    EMPNAME.rawValue = String(EMPFNAME.rawValue) + " ";
    if (EMPFNAME.rawValue <> " " )&&(EMPMI.rawValue <> " "){
    EMPNAME.rawValue = String(EMPFNAME.rawValue) + " " + String(EMPMI.rawValue) + ".";
    var s = EMPMI.rawValue;
    EMPMI.rawValue = s.toUpperCase();
    if (EMPFNAME.rawValue <> " " )&&(EMPMI.rawValue <> " ")&&(EMPLNAME.rawValue <> " "){
    EMPNAME.rawValue = String(EMPFNAME.rawValue) + " " + String(EMPMI.rawValue) + "." + " " + String(EMPLNAME.rawValue);
    var s = EMPMI.rawValue;
    EMPMI.rawValue = s.toUpperCase();
    Thanks
    Lucky P

  • Use javascript value in SQL report

    Hello,
    I'm trying to do a report that must use the windows username as a filter. Something like
    select *
    from audit
    where username = WINDOWS_USERNAME.
    I have this code that retrieves it from the system
    <script language="Javascript">
    var WshNetwork = new ActiveXObject("WScript.Network");
    var userName;
    function getUsername(){
    userName = WshNetwork.UserName;
    return userName;
    Does anyone know how can I use it?
    Another possibility is having a application item that is populated in the onLoad event. Help please!

    I'm going to show you how I implemented my solution:
    I have in the login page a html region with the following code:
    <script language="Javascript">
    var WshNetwork = new ActiveXObject("WScript.Network");
    html_GetElement('P111_USERNAME').value = WshNetwork.UserName;
    document.write('<b>'+html_GetElement('P111_USERNAME').value+'</b>
    </script>When the user clicks the button I have a computation that sets a application item with the value of the P111_USERNAME hidden field.
    In all the others pages I reference the application item and it has the correct value.
    Your errors should be because you are declaring the ActiveX object outside the function. Or it's just a security limitation of your IE.
    Message was edited by:
    Reise

  • Using Bulk insert or SQL Loader in VB6

    Hi,
    I am quite new to the Oracle world and also forums. But I am looking for some directions in how i get a dataset of 10000 records into a table the quickest way. I have the recordset in an ADO Recordset (or a textfile if that is easier) and I want to insert them in an empty Oracle table. The problem is - I don't know how to.
    Situation
    The Oracle DB is on another computer I have nothing special installed on the computer running the VB6 application.
    Can anyone please provide code example or guidelines...
    Regards,
    Christian

    This may not be "bulk insert" by your definition, but it can transfer data as you want.
    A simple VB code for demo purpose:
    Dim con As New ADODB.Connection
    Dim con2 As New ADODB.Connection
    Dim rst As New ADODB.Recordset
    Dim rst2 As New ADODB.Recordset
    Dim rst3 As New ADODB.Recordset
    con.ConnectionString = "Provider=OraOLEDB.Oracle.1;User ID=scott;Password=tiger;Data Source=db_one;"
    con.Open
    rst.Open "select * from dept", con, adOpenDynamic, adLockOptimistic
    'save to a file using ADTG format. You may choose other format.
    rst.Save "c:\myfile.txt", adPersistADTG
    'dept2 is an empty table with the same table definition as dept. You can create it using SQL*Plus.
    'add rows by reading from the saved file.
    con2.ConnectionString = "Provider=OraOLEDB.Oracle.1;User ID=xyz;Password=xyz;Data Source=db_two;"
    con2.Open
    'open the saved file
    rst2.Open "c:\myfile.txt"
    'rst3 is an empty recordset because dept2 is empty at this time.
    rst3.Open "select * from dept2", con2, adOpenDynamic, adLockOptimistic
    'adding rows into dept2.
    Do Until rst2.EOF
    rst3.AddNew Array("deptno", "dname", "loc"), Array(rst2.Fields("deptno"), rst2.Fields("dname"), rst2.Fields("loc"))
    rst2.MoveNext
    Loop
    rst.Close
    rst2.Close
    rst3.Close
    con.Close
    con2.Close
    Sinclair

  • How to use 'REQUEST' value on PL/SQL

    Hi All,
    I have assigned 'SEARCH' as button request to search button. I want to use this value in PL/SQL some thing like
    IF REQUEST='SEARCH' THEN
    --do something
    ELSE
    --do something else
    END IF;
    Can any one suggest how to access the 'REQUEST' value?
    Thanks in advance.
    Regards,
    Hari

    Hi rchalton!
    Sorry for that. Here is an english document which also shows an example of how to use v('REQUEST') or :REQUEST.
    [http://download.oracle.com/docs/cd/E14373_01/appdev.32/e11838/concept.htm]
    regards
    Edited by: Florian W. on 06.04.2009 15:35
    I've also tried to translate this link from german into english with google and it worked very good.

  • Af:inputFile componet - want to use class oracle.sql.BLOB instead

    Hi,
    I want to use the class oracle.sql.BLOB to get a blob from an input field. Can I use another ADF component instead of the af:inputFile component?
    According to this site: http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/jsf/doc/apidocs/oracle/adf/view/faces/component/core/input/CoreInputFile.html - The "value" property of an inputFile component will be set to an instance of the oracle.adf.view.faces.model.UploadedFile class.
    From the Oracle JDeveloper 10g (10.1.3) Documentationdocumentation:
    UploadedFile file = (UploadedFile) event.getNewValue();
    //Here's where we could call file.getInputStream()
    I don't want to use getInputStream().
    I am working with JDev, oracle ADF, and Toplink.
    Any help is appreciated.
    Lin

    Hi,
    http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html
    Example 85
    http://otn.oracle.com/products/jdev/tips/muench/uploadedfiletoblob/UploadedFileToBlob.zip
    Frank

Maybe you are looking for