CSV Files from Oracle - why won't this work?

Hi all, I copied and pasted in the code at the bottom of this post
into Oracle 8 - it's copied from asktom so it should be fine.
I got Function created at the end.
However, when I try to run
exec dump_csv( 'SELECT Defer_Date, Defer_Time, User_Id, Start_Date, Group_Name,Employee_Id, PROCESS_STATUS, REQUEST_PARAMSX1 FROM msf080 ORDER BY Defer_Date DESC;',',','/ellipse/el5.2.3.2_tb_sup/work','billy.txt');
I get
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00221: 'DUMP_CSV' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
The same thing happens when I remove the exec from the beginning of the
command.
I know it's probably something stupid that I have neglected. Any help
appreciated. Also, being able to escape single quotes would be nice,
as in WHERE Prog_Name = 'MyString' - is it
WHERE Prog_Name = '''MyString''' - i.e. triple-single quote?
Paul...
create or replace function dump_csv( p_query in varchar2,
p_separator in varchar2 default ',',
p_dir in varchar2 ,
p_filename in varchar2 )
return number
is
l_output utl_file.file_type;
l_theCursor integer default dbms_sql.open_cursor;
l_columnValue varchar2(2000);
l_status integer;
l_colCnt number default 0;
l_separator varchar2(10) default '';
l_cnt number default 0;
begin
l_output := utl_file.fopen( p_dir, p_filename, 'w' );
dbms_sql.parse( l_theCursor, p_query, dbms_sql.native );
for i in 1 .. 255 loop
begin
dbms_sql.define_column( l_theCursor, i, l_columnValue, 2000 );
l_colCnt := i;
exception
when others then
if ( sqlcode = -1007 ) then exit;
else
raise;
end if;
end;
end loop;
dbms_sql.define_column( l_theCursor, 1, l_columnValue, 2000 );
l_status := dbms_sql.execute(l_theCursor);
loop
exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
l_separator := '';
for i in 1 .. l_colCnt loop
dbms_sql.column_value( l_theCursor, i, l_columnValue );
utl_file.put( l_output, l_separator || l_columnValue );
l_separator := p_separator;
end loop;
utl_file.new_line( l_output );
l_cnt := l_cnt+1;
end loop;
dbms_sql.close_cursor(l_theCursor);
utl_file.fclose( l_output );
return l_cnt;
end dump_csv;
/

mkdir admin - permission denied. I guess that's the end of that so?I'm afraid so...
Shouldn't that be /usr/oracle/admin/m52ora/ - i.e. without the utl_file at the end?No, from your posts it's part of the path.
...but there could be another way. Not sure if it works on your version (it surely works on 9i onwards), I don't have your version on hands to do tests, so you'll do the test :-)
As sysdba create a directory object, say MYDIR (you can name it as you want) :
SQL> create or replace directory mydir as '/ellipse/el5.2.3.2_tb_sup/work'; -- here you can use any OS directory on which you have write access.
SQL> grant read,write on directory mydir to <your user>;
then, as your user
select dump_csv( 'SELECT Defer_Date, Defer_Time, User_Id, Start_Date, Group_Name,Employee_Id, PROCESS_STATUS, REQUEST_PARAMSX1 FROM msf080 ORDER BY Defer_Date DESC;',',','MYDIR','billy.txt')
from dual;
here MYDIR must be uppercase.
Good luck...

Similar Messages

  • Functions in a For Loop defining objects from an Array. . .Why Won't This Work?!

    I'm trying to put these functions into a Loop to conserve
    space. Why won't this work?
    .

    Yeah, sly one is right. You can not have the "i" inside the
    onRollOver function, what you have to do is: As the movieClip class
    is dynamic you can create a property of the movieClip which stores
    the value if the "i". And then, inside the onRollOver function, you
    have to make reference to that property.
    for (i=0; i<2; i++) {
    this.regArray
    .iterator = i;
    this.regArray.onRollOver = function () {
    showRegion(regArray[this.iterator]);
    this.regArray
    .onRollOut = function () {
    hideRegion(regArray[this.iterator]);

  • Consolidate Library - why won't this work?

    Hi there,
    I've been using iTunes and my iPod on several iMacs successfully for years - I've just changed to a PC and now I feel like a beginner!
    I can't seem to get iTunes for Windows to seek out all my MP3s and put them in iTunes. The only way I can get iTunes to put them in it's library is to play them - then iTunes recognises then and remebers them. I have tried clicking on consolidate library - nothing. I have tried downloading my new music directly into the iTunes music folder - nothing. I can maunally add the file I download music into, but I don't want to have to do that all the time.
    Why won't iTunes just find my music for me? It does on my iMac!

    I dont know!
    In what way is it not working?

  • Erratic file naming. Why doesn't this work?

    The Finder allows certain names for files and folders sometimes, but then doesn't allow them at other times. What's happenig? Here's an example. I created a folder with this name: "National Geog> Africa (4 parts, 1hr each)" with no problem. Later I wanted to change the "4" to a "6". Sounds simple enough. I highlighted the 4 and typed the 6—but the Finder rejected that simple change, with this message: The [new name] cannot be used. Try using another name, with fewer characters or no punctuation marks."
    Why would it like the name with a 4 in it, but not like the name with a 6 instead of the 4?
    I can provide this much a clue. The folder resides on an external LaCie hard disk. I don't recall how that particular folder got there, but I have discovered I can create a folder with the desired name on my desktop and then successfully copy it to my external disk with no problem. But I cannot create the folder on the external disk in give it the desired name (I get the error message), nor can I change an existing folder name on the external disk to that name.
    This is not the world's worst problem, but if anyone has any comments about this, I'd appreciate them.

    Strange...when I create a folder on my desktop with that exact name I can change the 4 to a 6 perfectly fine. Are you able to change the name to other things?
    Are you able to create new files on the disk, or are you only able to copy files to it via the finder?

  • Why won't this work even though it does on another page?

    Hi,
    I am using XML to populate dynamic data. The Editor/Back-End
    will load the data no problem. When update is clicked the info is
    sent to a PHP script and the new xml is written to the file.
    However, on the front-end, main page, I use the same code, and it
    only loads a small bit, so I will only see the first text line or
    top of the picture, I can't seem to find out why..

    how can I bind the xmllistcollection value to the text value
    of a text field or source of an image.
    my xml structure is like this...
    <about>
    <image>images/image.jpg</image>
    <top>html text goes here with CDATA
    wrapper</top>
    <bottom>more html text goes here with CDATA
    wrapper</bottom>
    </about>
    i know how to bind the xmllistcollection to a dataprovider or
    list, but i don't understand how i can use it outside of components
    that use dataproviders.
    thanks,
    jesse

  • RAM issues WHY WON'T THIS WORK??!!

    I bought 1 additional 2Gb stick of RAM for my MacBook Pro 2.16, all information given on Mac website, documentation etc states that this MAC is capable of handling up to 3Gb RAM. But when the new RAM is install it will not boot. I have tried everything I can think of, ensuring that both of the memory slots are good, I have installed the original RAM in the second port, the system boots fine, I have installed the new 2Gb of RAM in the original port, system boots fine, installed the new 2Gb stick in the secondary port, system boots fine, but together nothing. I am sure that the RAM is correct - 2Gig - SO-DIMM DDR2 SDRAM 667Mhz.... Not to mention the system boots fine without the original 1Gb RAM, but honestly I didn't spend the money to have only 2Gb RAM !!
    Has anyone any ideas ??
    Message was edited by: AW1979

    Hi AW1979: In doing a little checking, I see that there are 2 versions of the 2.16gHz 17" MacBook Pro. The earlier version is capable of supporting only 2gB of RAM. The second version can support 3gB. Is it possible that yours is the version from Spring/Summer of 2006?
    Stedman

  • 5.5G battery in my 5G iPod.  Why won't this work?

    I bought a 5G 30GB iPod around christmas 05. Recently, the HD failed after i dropped it.
    Fortunately, my girlfriend had a 5.5G 80GB with a broken screen that she was using for back ups.
    She gave me the iPod so that i could maybe use her HD in my iPod. I cracked them open and used the Screen, scroll wheel, motherboard from my 5G 30gb, and the HD and battery from her 5.5G 80gb.
    After i put the two back together here is what happened:
    I started up the iPod and the apple logo appeared. Shortly after, a screen saying "Connect to your Computer. Use iTunes to Restore." in about 5 different languages.
    I connected it to my computer, then a message in iTunes showed up saying "iTunes has detected an iPod in recovery mode. You must restore this iPod before it can be used with iTunes."
    I then clicked Restore and entered in my Administrator name and password.
    Shortly after that, an alert popped up saying "The iPod "iPod" could not be restored. An unknown error occurred (1416)."
    This is where I'm stuck. I'm hopping that there are some people on this forum much smarter than i am and who are also willing to help me out.
    Let me know if i can describe anything further to give people more information about my problem.
    Thanks to anyone who can help!!!

    OK, I got the cfdump to display all the form variables, and my submit  button, btnSubmit is there.  But I think that is also the problem.
    In my original action page, I did not have to check for the existence of the submit button, so the codes  below worked :
    <cfif ListFirst(i,"/") is "comments">
    <cfset select_urdn_number = listgetat(i, 2, "/")>
    <cfset select_urdn_line_item = listlast(i, "/")>
    <cfset combineEnd = select_urdn_number & "/" & select_urdn_line_item>
    <cfif StructKeyExists(form, "del/" & combineEnd) and form["del/" & combineEnd] is "Yes">
    Now when I submit the form to itself, I have to check for the existence of the submit button and that gives me an extra form variable, so
    <cfif ListFirst(i,"/") is "comments"> will fail since it is no loner the first variable.
    So instead of performing listfirst, how can I find the comments in the form variables, so that I can continue to perform the other steps after ListFirst,
    to get all the information that I want ? I need it broken up like the above in order for the form to process correctly.

  • ITunes: I can no longer copy a playlist into a Pages (Word) document by using select all edit copy edit  paste.  Why won't this work now?  All I get when I paste is a series of Speaker symbols.

    I want to creat a copy of my playlists onto a Pages page.  I selected all the entries in the playlist, then did Edit > Copy > Edit > Paste.  I've done this lots of times before and it was fine; now when I paste all I get is a series of Speaker symbols, no text with of the playlist songs.  Does anyone else have this problem?  Thanks.

    I want to creat a copy of my playlists onto a Pages page.  I selected all the entries in the playlist, then did Edit > Copy > Edit > Paste.  I've done this lots of times before and it was fine; now when I paste all I get is a series of Speaker symbols, no text with of the playlist songs.  Does anyone else have this problem?  Thanks.

  • Create XML file from Oracle DB

    Hi,
    I'm working in a task to create electronic billing for Mexico Rules, to do this; I need to create a XML source that will contain all the information requested from Oracle DB.
    For this reason, I'm looking how to create this XML file from Oracle DB.
    All this is for the new legislations rules in Mexico to use electronic billing.
    Please, if you have any reference about this, let me know.
    Thanks and regards.

    you may want to check out commands like xmlforest and xmlelement
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions221.htm
    copied from documentation
    Purpose
    XMLForest converts each of its argument parameters to XML, and then returns an XML fragment that is the concatenation of these converted arguments.
    •If value_expr is a scalar expression, then you can omit the AS clause, and Oracle Database uses the column name as the element name.
    •If value_expr is an object type or collection, then the AS clause is mandatory, and Oracle uses the specified c_alias as the enclosing tag. The c_alias can be up to 4000 characters.
    •If value_expr is null, then no element is created for that value_expr.
    Examples
    The following example creates an Emp element for a subset of employees, with nested employee_id, last_name, and salary elements as the contents of Emp:
    SELECT XMLELEMENT("Emp",
    XMLFOREST(e.employee_id, e.last_name, e.salary))
    "Emp Element"
    FROM employees e WHERE employee_id = 204;
    Emp Element
    <Emp>
    <EMPLOYEE_ID>204</EMPLOYEE_ID>
    <LAST_NAME>Baer</LAST_NAME>
    <SALARY>10000</SALARY>
    </Emp>

  • Can't update ADOBE after many attempts. Why won't it work?

    Keep getting messages saying I must update ADOBE. Keep following directions for update. Then I'm disallowed access to anything that requires ADOBE update and a red typed message appears again saying I need to update ADOBE. Why won't this work ? I am a senior citizen and am not a computer savvy user. Need help with this ongoing problem.
    fiddle4dee

    Hello fiddle4dee, probably you mean adobe flash player, the latest flash version for your Intel Mac OS X 10.6 today is the 16.0.0.296. If you have a previous version then uninstall it with the :
    * http://helpx.adobe.com/flash-player/kb/uninstall-flash-player-mac-os.html
    after that you can install the latest from the next link :
    * http://www.adobe.com/special/products/flashplayer/fp_distribution3.html
    find Operating System, Mac OS X (Intel) > All supported browsers > All supported languages > '''Download DMG Installer'''
    thank you

  • How to import data from excel or csv files to Oracle table

    hello everybody,
    I am new here and new in Oracle. I would like to know the steps how to import data from excel or csv files to Oracle table.
    Let say I already have table inside the Oracle. Then my user give me the sets of data inside the Excel Worksheet.
    So, how can I import the excel data into Oracle table.
    Thank you in advance.
    cheers,
    shima

    Even easier. Download JDeveloper 11G from this site.
    Set up the database connection, right click on the table, select Import->Excel and specify your file to load it. On the import pop-up, you must view and update each tab indicating Columns, Data Types, and DML.
    Columns -- move the selected columns that you want to load to the box on the right
    Data Types -- select column name from second column to which the data for each column of the import file should load
    DML -- click this tab to generate the INSERT SQL
    Once done click 'Insert'

  • Loading data from .csv file into Oracle Table

    Hi,
    I have a requirement where I need to populate data from .csv file into oracle table.
    Is there any mechanism so that i can follow the same?
    Any help will be fruitful.
    Thanks and regards

    You can use Sql Loader or External tables for your requirement
    Missed Karthick's post ...alredy there :)
    Edited by: Rajneesh Kumar on Dec 4, 2008 10:54 AM

  • How to load the data from .csv file to oracle table???

    Hi,
    I am using oracle 10g , plsql developer. Can anyone help me in how to load the data from .csv file to oracle table. The table is already created with the required columns. The .csv file is having about 10lakh records. Is it possible to load 10lakh records. can any one please tell me how to proceed.
    Thanks in advance

    981145 wrote:
    Can you tell more about sql * loader??? how to know that utility is available for me or not??? I am using oracle 10g database and plsql developer???SQL*Loader is part of the Oracle client. If you have a developer installation you should normally have it on your client.
    the command is
    sqlldrType it and see if you have it installed.
    Have a look also at the FAQ link posted by Marwin.
    There are plenty of examples also on the web.
    Regards.
    Al

  • HT1351 Why won't movie files from flip camera won't play on ipod even after being converted?

    Why won't movie files from flip camera won't play on ipod even after being converted?

    Try the standard fixes:
    - Reset. Nothing is lost
    Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Restore from backup
    - Restore to factory defaults/new iPod.

  • How to mail pdf file from oracle database 11g

    Hi,
    Using following code to send pdf file from oracle database.
    DECLARE
    v_From VARCHAR2(80) := '[email protected]';
    v_Recipient VARCHAR2(80) := '[email protected]';
    v_Subject VARCHAR2(80) := 'test subject';
    v_Mail_Host VARCHAR2(30) := '116.214.31.249';
    v_Mail_Conn sys.utl_smtp.Connection;
    crlf VARCHAR2(2) := chr(13)||chr(10);
    BEGIN
    v_Mail_Conn := sys.utl_smtp.Open_Connection(v_Mail_Host, 26);
    sys.utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
    sys.utl_smtp.Mail(v_Mail_Conn, v_From);
    sys.utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
    sys.utl_smtp.Data(v_Mail_Conn,
    'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
    'From: ' || v_From || crlf ||
    'Subject: '|| v_Subject || crlf ||
    'To: ' || v_Recipient || crlf ||
    'MIME-Version: 1.0'|| crlf ||     -- Use MIME mail standard
    'Content-Type: multipart/mixed;'|| crlf ||
    ' boundary="-----SECBOUND"'|| crlf ||
    crlf ||
    '-------SECBOUND'|| crlf ||
    'Content-Type: text/plain;'|| crlf ||
    'Content-Transfer_Encoding: 7bit'|| crlf ||
    crlf ||
    'some message text'|| crlf ||     -- Message body
    'more message text'|| crlf ||
    crlf ||
    '-------SECBOUND'|| crlf ||
    'Content-Type: file;'|| crlf ||
    ' name="D:\mail\pdfSample.pdf"'|| crlf ||
    'Content-Transfer_Encoding: 8bit'|| crlf ||
    'Content-Disposition: attachment;'|| crlf ||
    ' filename="D:\mail\pdfSample.pdf"'|| crlf ||
    crlf ||
    'CSV,file,attachement'|| crlf ||     -- Content of attachment
    crlf ||
    '-------SECBOUND--'               -- End MIME mail
    sys.utl_smtp.Quit(v_mail_conn);
    EXCEPTION
    WHEN sys.utl_smtp.Transient_Error OR sys.utl_smtp.Permanent_Error then
    raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;
    Above code executed successfully and mail is send to recipient but file is corrupted.
    I think it doesn't pick file from specified location, attachment name is appearing like this 'D:mailpdfsample.pdf
    Oracle Database : 11g R2
    O.S : windows 7 Professional
    Thanks in Advance

    parapr wrote:
    sys.utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);The above violates RFC 5321 section 4.1.1.1
    '-------SECBOUND'|| crlf ||
    'Content-Type: file;'|| crlf ||
    ' name="D:\mail\pdfSample.pdf"'|| crlf ||
    'Content-Transfer_Encoding: 8bit'|| crlf ||
    'Content-Disposition: attachment;'|| crlf ||
    ' filename="D:\mail\pdfSample.pdf"'|| crlf ||Invalid Mime header above. Filename are logical. Not physical. Loose the drive and directory names. The filename is there to name the Mime body's content.
    crlf ||
    'CSV,file,attachement'|| crlf ||     -- Content of attachmentHow is the above PDF content? This is a string containing the text CSV,file,attachement. Which means when this is what is saved as a PDF file by the mail reader.
    EXCEPTION
    WHEN sys.utl_smtp.Transient_Error OR sys.utl_smtp.Permanent_Error then
    raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;Silly. Why change meaningful exceptions into a generic meaningless exception?? That does not make any sense.

Maybe you are looking for