External Table, Handling Delimited and Special Character in file

Hi ,
I have created one external table with these option
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY ***************************************
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
SKIP 0
FIELDS TERMINATED BY '|'
OPTIONALLY ENCLOSED BY '"'
MISSING FIELD VALUES ARE NULL                                          
LOCATION
( 'test_feed.csv'
Now problem is these are coming as valid.
anupam|anupam2
anupam"test|anupam"test2
"anupam|test3"|test3
anupam""""test5|test5
anupam"|test7
but these are not coming as valid
"anupam"test4"|test4    --> Case when we have quotes in the filed but still have quotes in it. I guess in this case we can send the filed expect closing double quotes.
"anupam|test6   --> In case field is starting with double quotes then it's failing
"anupam"test8|test8"|test8 --> In case one filed contains both pipe ( |) and double quotes then we are sending it enclosed in double quotes. But thats failing the job.
Can you suggest what is the best way to handle such scenario? ( One restriction though. The file is used by other system - Netezza as well, which can't take more than one character long delimited :'( )

One approach is to define the external table a ONE column table (with single field on the file). This way each line will come in as a row in the external table. Of course you have to build "parsing logic" on top of that.
DROP TABLE xtern_table;
CREATE TABLE xtern_table
    c1 VARCHAR2(4000)
  organization external
    type ORACLE_LOADER DEFAULT directory xtern_data_dir
    ACCESS PARAMETERS (
        RECORDS DELIMITED BY NEWLINE
        FIELDS TERMINATED BY '~'   ---- <<<<<<<< Use a field terminator as a character that is not found in the file
        MISSING FIELD VALUES ARE NULL
        ( c1 CHAR(4000)
     ) location ('mycsv.csv')
> desc xtern_table
desc xtern_table
Name Null Type          
C1        VARCHAR2(4000)
> column c1 format A40
> select * from xtern_table
C1                                    
anupam|anupam2                          
anupam"test|anupam"test2                
"anupam|test3"|test3                    
anupam""""test5|test5                   
anupam"|test7                           
"anupam"test4"|test4                    
"anupam|test6                           
"anupam"test8|test8"|test8              
8 rows selected
Ideally, it will be good t have an incoming source file with predictable format.
Hope this helps.

Similar Messages

  • Import over network link fails when table and special character.

    I am trying to do an import over the network link. Below is the command I am using to do the import. In the parameter file the table name has "$" sign. Database is on AIX.
    impdp "'/ as sysdba'" PARFILE=par_aml_aud_import.txt LOGFILE=test.log
    PARFILE:
    JOB_NAME=MONTHLY_XYZ_IMPORT
    NETWORK_LINK=XYZ_IMPORT_LNK
    DIRECTORY=XYZ_AUD_IMPORT
    TABLE_EXISTS_ACTION=TRUNCATE
    REMAP_SCHEMA=XYZ:XYZ_AUDIT
    REMAP_TABLESPACE=XYZ_DATA:XYZ_AUDIT_DATA
    REMAP_TABLESPACE=XYZ_INDEX:XYZ_AUDIT_INDEX
    EXCLUDE=GRANT
    TABLES=XYZ.DR$ABC_EFG_CTC1$N, DR$MNO_PQR_CTC1$N
    I have tested this import with following options.
    on the command line TABLES=\"XYZ\".\"DR\$ABC_EFG_CTC1\$N\" ---- (IN THE PARFILE)
    on the command line TABLES=\"XYZ\".\"DR\$ABC_EFG_CTC1\$N\" ---- (WITHOUT USING PARFILE)
    Still my import fails with below error.
    ======================
    ORA-39166: Object ."DR$ABC_EFG_CTC1$N" was not found.
    ORA-39166: Object ."DR$MNO_PQR_CTC1$N" was not found.
    ORA-39166: Object XYZ was not found.
    ORA-31655: no data or metadata objects selected for job
    Job "SYS"."SYS_IMPORT_TABLE_01" completed with 3 error(s) at 07:46:30
    I had more than 20 tables to import. All the other tables get imported except these tables which have special character. I have confirmed that these tables exists in source database.
    Please advice.
    Thanks
    Shelly

    First hint: don't use as sysdba
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/dp_import.htm#sthref243
    Instead, create a user with (no more than necessary) export and/or import rights
    user7414922 wrote:
    on the command line TABLES=\"XYZ\".\"DR\$ABC_EFG_CTC1\$N\" ---- (WITHOUT USING PARFILE)Try something like tables=xyz.table\$name
    or
    tables='xyz.table$name'
    TABLES=XYZ.DR$ABC_EFG_CTC1$N, DR$MNO_PQR_CTC1$NSecond table should probably have schema qualifier as well.

  • How can an external table handle data with line feed between delimiters?

    I have defined an external table as below. My data is pipe delimited and comes from a DOS system.
    I already remove any carriage returns before putting the file into the DATA_DIR for reading. But
    I have found that some of my VARCHAR fields have embeded line feeds.
    Is it possible to have a definition that would remove any line feed characters between the delimiters?
    Below I also threw together a sample data set there ID #2 has that extra character. Yes, I could
    write an awk script to pre-process all my data files. But I am hoping there is a way for Oracle
    to also do this.
    I understand the LDTRIM to remove any leading and trailing spaces in the delimited field. Is there a
    REPLACE or TRANSLATE option. I did a bit of searching but I must be asking the wrong things.
    Thanks for any help
    Eric
    CREATE TABLE table_ext
      id        NUMBER,
      desc1     VARCHAR2(64 CHAR),
      desc2     VARCHAR2(255 CHAR),
      add_date  DATE
    ORGANIZATION EXTERNAL
      TYPE ORACLE_LOADER
      DEFAULT DIRECTORY data_dir
      ACCESS PARAMETERS
        RECORDS DELIMITED BY NEWLINE
        CHARACTERSET WE8ISO8859P1
        BADFILE     log_dir:'table_ext.bad'
        DISCARDFILE log_dir:'table_ext.dis'
        LOGFILE     log_dir:'table_ext.log'
        FIELDS TERMINATED BY '|' LDRTRIM
        MISSING FIELD VALUES ARE NULL
        id        INTEGER EXTERNAL(38),
        desc1     CHAR(64),
        desc2     CHAR(255),
        add_date  CHAR DATE_FORMAT DATE MASK "yyyy-mm-dd hh24:mi",
      LOCATION( 'data.txt' )
    PARALLEL
    REJECT LIMIT UNLIMITED;
    1|short desc|long desc|2001-01-01 00:00
    2|short desc| long
    desc |1999-03-03 23:23
    3|short desc|  long  desc  | 2011-02-02 02:02

    Thanks for looking. But that relates to the record delimiter which in my case is the pipe character '|'. In my various data sets this is consistent. I expect each record to be one per line. But between two delimiters some data has a line feed. So I'm looking for a method that will "cleanup" the field data as it gets imported.
    I was hoping there was an option that would ignore any embedded line feeds (\n) characters. I.e., those not at the end of the line.
    Eric

  • External Table - Record delimiter

    Hi,
    Is it possible to have combination of character and NEWLINE as a record delimiter in external table. i.e something like RECORDS DELIMITED BY '#^'||chr(10)
    Thanks
    S. Sathish Kumar

    you can always read the manuals
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch12.htm#1007431
    assuming that you mean you have the #^ at the end of the line, then it's just
    RECORDS DELIMITED BY '#^'
    if you mean that you sometimes have #^ in the middle, and only break when it's at the end of the line, then you need to use (on windows)
    RECORDS DELIMITED BY '#^\r\n'

  • Table Maintainence generator Error Special Character '_' in generic key

    Hello,
    I have created a Table which contain 6 fields. All the fields of the table are primary key. The combined length of all the primary key is 163 characters. In the activation Log of the table we have a warning message which states "Key length > 120 (Restricted functionality)". Initially we are able maintain the entries using SM30. BUt now when we are making the entreis in the table an error message comes. The error is Special character "_" in generic key.and we are not able to save the entries.
    I have deleted the table maintainence generator and have regenerated it. But the same error is coming.
    Please provide your suggestion.
    Thanks,
    Mohit

    Please provide your suggestions
    Thanks,
    Mohit

  • External Table : ROW Delimiter

    Hi,
    I am working on an interesting solution that invloves modifying the definitions of External Tables dynamically. I have created a Procedure that alters the delimiters ( ROW and COLUMN ) using Dynamic SQL.
    CREATE OR REPLACE PROCEDURE SP_CHANGE_DELIMITER
         P_RECORD_DELIM     VARCHAR2,
         P_FIELD_DELIM     VARCHAR2,
         P_DEBUG          NUMBER   DEFAULT 0     
    AS
              P_RECORD_DELIM_ VARCHAR2(100):= P_RECORD_DELIM;
              P_FIELD_DELIM_  VARCHAR2(100):= P_FIELD_DELIM;
              sql_          VARCHAR2(4000);
         BEGIN
              IF P_RECORD_DELIM_ IS NOT NULL
              THEN
                   P_RECORD_DELIM_ := ''''||P_RECORD_DELIM_||'''';
              ELSE
                   P_RECORD_DELIM_ := 'NEWLINE';
              END IF;
              IF P_FIELD_DELIM_ IS NOT NULL
              THEN
                   P_FIELD_DELIM_ := ''''||P_FIELD_DELIM_||'''';
              END IF;
              sql_:=
                        ALTER TABLE EXTERN_EMPL_RPT
                        ACCESS PARAMETERS
                             RECORDS DELIMITED BY '||P_RECORD_DELIM_||'
                             FIELDS TERMINATED BY '||P_FIELD_DELIM_ ||'
              IF NVL(P_DEBUG,0) = 1 THEN
                   DBMS_OUTPUT.PUT_LINE(sql_);
              END IF;
              EXECUTE IMMEDIATE sql_;
         END;I am able to dynamically change the Definition of the CLOUM Delimiter using my Procedure :-
    EXEC SP_CHANGE_DELIMITER(P_RECORD_DELIM=> '', P_FIELD_DELIM => '*',P_DEBUG=>1);However, when I try to change the ROW Delimiter, I am getting this error :-
    EXEC SP_CHANGE_DELIMITER(P_RECORD_DELIM=> '|', P_FIELD_DELIM => '#',P_DEBUG=>1);
    SQL> SELECT * FROM EXTERN_EMPL_RPT;
    SELECT * FROM EXTERN_EMPL_RPT
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEFETCH callout
    ORA-30653: reject limit reached
    ORA-06512: at "SYS.ORACLE_LOADER", line 52
    ORA-06512: at line 1I am working with data that looks like this:-
    001 | Sandeep | Seshan
    002 | Seshan   | SandeepIf I try to change this to :-
    001 # Sandeep #  Seshan  |
    002 # Seshan   # Sandeep |I get the ORA-29913 error.
    Can you please help me with this sticky bit ?
    Please do let me know if I need to include more information.
    Thanks,
    Sandeep

    Try increasing reject limit to unlimited!
    ALTER TABLE EXTERN_EMPL_RPT REJECT LIMITED UNLIMITED;

  • Accessing The External Table using UIAPI and DIAPI

    Hi  Every One,
    can any one tell me about , can we access the external table data  that is created by using sql query externally using UIApi and DIAPI
    Regards
    Srinivas

    Hi,
    technically is it possible, but all inserts and updates have to be through query.
    Note, that when you create tables from sdk, you can set more informations about fields than in sql query manager (for example subtype) - so you may have problem in binding data to matrix for example. So if you have table externally, you may work with, but this isn`t allowed by SAP (and I think that this case may be dangerous if you acces it in sdk). If you need to acces it on sql server side (own numbering, some stored procedure, ..) it will works safer, but it is not allowed as well.
    Petr

  • MII 12.0.4 - Problem MessageListener and special character (German) -

    Hey,
    we have the following Landscape:
    + ECC 6.0 with Unicode
    + MII 12.0.4
    Settings on the MessageListener Server:
    gwhost xxxxxxxxx 
    gwserv xxxxxxxxx 
    progid SAP_MII 
    trace   
    params   
    snc_myname   
    snc_qop   
    snc_lib   
    unicode 1 
    max_startup_delay
    Settings on the MessageListener Client:
    client yyy 
    user yyyyyyyy 
    alias_user   
    passwd   
    lang    de
    sysnr xx 
    ashost xxxxxxxx 
    mshost   
    gwhost xxxxxxxx 
    gwserv xxxxxxxxx 
    r3name   
    group   
    tpname SAP_MII 
    tphost   
    type   
    trace   
    codepage  
    abap_debug   
    use_sapgui   
    getsso2   
    mysapsso2   
    x509cert   
    lcheck   
    grt_data   
    use_guihost   
    use_guiserv   
    use_guiprogid   
    snc_mode   
    snc_partnername   
    snc_qop   
    snc_myname   
    snc_lib   
    dest   
    saplogon_id   
    extiddata   
    extidtype   
    idle_timeout   
    dsr
    Error-Description:
    When MII get a Message (RFC) from the ECC, all special character (German Umlaut) coming wrong.
    I tried with changing the Language, codepage... without any success. When I call the same Message
    (RFC) from the BLS through a JCO action block, then the result is with special character. I also tried
    this on a MII 12.0.5 installation without success... Did anybody had this problem one time?
    Kind Regards
    Pedro

    Pedro,
    we are working in an german environment with unicode, although I have set the Message Listener language to EN. I have found some material texts which came down with a MATMAS that contain german umlaute and which are shown correctly inside the database.
    I have also used a "normal" JCo block, no session. I guess it would make no difference using an IDoc or RFC.
    Have you seen the wrong characters, in the MII workbench or in a database where you store the contents?
    Michael

  • Change Password with changePasswordForSelf and Special character

    Hi,
    I was trying to use the OIM (9.1.1.0) API to change the password using:
    userIntf.changePasswordForSelf(oldPassword, newPassword, confirmNewPassword);
    This works when I use some standard password.
    The issue appears when I try to enter certain special character: e.g: < or >
    The error returned is :
    <Error (class Thor.API.Exceptions.IllegalInputException): Thor.API.Exceptions.IllegalInputException>
    Exception is: Thor.API.Exceptions.IllegalInputException
    I reckon this is done to prevent injections.
    I didn't see any restriction in any of Oracle documentation and was wondering if you can help me understanding:
    - if you have observed the same issues before
    - which character are affected by this
    - if there is a work around to allow these character
    Thank you.

    That's because the special characters you are using are the scripting tags and it confuses itself with the OIM scripting process, for instance JSP's etc.
    So I would recommend not to do it and have your policies in place which restricts end-user to have a password with such special characters. I did not tried that but you can possibly do that.

  • Htp.p() and special character

    I am trying to use PL/SQL procedure to present my customized item.
    If user type in secial character, e.g. single quote ', in an attribute, I got this error on the page:
    Error 30584: DBMS_SQL has raised an unhandled exception. ORA-06550: line 1, column 327: PLS-00103: Encountered the symbol "03" when expecting one of the following: . ( ) , * @ % & = - + < / > at in is mod not rem <> or != or ~= >= <= <> and or like between ||
    Is there a procedure I can call to encode the special character? I tried htp.ps() and htf.escape_sc(), however they are not dealing with single quote.
    thanks

    I am using a custom item type to display news and annoucements for my intranet.
    The custom item type has an associated procedure that renders it on the front page of my intranet.
    If the end users enter an apostrophe such as ' . in the title custom item type or the body of the custom item type, I get an error message on the page where the custom item type is displayed, such as
    Error 30584: DBMS_SQL has raised an unhandled exception.
    I tried changing the procedure that formats and displays the custom item type so it replaces the quote for example
    v_description := replace(v_description, '''','ampersand#8217;');
    note i am using the ampersand character and not the word so it posts correctly here, the variable is then used as below .
    <td>'||substr(v_description,1,400)||'..</td> .
    but it does not work.
    Is there anyway of trapping what the user is typing in before it gets put into the database and replacing it with a html special character.
    or is my plsql wrong.
    Any help appreciated.

  • REGEX AND SPECIAL CHARACTER

    Hi guys, I have a problem!!!!
    I am using the java.util.regex.*, when I try use the special character, for example ' \w ' I get a error
    Pattern.compile("\w123\w");
    The compiler return to me that the \w character is not a valide, the output error are:
    "illegal escape character".
    What I need do to put this character in my regular expression and don't get the error?!!?
    Another question, I use the feloow code
    Pattern p = Pattern.compile("isc");
    Matcher matcher = p.matcher("Giscard");
    if(matcher.matches())
       System.out.println("MATCH");
    else
      System.out.println("NOT MATCH");  //The resul is always this, why the regex don't match with my name?Thanks one more time.
    Giscard

    1)
    Pattern.compile("\\w123\\w");To input a single "\" in a Java program you must enter two "\\".
    2) read the javadoc
    matches()
    Attempts to match the entire region against the pattern.
    So "isc" only matches "isc", not "Giscard"
    You need to use find()

  • Script and special character!!

    Hi ,
    while printing address using address and endaddress, i am getting special character > ( ><(><<)> ( ><(><<)> <(><<)> ) > <(><<)>  inserted between ort01 and ort02 field while printing city in the editor in se71 , everytime i remove it it appear again and again....
    anyone faced something similar ....
    Regards
    Gunjan

    Hi
    Check whether your system is Unicde enabled or not?
    Because in Unicode system there is a chance to get such type of Unwanted special characters.
    Reward points for useful Answers
    Regards
    Anji

  • External table fails to view data after changing file name

    Hello,
    I have previously imported 122 external tables and was able to view their data without any problems.
    The names of these files have since changed. The names have a date in them.
    So I dropped the external tables from that database and recreated them with the new file names.
    I then went into OWB and dropped them from OWB.
    I reimported all of the tables without errors.
    I go to view the data and get an error that the file does not exists.
    The problem is that the file it is telling me does not exists, is the file I had been using last week. Not the new file.
    However, when I go and right click the external table and do a configure, the correct name is showing up under datafiles.
    It's almost as though when I dropped the external tables, not everything was cleaned up. For whatever reason, OWB is still using the old names.
    Dan

    Hi there... Wich OWB version are you using?
    If you've created this external tables using any other tool (ie: SQLPLUS, SQLDeveloper, Toad, SQLNavigator, etc), are you able to query this objects from one of these tools?
    If you've created this ET's using OWB, are you creating it as external tables or are you mapping it as source flat files?
    If you are using OWB to create it, there are a few configurations/properties you should change to have them running well.
    Please, post some more info.
    Thanks

  • SAX Parser and special character problem

    Hi,
    Could anyone help with the following problem?
    Background:
    1. Using a SAX Parser (Oracle Implementation) to read XML from a CLOB, convert this XML to another format to be inserted in the database.
    2. Due to performance issues we parse the input stream from the CLOB.
    3. For same reason, we are not using XSL.
    This is the problem we face:
    1. Values of some of the tags in the XML have special characters (Ex: &, <, >).
    2. While using the SAX Parser, the element handler function for the SAX Parser is called by the frame work with the value of these tags broken up with each of these characters being treated as a tag delimiter.
    Ex: <Description>SomeText_A & SomeText_B</Description>
    is treated as SomeText_A in first call to the handler; SomeText_B in the second call.
    The handler function does not get to see the "&" character.
    Thus, the final conversion is
    Say, <Description> is to be converted to <FreeText>
    we, get <FreeText>SomeText_A</FreeText>
    <FreeText>SomeText_B</FreeText>
    We tried using &; but it then breaks it up into SomeText_A, & and SomeText_B.
    How can we get the whole value for the <Description> tag in the characters() function in the SAXParser so that we can convert it to <FreeText>SomeText_A & SomeText_B</FreeText>.
    Thanks in advance..
    Chirdeep.

    We already tried that..looks like the line where I mentioned that it converted the entity referece characters to an ampersand..
    "We tried using <entity reference for &> but it then breaks it up into SomeText_A, & and SomeText_B."
    null

  • External table, fixed columns and variable record length..

    Hi all,
    I'm trying to create an exernal table of a txt-file. Te records are delimited by newlines and the field lengths are fixed. But...
    When one or more of the last columns are missing the record is truncated.
    Here's the problem: the access parameter "missing field values are null" doesn't seem to work here.. And all incomplete lines are rejected!
    Any ideas??

    Well, seems like I was on a wild goose chase here.
    The original version of the file was not in UTF8 but in ANSI. But for some reason somebody thought it was necessary to convert the file to UTF8.
    So, although my question isn't answered yet, my problem has been solved.

Maybe you are looking for