Files with pipe lines

I have written a package which imports data into my database from a file whose information is delimited by pipes. I use a function that separates the data delimited by the pipes and treats it like different information as Name, Surname, Age, Location.
Below the example(1):
Paul|Simon|33|Scotland
Rachel|Smith|28|EnglandThe package compiles correctly, but when I debug it, it erros with the following:
Oracle Error :: ORA-06533
Subscript beyond countI have noticed that if I add a pipe at the end of each line, the error does not occur and everything gets imported as I want it to.
Example(2):
Paul|Simon|33|Scotland|
Rachel|Smith|28|England|Unfortunately, the files comes in from an external source and cannot be modified with the extra pipe.
Can anyone suggest a way to fix this issue, please?
Thanks
PS: I am using collections.
The split function was found on this website http://www.orafaq.com/forum/t/11692/0/ in the last reply from Barbara Boehmer

If I use external tables, I suppose I can point the
second part of the package to the external table and
do the upload from there?Yes, of course, did you already use external tables ? See this example :
$ cat names.dat
Paul|Simon|33|Scotland
Rachel|Smith|28|England
$ sqlplus test/test
SQL*Plus: Release 10.2.0.3.0 - Production on Sun Nov 25 23:05:46 2007
Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
TEST@db102 > CREATE TABLE ext_tab (
  2  name       varchar2(20),
  3  surname    varchar2(20),
  4  age        number,
  5  location varchar2(30)
  6  )
  7  ORGANIZATION EXTERNAL
  8  ( TYPE ORACLE_LOADER
  9  DEFAULT DIRECTORY work
10  ACCESS PARAMETERS ( RECORDS DELIMITED BY NEWLINE
11  fields terminated by '|'
12  )
13  LOCATION ( 'names.dat' ))
14  REJECT LIMIT UNLIMITED
TEST@db102 > /
Table created.
TEST@db102 > select * from ext_tab;
NAME                 SURNAME                     AGE LOCATION
Paul                 Simon                        33 Scotland
Rachel               Smith                        28 England
TEST@db102 >

Similar Messages

  • How To Run An External .exe File With Command Line Arguments

    Hiya, could anyone tell me how I can run an external .exe file with command line arguments in Java, and if possible catch any printouts the external .exe file prints to the command line.
    Thanks.

    Using the Runtime.exec() command. And read this:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Import biar file with command line

    Hi
    I am trying to import biar file with command line on unix environment with BOXI R3.1 and Oracle DB
    The biar file include one universe and it's connection (eFashion), one report and one user
    when I run the command line:
    java -jar /BO/boxi/bobje/java/lib/biarengine.jar /BO/boxi/test.properties
    I recive the following error:
    Failed to commit objects to server : Undefined Info Store error
    An error occurred at the server during security batch commit:
    Request 6 of type 36 failed with server error : Object not found (1433)
    Request 11 of type 36 failed with server error : Object not found (1433)
    Request 20 of type 38 failed with server error : Object not found (1433)
    Request 26 of type 38 failed with server error : Object not found (1433)
    Do you have any idea , what is the problem?
    Thank you

    Hi Denis
    I found out after I create a biar file ,with only the user, through a command line. that the user did import since it was in a concurrent connectiontype , a type that not exit in the target environment.
    But after I fix this in the source environment and saw that a biar file with only the user is loaded , I recreate the biar file with all the objects as before (user, universe, report , folder) and I still got the same error message as before.
    So now I try to create the biar file with all those object through the command line. and I get a new errer message "Required dependencies not found on target system : '[AZK_.9sbf_lMgdQRpsbZfVw]"
    I check it , and understand that the object is the report , but I do not see what missing..... : (
    Those are the quries in the properties file:
    exportQuery= SELECT * FROM CI_APPOBJECTS where si_kind = 'Universe' and si_name='eFashion'
    exportQuery= SELECT  * FROM CI_APPOBJECTS WHERE SI_ID in ( 894,926)
    exportQuery= SELECT * from CI_SYSTEMOBJECTS WHERE SI_KIND = 'user' and SI_Name='repadmin'
    exportQuery= SELECT * FROM CI_INFOOBJECTS WHERE si_kind= 'Folder' and SI_name = 'test'
    exportQuery= SELECT * FROM CI_INFOOBJECTS WHERE      SI_ID IN (2188)
    Can you tell what is missing?

  • Production order with pipe line material

    Production ordre created and got confirmed  and found pipe line materials got stuck in COGI and on analysis found in that specific ordrer ordre pipe line material are not activated with special stock key indicator i.e. 4.
    Due to this it got stuck in cogi and for the same material created an order and found there is a allocation and  activated with special stock key indicator i.e. 4.
    Help me to resolve the existing Goods issue from COGI and cause of not activated with special stock key indicator i.e. 4. in production order.

    Dear ,
    did the pipe line material is showing in  production reservation  as one of the BOM compoenent?
    If it is the case , then cancel the confirmation in CO13 and try to connfirm the operation with Clear Reservation Option .
    Refer the below thread which may help you to figure out the issue :
    Re : How to consider Power and Steam in power plants and paper mills
    Re : Power and steam
    Regards
    JH

  • How to handle text files with Header lines

    Hi,
    Eventhough the number of header lines is specified, when I do Reverse to get columns, its considering only header line.
    I have file format like
    ffserver started.
    192.168.11.30 - - [Fri Apr 20 19:28:01 2007] "GET /robots.txt HTTP/1.1" 404 150
    192.168.11.30 - - [Fri Apr 20 19:28:02 2007] "GET /V23WASTINGPETROL HTTP/1.1" 200 310
    first line is header line and there are spaces within a field value, and the field separator also is space.
    regards,
    Vivek

    in this scenario of urs ,ur file has multiple delimiters like -- and spaces.
    in this case u need to convert the file in a file with single delimiter .
    this can be done by writing a code in java in ODI procedures.
    once you have the same delimiter all over the file.
    u can extract multiple headers using typical Procedure

  • Create biar file with command line for link universe

    Hi
    I am using boxi 3.1 and I am trying to create 2 biar files with the command line
    One file for " main" universe and it's reports and another is for a link universe and it's reports
    The problem that on "main " biar file that been created , the link universe and it's reports also appear in it.  Even so in the queries only the relevant objects are selected
    I try to remove from the properties file the parameter 'exportDependencies=true ', and then when I check the xml of the biar I so that the link universe and it's report no longer appear. But when I importing the file I receive the error message 'Required dependencies not found on target system : '[ARgp0DCiBRBOsL3EHYQaHBY, AdfkNagAE59Nsbazh40nwTU]'
    Does anyone have an idea what I need to do , in order to see in the main biar bust the main objects?

    I have done it before on BOXI R2 with the IW, and it works fine
    But any how, this is the way that we have to work with, since it is part of a customer product and the link universe and it's reports  is an additional part of the product.
    So is there a way that I can pull just the main universe and it's reports?

  • File with 4500 lines crashes on project 2013

    Hey All
    I have mpp file with 4500 tasks and connection that was created in msp 2010.
    in msp 2010 there is no problam to work with the file and the program doesn't crashe or stucks.
    in msp 2013 standart (with sp1)  i can open the file but the i can't work on it. it's crashes again & again. 
    it happens in very diffrent ways: when i am trying to add new column to the view the it's stuck, when i am pressing keyboard arrows to jumping to next lines it's stucks and crashes , when i am edting any text columns and so on... when it's stucks i need
    to close the program and it's crashes. it looks like a memory problam but it's also happens in diffrent computers with msp 2013 and i have computer with lots more then the system rquirement  of msp 2013.
    in adddition, it tryed to create new file with all the content the olds with many diffrent ways: copy-past summary task to new file,export to excel the exisiting file and copy column by column to new mpp file. and allways becomes slower and finally got stuck
    and crashes.
    when i copy from exported excel file (with task name,duration, predeccesors) to new mpp file the problames starts when i copy the predeccesors columns. 
    I copied the column of the predecessor in packages of 10 lines at a time to find out when the file begins to be problematic. And it starts to crashes and havee some stוcking and icaps as soon as I go through the line 100 in the file. Is it possible there
    is a problem of the relations between activities MSP 2010 know and understand them and MSP 2013 do not understand ?? Is it possible that MSP 2013 not supports 4500 activities?
    please help me !! i don't know where is the problam and i don't know why it's happen in new file too.

    Hi Avinoam,
    4500 task is a large project but anyway it should not make Project crash.
    You could try the following:
    Save the file Under a new name using the "save as" command and see if it helps,
    Try the
    XML export method.
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • Blank file with gray lines

    When I look in an event some of the photos are blank with gray lines in a square. When I double click on it the picture appears. If I burn these on to a disc will they show?

    No.
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild.
    Regards
    TD

  • How to create and use library JAR files with command-line tools?

    Development Tools -> General Questions:
    I am trying to figure out how to put utility classes into JAR files and then compile and run applications against those JAR files using the command-line javac, jar, and java tools. I am using jdk1.7.0_17 on Debian GNU/Linux 6.0.7.
    I have posted a simple example with one utility class, one console application class, and a Makefile:
    http://holgerdanske.com/users/dpchrist/java/examples/jar-20130520-2134.tar.gz
    Here is a console session:
    2013-05-20 21:39:01 dpchrist@desktop ~/sandbox/java/jar
    $ cat src/com/example/util/Hello.java
    package com.example.util;
    public class Hello {
        public static void hello(String arg) {
         System.out.println("hello, " + arg);
    2013-05-20 21:39:12 dpchrist@desktop ~/sandbox/java/jar
    $ cat src/com/example/hello/HelloConsole.java
    package com.example.hello;
    import static com.example.util.Hello.hello;
    public class HelloConsole {
        public static void main(String [] args) {
         hello("world!");
    2013-05-20 21:39:21 dpchrist@desktop ~/sandbox/java/jar
    $ make
    rm -f hello
    find . -name '*.class' -delete
    javac src/com/example/util/Hello.java
    javac -cp src src/com/example/hello/HelloConsole.java
    echo "java -cp src com.example.hello.HelloConsole" > hello
    chmod +x hello
    2013-05-20 21:39:28 dpchrist@desktop ~/sandbox/java/jar
    $ ./hello
    hello, world!I believe I am looking for:
    1. Command-line invocation of "jar" to put the utility class bytecode file (Hello.class) into a JAR?
    2. Command-line invocation of "javac" to compile the application (HelloConsole.java) against the JAR file?
    3. Command-line invocation of "java" to run the application (HelloConsole.class) against the JAR file?
    I already know how t compile the utility class file.
    Any suggestions?
    TIA,
    David

    I finally figured it out:
    1. All name spaces must match -- identifiers, packages, file system, JAR contents, etc..
    2. Tools must be invoked from specific working directories with specific option arguments, all according to the project name space.
    My key discovery was that if the code says
    import com.example.util.Hello;then the JAR must contain
    com/example/util/Hello.classand I must invoke the compiler and interpreter with an -classpath argument that is the full path to the JAR file
    -classpath ext/com/example/util.jarThe code is here:
    http://holgerdanske.com/users/dpchrist/java/examples/jar-20130525-1301.tar.gz
    Here is a console session that demonstrates building and running the code two ways:
    1. Compiling the utility class into bytecode, compiling the application class against the utility bytecode, and running the application bytecode against the utility bytecode.
    2. Putting the (previously compiled) utility bytecode into a JAR and running the application bytecode against the JAR. (Note that recompiling the application against the JAR was unnecessary.)
    (If you don't know Make, understand that the working directory is reset to the initial working directory prior to each and every command issued by Make):
    2013-05-25 14:02:47 dpchrist@desktop ~/sandbox/java/jar
    $ cat apps/com/example/hello/Console.java
    package com.example.hello;
    import com.example.util.Hello;
    public class Console {
        public static void main(String [] args) {
         Hello.hello("world!");
    2013-05-25 14:02:55 dpchrist@desktop ~/sandbox/java/jar
    $ cat libs/com/example/util/Hello.java
    package com.example.util;
    public class Hello {
        public static void hello(String arg) {
         System.out.println("hello, " + arg);
    2013-05-25 14:03:03 dpchrist@desktop ~/sandbox/java/jar
    $ make
    rm -rf bin ext obj
    mkdir obj
    cd libs; javac -d ../obj com/example/util/Hello.java
    mkdir bin
    cd apps; javac -d ../bin -cp ../obj com/example/hello/Console.java
    cd bin; java -cp .:../obj com.example.hello.Console
    hello, world!
    mkdir -p ext/com/example
    cd obj; jar cvf ../ext/com/example/util.jar com/example/util/Hello.class
    added manifest
    adding: com/example/util/Hello.class(in = 566) (out= 357)(deflated 36%)
    cd bin; java -cp .:../ext/com/example/util.jar com.example.hello.Console
    hello, world!
    2013-05-25 14:03:11 dpchrist@desktop ~/sandbox/java/jar
    $ tree -I CVS .
    |-- Makefile
    |-- apps
    |   `-- com
    |       `-- example
    |           `-- hello
    |               `-- Console.java
    |-- bin
    |   `-- com
    |       `-- example
    |           `-- hello
    |               `-- Console.class
    |-- ext
    |   `-- com
    |       `-- example
    |           `-- util.jar
    |-- libs
    |   `-- com
    |       `-- example
    |           `-- util
    |               `-- Hello.java
    `-- obj
        `-- com
            `-- example
                `-- util
                    `-- Hello.class
    19 directories, 6 filesHTH,
    David

  • SQL loader and stream files with new line '

    I have been trying unsuccessfully to load EDI files using SQL loader. The problem
    is that the lines are terminated by ' and when I use the stream file option it does
    not recognise the line terminator given. As I understand it from the documentation
    this should work - but it does not. I have also used the Hex option with no better
    result. Does anyone have any ideas ?
    I can and have used tr "[']" "[\n]" in Unix to convert the ' to newlines - I just
    wonder am I missing something in SQL loader which will allow me to do this ?
    This is the sql loader control file
    LOAD DATA
    INFILE 'WS860685.MFD' "Str ''' "
    BADFILE 'WS860685.bad'
    DISCARDFILE 'WS860685.dsc'
    INTO TABLE "DUND1"."EDI_LOADED_TEMP"
    REPLACE
    FIELDS TERMINATED BY '+'
    TRAILING NULLCOLS
    (L1,
    L2,
    L3,
    L4,
    L5,
    L6,
    L7,
    L8,
    L9,
    L10,
    L11,
    L12,
    L13,
    L14,
    L15,
    L16,
    L17,
    L18,
    L19,
    L20,
    L21,
    L22,
    L23,
    L24,
    L25,
    L26,
    L27,
    L28,
    L29,
    L30,
    L31,
    L32,
    L33,
    L34,
    L35,
    L36,
    L37,
    L38,
    L39,
    L40,
    LNO)
    Heres a sample of the data
    UNB+UNOA:2+5398888501357+5398888501838+080306:0737+395+ DESADV+++1'UNH+0001+DESADV:D:93A:UN:EAN004'

    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6020061915147
    answers this question perfectly

  • Output csv file with blank line

    Hi Fellow PI friend,
    I encountered 1 problem where my output csv file always come with 2 blank lines after data line record. Can someone give me some advise or tip how to solve it?
    Thanks in advance.

    Hi ,
       Check if this link throws some light on your issue:
    Junk character at end of file from sender adapter creating a blank record
    Regards,
    Ravi

  • How to print a text file with long lines?

    I am trying to print a text file which contains many long lines. I find that the long lines are truncated on the printouts. How do I wrap up these long lines? Could you give me some examples?
    Thank you very much!

    Here's an example. The "\n" makes anything after it go to the next line. I hope this helps. Look at the Private void getTable() section.
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    public class LabNine extends Frame implements ActionListener, WindowListener {
         private TextField txtInfo;
         private List lstInfo;
         private Button btnAddInfo;
         private BorderLayout borderlayout;
         private Connection databaseConnection;
         Statement statement;
         ResultSet resultSet;
    public LabNine( ) {
         super("Lab Nine");
         // addWindowListener to close application
         addWindowListener(this);
         // create layout
         borderlayout = new BorderLayout();
         setLayout(borderlayout);
         // create text field so the file input that is selected will be seen in here
         txtInfo = new TextField();
         txtInfo.setEnabled(false);
         Color color = new Color(255, 136, 183);
         txtInfo.setBackground(color);
         add(txtInfo, BorderLayout.NORTH);
         // create list so the file input can be populated in here
         lstInfo = new List();
         add(lstInfo, BorderLayout.CENTER);
         // create button to add selected input file in the text field
         btnAddInfo = new Button("Add Info");
         btnAddInfo.setBackground(Color.cyan);
         btnAddInfo.setFont(new Font("TimesRoman", Font.BOLD, 16));
         btnAddInfo.addActionListener( this );          
         add(btnAddInfo, BorderLayout.SOUTH);
         // set frame attributes
         setSize(450, 250);
         setResizable( false );
         show();
         // get the table/ get the query
         loadConnection();
         getTable();
    public void actionPerformed(java.awt.event.ActionEvent e) {
         // if add button is pushed then it will check to see if an item was selected.
         // if not, then an error message will be displayed else the selected item will be in the text box
         if ( e.getSource() == btnAddInfo ) {
              if ( lstInfo.getSelectedIndex() == -1 ) {
                   System.out.print( "You have not selected an item" );
              else {
                   txtInfo.setText(( lstInfo.getSelectedItem() ));
    private void getTable() {
         try {
              String query = "SELECT FIRST, LAST, EMAIL FROM Names";
              statement = databaseConnection.createStatement();
              resultSet = statement.executeQuery( query );
              while ( resultSet.next() ) {
                   lstInfo.add( resultSet.getString( "FIRST" ) + " " + resultSet.getString( "LAST") + " " +
                        resultSet.getString( "EMAIL" ) + "\n" );
              statement.close();     
         catch ( Exception e ) {
              System.err.println( e );
    private void loadConnection() {
         // define the data source for the driver
         String sourceURL = "jdbc:odbc:people";
         String username = "";
         String password = "";
         // load the driver
         try {
              // load the drive class
              Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
              // create a connection through the drivermanager
              databaseConnection = DriverManager.getConnection( sourceURL , username, password );     
         catch( ClassNotFoundException cnfe ) {
              System.err.println( cnfe );
         catch( SQLException sqle ) {
              System.err.println( sqle );
    public static void main(java.lang.String[] args) {
         LabNine aLabNine = new LabNine( );
    public void windowActivated(java.awt.event.WindowEvent e) {
    public void windowClosed(java.awt.event.WindowEvent e) {
         // closes the application
         System.exit( 0 );
    public void windowClosing(java.awt.event.WindowEvent e) {
         // closes the application
         System.exit( 0 );

  • Target flat file with pipe seperated

    Hi
    I want to load the data in flat file , i don't see pipe "|" seperation values to create a flat file in this format. how can i achive and how can i also how can i create file name dynamically
    Thanks

    Just type in your desired character.
    Cheers
    David

  • Spool with .csv file with appropiate line

    Hi All,
    I am spooling .csv file in sqlplus below are the spooling sqlplus command,
    set echo off
    set verify off
    set termout on
    set heading off
    set pages 50000
    set feedback off
    set newpage none
    set linesize 160
    SET TRIMSPOOL on
    spool d:\spool1.csv
    select 'MENU_USAGE_ID,BAC,SRV_CNSLTNT_ID,SRV_CNSLTNT_FNAME,SRV_CNSLTNT_LNAME,PRESENTED_MENUS_COUNT,PRESENTED_SERVICES_COUNT,ACCPT_SERVICES_COUNT,TOTAL_PRSNT_MENUS_VALUE,TOTAL_ACCPT_MENUS_VALUE,MENU_USAGE_DATE,CREATEDBY,UPDATEDBY,CREATED_DATETIME,UPDATED_DATETIME,CUSTOMER_MENU_ID,TOTAL_DECLINED_MENU_PRICE,CHANNEL,MODEL_YEAR,MODEL_DESC,VIN,CURRENT_MILEAGE,RO_NUMBER,GM_SERVICES_ACCEPTED,GM_SERVICES_DECLINED,DEALER_SERVICES_ACCEPTED,DEALER_SERVICES_DECLINED' from dual;
    select
    MENU_USAGE_ID ||','|| BAC||','|| SRV_CNSLTNT_ID||','|| SRV_CNSLTNT_FNAME||','|| SRV_CNSLTNT_LNAME||','|| PRESENTED_MENUS_COUNT||','|| PRESENTED_SERVICES_COUNT||','|| ACCPT_SERVICES_COUNT||','|| TOTAL_PRSNT_MENUS_VALUE||','|| TOTAL_ACCPT_MENUS_VALUE||','|| MENU_USAGE_DATE||','|| CREATEDBY||','|| UPDATEDBY||','|| CREATED_DATETIME||','|| UPDATED_DATETIME||','|| CUSTOMER_MENU_ID||','|| TOTAL_DECLINED_MENU_PRICE||','|| CHANNEL||','|| MODEL_YEAR||','|| MODEL_DESC||','|| VIN||','|| CURRENT_MILEAGE||','|| RO_NUMBER||','|| GM_SERVICES_ACCEPTED||','|| GM_SERVICES_DECLINED||','|| DEALER_SERVICES_ACCEPTED||','|| DEALER_SERVICES_DECLINED from menu_usage;
    spool off;
    But when I am opening .csv file I seeing like
    >
    SQL> select 'MENU_USAGE_ID     BAC     SRV_CNSLTNT_ID     SRV_CNSLTNT_FNAME     SRV_CNSLTNT_LNAME     PRESENTED_MENUS_COUNT     PRESENTED_SERVICES_COUNT     ACCPT_SERVICES_COUNT     TOTAL_PRSNT_MENUS_VALUE     TOTAL_ACCPT_MENUS_VALUE     MENU_USAGE_DATE     CREATEDBY     UPDATEDBY     CREATED_DATETIME     UPDATED_DATETIME     CUSTOMER_MENU_ID     TOTAL_DECLINED_MENU_PRICE     CHANNEL     MODEL_YEAR     MODEL_DESC     VIN     CURRENT_MILEAGE     RO_NUMBER     GM_SERVICES_ACCEPTED     GM_SERVICES_DECLINED     DEALER_SERVICES_ACCEPTED     DEALER_SERVICES_DECLINED' from dual;     
    I have attached the both .csv files .
    My requirement is
    It should come like this in .csv file.
    13706940     partId_001     Mark     James     1     2     2     146.26     146.26     9-Apr-12     tpsdir     tpsdir     9-Apr-12     9-Apr-12     9030845     0     UI     2006     CTS     1G6DP577X60140937     45     RO3     1     0     0     0
    13706949     partId_001     Mark     James     1     6     3     296.87     158.04     ########     tpsdir     tpsdir     ########     ########     9030859     138.83     UI     2010     Avalanche - 4WD     56000          1     3     2     0
    13706948     partId_001     Mark     James     1     3     0     145.84     0     ########     tpsdir     tpsdir     ########     ########     9030858     145.84     UI     2012     CTS     1GASDFJASLDFJLASD     50000          0     2     0     1
    1.     Not required >SQL prompt
    2.     Not required column header
    3. Not required SQL> spool off;
    Can anyone please help on this.
    Thanks,
    Krupa

    Other solution is to avoid using SQL*Plus spooling...
    (From my standard library of examples...)
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.

  • The scan output is a file with lines

    The scan output is always a file with vertical lines. Whatever I try the printer, with wireless or USB connection, as well as  scanning with HP scan or the App scan from Windows 8.1. The result is the same, ie, fuzzy lines.
    Note: as a previous post suggested, I also open the lid and clean the glass.
    I´m enclosing the output  file:

    Hi @TRuivo
    I am sorry to see your scan output looks like a muddy rainbow   I would be happy to do my best to help you with this!
    Do you have the printer connected directly to a wall outlet or is it in a surge protector or power bar? Even if you have been using a surge protector/power bar all this time and you feel it is not the cause, please connect it to a wall outlet just so we can eliminate the power source as the root cause.   Issues when Connected to an Uninterruptible Power Supply/Power Strip/Surge Protector
    In this document you will see, ISSUE: Problems or issues may arise when an HP LaserJet series printer is connected to an uninterruptible power supply (UPS), a power strip, or a surge protector
    ^ This is not limited to Laserjet printers.
    Let's perform a hard reset. To do so, leave the printer on and unplug the power cable for 1 minute. While it is unplugged, hold down the power button on the printer for 10-15 seconds to release any built up power, then after the minute has passed, plug the printer back in.
    Also, please download the latest firmware version to ensure your printer is up to date; DJ2540_188.exe
    I hope one of these recommendations helps to resolve the issue! 
    Please click the Thumbs up icon below to thank me for responding.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Sunshyn2005 - I work on behalf of HP

Maybe you are looking for

  • Trying to load MP3 from desktop to AIR application

    I'm trying to load an MP3 file into an Air application. Here's some code. The first 2 lines are in my constructor fileToOpen.browseForOpen("Open", [new FileFilter("MP3", "*.mp3")]); fileToOpen.addEventListener(Event.SELECT, fileSelected); private fun

  • Why are my RAW images grainy on some devices after saving as JPG files?

    I am new to the world of photography, so forgive me if my question is silly. I just recently started shooting in RAW format.  After editing my photos and saving them as JPG files, I am running into a problem.  When I view the image files on my comput

  • Report RSHTTPPIN output only to screen

    Hi all, if i look to the report RSHTTPPIN the output is only to see on screen in HTML. But I need the data of response body in an abap to save the data in a z-table. Is there anyone how can help me. Thanks Angelika

  • Combining bandwidth of two wireless cards

    Hi, I have a mac mini c2d which comes with a built in b/g network. recently ive upgraded to a new N router for which i bought a new llinksys usb key (N Netowrk operating on 5 ghz). the problem is that this connection seems to be cutting in and out, m

  • Creating circular arrows?

    Hello! I've looked for a good solution to this issue I've had for like... forever, it seems. I often need to create circular arrows. Now, this is not normally a problem since I just add arrowheads to a path. But is there a way to convert the stylized