Download file to local machine using WPG_DOCLOAD.download

Hi ,
i am using database 11g and i am trying to write to file on database server using utl_file and download to the local machine by pl/sql procedure . i am directly executing this procedure in pl/sql . i am getting ORA-06502: PL/SQL: numeric or value error when executing owa_util.mime_header ('application/vnd.ms-excel',TRUE); statement in the procedure . not sure what is happening and i am new in using these features
here is my code
CREATE OR REPLACE PROCEDURE UTL_TEST_DOWNLOAD
AS
output_file utl_file.file_type;
vexists BOOLEAN;
vfile_length NUMBER;
vblocksize NUMBER;
l_blob BLOB;
l_bfile BFILE;
BEGIN
output_file:=UTL_FILE.FOPEN('DATA_DIR', 'timesheet.csv', 'w');
UTL_FILE.PUT_LINE(output_file,'COST_CENTRE'||
'HISTORY_DATE'||
'REF_NO'||
'FIELD_NAME'||
'VALUE'||
'DATA_TYPE'||
'CHANGE_DATE'||
'INT_REF');
UTL_FILE.fclose(output_file);
UTL_FILE.FGETATTR('DATA_DIR','timesheet.csv',vexists,vfile_length,vblocksize);
IF vexists THEN
DBMS_LOB.createtemporary (l_blob, TRUE, DBMS_LOB.SESSION);
l_bfile := BFILENAME ('DATA_DIR', 'timesheet.csv');
DBMS_LOB.fileopen (l_bfile,dbms_lob.file_readonly);
DBMS_LOB.loadfromfile (l_blob, l_bfile, DBMS_LOB.getlength (l_bfile));
DBMS_LOB.fileclose (l_bfile);
owa_util.mime_header ('application/vnd.ms-excel',TRUE);
dbms_output.put_line('after owa_util' );
owa_util.http_header_close;
WPG_DOCLOAD.download_file (l_blob);
end if;
EXCEPTION
WHEN utl_file.invalid_path THEN
RAISE_APPLICATION_ERROR(-20001, 'utl_file.invalid_path');
WHEN utl_file.invalid_mode THEN
RAISE_APPLICATION_ERROR(-20001, 'utl_file.invalid_mode');
WHEN utl_file.invalid_filehandle THEN
RAISE_APPLICATION_ERROR(-20001, 'utl_file.invalid_filehandle');
WHEN utl_file.invalid_operation THEN
RAISE_APPLICATION_ERROR(-20001, 'utl_file.invalid_operation');
WHEN utl_file.read_error THEN
RAISE_APPLICATION_ERROR(-20001, 'utl_file.read_error');
WHEN utl_file.write_error THEN
RAISE_APPLICATION_ERROR(-20001, 'utl_file.write_error');
WHEN utl_file.internal_error THEN
RAISE_APPLICATION_ERROR(-20001, 'utl_file.internal_error');
WHEN OTHERS THEN
dbms_output.put_line('SQLERRM '||SQLERRM);
END UTL_TEST_DOWNLOAD
SQLERRM ORA-06502: PL/SQL: numeric or value error
The file is getting created all the time i execute this procedure i am getting the above error while executing this statement owa_util.mime_header ('application/vnd.ms-excel',TRUE);

Hi,
it seems your issue is with PLSQL product so I would suggest to post your question in the PLSQL forum.
reference
PL/SQL
REgards, Roberto

Similar Messages

  • Problem in creating file on local machine

    Hello everbody...
    i m using forms and reports 6i
    i m creating file out_file := Text_IO.Fopen(:filepath || '.csv', 'a'); using this command in before_report trigger. And closing file in after_report trigger.
    here filepath is = \\IP address of local machine\d$\file name
    now problem is that if i m giving IP address of local machine then its giving error ORA-39856.
    And if i m giving IP address of server machine then it is going to create file on server machine from local machine.
    Why its not creating file on client machine?
    i think there r problems related to rights
    can anyone has solution then please tell me

    yes in report there is report output and with that it also creating file in coding by
    out_file := Text_IO.Fopen(:filepath || '.csv', 'w');
    this open stmt is written in before report trigger
    Below lines r written for each row thats fetch by report main query.
    str := rpad(:apt_bil_no,8,' ') || ',' || lpad(:apt_bil_dt,10,' ') || ',"' ||
                   rpad(:supl_name,30,' ') || '",' || rpad(:supl_tin_no,11,' ') || ',' ||
                   rpad(:aptvat_hsn_no,10,' ') || ',' ||
                   lpad(ltrim(to_char((apt_amt2 - apt_vat_amt2),'999999990.00')),12,' ') || ',' ||
                   lpad(apt_vat_amt2,12,' ') || ',' ||
                   lpad(ltrim(to_char(apt_amt2,'999999990.00')),12,' ');
    Text_IO.Put(out_file, str);
    Text_IO.New_Line(out_file);
    file is closing in after report trigger.
    text_io.fclose(out_file);
    now i wants to create this file on local machine.
    yes using report server and its started window service.
    can u have any idea?

  • Not able to create a text file in Client Machine using Forms 10g

    Hi - I'm mot able to create a text file in Client Machine using Forms 10g. I'm getting error when system executes the bolded line.(i.e. CLIENT_TEXT_IO.FOPEN). During run-time system is throwing "ORA-06508: PL/SQL: could not find program unit being called".
    I had attached webutil.pll in the form.
    Please advise me.
    DECLARE
    l_Temp CLIENT_TEXT_IO.FILE_TYPE;
    LC$Name Varchar2(100) ;
    LC$Fic Varchar2(100) ;
    LN$Lines Pls_integer := 0 ;
    LC$Line Varchar2(4000) ;
    Cursor C_CUR Is
    Select * From TEST_TEXTIO where rownum <= 50;
    BEGIN
    LC$Name := 'tmp_file.txt' ;
    LC$Fic := 'c:\temp\tmp_file.txt';
    Begin
    l_temp := CLIENT_TEXT_IO.FOPEN( 'C:\temp\tmp_file.txt', 'W');
    Exception
         when others then
         message( 'OPEN FILE ERROR ' || LC$Fic ||sqlerrm );
         display_error;
         raise form_trigger_failure;
    End ;
    -- Write the lines --
    For Cur In C_CUR Loop
         LC$Line := Cur.CODE || ' -> ' || Cur.COL1 || ',' || Cur.COL2 || ',' || Cur.Col3 ;
         CLIENT_TEXT_IO.PUT_LINE( LF$File, LC$Line ) ;      
         LN$Lines := C_CUR%ROWCOUNT ;
    End loop ;
    -- Close the file --
    CLIENT_TEXT_IO.FCLOSE( LF$File ) ;
    Exception
         When others Then
    message('err='||sqlerrm);message(' ');
    display_error;
    CLIENT_TEXT_IO.FCLOSE( LF$File ) ;      
         Raise ;
    END;
    Thanks.
    Arun

    Hi ,
    i have one Question though its not related to thos question if some could help me it will be really helpful,
    i have created one program to import and export excel to forms vice versa, if the form is attached with webutil its working fine am using ole2.but i have a new idea if i add this program in menu, it can be used for all the forms attched to that menu, i made program also, but problem am facing right now is if the form is not attched with webutil it will not work so is there possiblity to share my webutil from one form to another form ,so i will keep one form as a interface form in that webutil will be attched ,i can share that webutil to all other forms so that all the forms no need to attach webutil again
    if its possible means please suggest some ideas

  • Open bat file on client machine using webutil

    Hi all.
    I'm on devsuite 10g.
    I want to run a bat file on client machine using client_host function of webutil.
    I have tried first to execute the bat file with mouse double-click in order to check if it is ok, and it works.
    Now I want to execute this file from my form using webutil.
    Here is my code:
    --> with this code I select a file from client machine
    Declare
         LC$Fichier Varchar2(1000):=null ;
         PC$Filtre Varchar2(2000) := '|All files|*.*|' ;
    Begin
         LC$Fichier := WEBUTIL_FILE.FILE_OPEN_DIALOG
         null,
         PC$Filtre,
         'Seleziona un file da caricare'
    If LC$Fichier is not null Then
    :output.apri_file := LC$Fichier ;
    End if ;
    End ;
    --> with this code I execute the file that I have opened
    declare
         cmd varchar2(30000) := null;
    BEGIN
         Cmd := 'cmd /c start "" "' || :output.apri_file || '"' ;
    CLIENT_HOST(cmd);
    END;
    When I execute my form I have this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: ....folder of file opened.
    Can anyone help me to solve this problem??
    Thanks in advance,
    Fabrizio

    Fabrizio Delli Priscoli wrote:
    Hi Tony.
    I have tried to run my bat file with double-click and everything is OK.
    When you say the DOS window opens for few second, is your batch file being executed?? did you see the results??
    The answer in NO for both of your questions.
    If I try to drag and drop the file I have error.
    How can I attach an image to this post, so that you can see the error??
    Thanks,
    FabrizioThis seems like a directory or OS level permission issue on the batch file, What is the error you got when you tried drag and drop the batch file in an DOS window???
    I think you need to upload the image to a site and use the markup for the image, include the full URL of the uploaded file between ! (exclamation marks) something like ! http://../post.gif ! without the spaces.
    Tony
    Edited by: Tony Garabedian on Sep 4, 2008 12:30 PM

  • Local machine using - expecting remote machine

    Any advice on this one? I did modify the security / firewall to except IChat
    2009-01-04 19:42:44 -0600: No data has been received for the last 10 seconds.
    Audio channel info: local machine using 10.0.1.200:16402, expecting remote machine to send to 68.179.174.46:41078
    Video channel info: local machine using 10.0.1.200:16402, expecting remote machine to send to 68.179.174.46:41078

    Ok,
    Most Cable Modems do not router.
    It means that they pass the Public IP to the Router (Or any computer that might be directly connected if you only have one).
    This also means it is not doing DHCP (so no two lots of DHCP in this case most likely)
    Telling us the Make and Model of the modem will help to confirm this.
    Alternatively you can check if it is in this List (Very new models tend not to be included yet. They work on people sending in info, so not all devices are listed either.)
    Also tell us which version and what firmware the Base Station is Running.
    The set up pages for this can be accessed with Airport Utility in the Applications/Utilities folder.
    This presents you with a list of the Airport Devices it can find in a list on the left.
    Click on yours.
    Click on the Internet icon.
    This pane is essentially in two parts.
    The top is how you are getting connected to the Internet.
    It normally tells you the IP you are getting.
    If it is the same as when you go here the modem is not routing.
    At the Bottom is whether the Base Station is set to DHCP (Share an IP) to the computers (LAN).
    Tell us what you find out.
    If it is a Public IP you see quote it as 90.66.xxx.xxx (Or put some xxx's in somewhere).
    Pic of Internet Pane with Public IP
    Older firmware and Base Stations have slightly different Access methods where you get a little Pop Up window to log on by IP first.
    (I don't have Pics of that at the moment)
    8:04 PM Monday; January 12, 2009

  • Firefox 7.0 - Can not upload the file from local machine to server...gives "error 404 : file not found"

    firefox 7.0 - Can not upload the file from local machine to server...gives "error 404 : file not found"

    you have not understood my point
    how does this code will run on servlet when I want to upload a file from client's
    machine to server machine
    what I am doing is I am giving an option to the user that he/she can browse the file and then select any file and finally it's action is post in the jsp form for which I have sent the code
    All the computers are connected in LAN
    So how to upload a file from client's machine to server's machine
    Plz give me a solution

  • Sharepoint 2010 is automatically downloading Office2010 files to local machine's Recent Documents, instead of opening from library, off an emailed link.

    Hi-
    Please forgive me if this exact question has been asked already (if so I'm not finding it via Google or these forums), but one of my users can't seem to edit documents IN libraries, via links emailed to him.  He clicks on the link and the
    file auto-downloads with no Read-only/Edit option pop-up, and he can edit it (without getting the annoying yellow "this is read only from the server, click to edit document" bar up top either), but naturally his changes to these documents
    are only being saved on his local machine and not making it back to the library....  Our IT dept gave him a Save As workaround (that, it appears, would make a SECOND file in the library, which is not going to work for our processes), but nobody
    else is having this issue....  I'm thinking this is a simple settings change someplace in Sharepoint 2010 or Word 2010 (we have Windows 7), or maybe IE, or it's possible his User profile in our network needs some kind of adjustment...  anyway,
    any/all help appreciated.  Thanks.
    CF

    Hi,
    1. For automatically download the files, please check the office software settings. for word file, please open local word > file > options > save > save checked-out files to: > select "the office document cache"
    2. site actions > site settings > site administration > search and offline availablity to change the settings.
    3. Please compare the add-ons from this user's IE setting and the working fine IE setting.
    Regards,
    Seven 

  • Saving an xml file in local machine(urgent)

    Hi Techies,
    I am creating the xml file from jsp and generation of xml is working fine for me.
    Now the query is How can I point out the location of local machine??
    Here is my code
    String locationAndBackupFileName =request.getParameter("locationAndNameOfBackupFile");
                             System.out.println("Location"+locationAndBackupFileName);
    StringWriter  stringOut = new StringWriter();       
    XMLSerializer   serial = new XMLSerializer(stringOut, new OutputFormat("xml", "UTF-8", true));
    response.setContentType("application/xml");
    response.setHeader("Content-Disposition","attachement; filename="+locationAndBackupFileName);
    serial.setOutputCharStream(new FileWriter(locationAndBackupFileName));
    serial.serialize(document.getDocumentElement());when I xcute my code I am getting download dialog box, with save option.
    But after downloading no data is available.
    Can u guys help me to fix this problem
    regards,
    krish

    I don't know what you mean by "location of local machine". The response is being sent to a client machine (maybe that's your "local" machine). You have a lot of strange code that looks like it's serializing the XML to various places, but it should be serializing it to the response's output stream if you want it to go to the client.
    There is no way for you, on the server, to control where on the client machine the response data will be stored. That is entirely up to the user on the client. And you certainly can't write it to the client without the knowledge and consent of the client. That's just basic network security.

  • How to allow user to select pdf file on local machine and populate field with file name only

    Folks,
    I have a project requirement that I am stumped on.  I am admittedly a novice, so forgive questions that may seem obvious.
    My requirement is a form running on a client system where the user can click a button and select a PDF file name from a PDF on their local machine and then populate a form field with that file path & filename.  The file names vary between all machines, so there is no static list.  Note that the PDF is not embedded, nothing is executed, I simply need the file name.
    There are several of these on a form (20+), so manual name entry is too error prone.   I would like to use a 'browse' type dialog, but can not figure out how to implement it.
    I've looked at app.browseForFile, but the users can not install a javascript file in their adobe folder or any other files;  the functionality has to be integral with the original PDF. 
    Functionally, this is no different from the image object file browse, except that I need a PDF instead of an image file, so there doesn't seem like there should be a security issue that is any different from those surrounding the image object.
    I've been stumped on this for the entire week, and I have a deadline rapidly approaching, so any examples or suggestions (please remember I'm a novice) would be greatly appreciated! 

    Thanks for the reply Paul - do you have any sample code of how to attach the PDF?  Or how the user can select a PDF to open?  I might be able to attach it, retrieve the file name, and then un-attach it.
    Alternatively, do you know how to retrieve the file name from the imagePath object?  It will let you select PDF files, but I can't find info on how to retrieve the file name.   It should be the way you would retrieve the file name for an image.
    As a novice in this, thanks for your help and patience!

  • How to update a BLOB column in a table with a file in local machine?

    I have a file (of XML type) in my local machine. I want to update it in a BLOB column of a table in databse server. Can anyone help me in this regard. Appreciate your help.
    Regards
    Walter Nicholas

    user447427 wrote:
    I have a file (of XML type) in my local machine. I want to update it in a BLOB column of a table in databse server. Can anyone help me in this regard.That's the client's job to read data on the client PC (from keyboard/mouse/scanner/file/whatever input) and submit that to the database server for processing and/or storage.
    You cannot expect the server to hack into your PC and lift that data in the file from your disk. Not that is not technically possible. You can wire rockets onto a bicycle to make it go faster, but that's not a wise thing to do. Similarly, it is not a bright idea to ignore the very basics of client-server.
    Bottom line - you need client s/w on your PC to load the content of that file into Oracle. It can be done using SQL*Loader as already suggested. It can be done using a web browser (submitting it via HTTP to web-enabled PL/SQL code). You can use FTP or WebDav and upload into Oracle's XDB (XML database).
    Your requirements will determine what client to use. Once off load? SQL*Loader is very easy to use for loading XML files into the database.

  • Creating flat file in local machine

    Gurus,
    My database is OLAP database, i need to extract the data into flat file (.csv/.txt/.xls) in to client machine (Local machine, or End user PC) not in to Oracle DB Server.
    Is it possible to achieve the same without using UTL_FILE?
    If so please help me in this regard.
    Thanks in advance.
    Karthik.K

    What client are you running on the PC to connect to the database
    If sqlplus you can spool the output
    Re: Create a file in a local PC.
    Other options some of which write to the client.
    http://tkyte.blogspot.com/2009/10/httpasktomoraclecomtkyteflat.html

  • Saving Email as a .msg file on local machine

    Hi Everyone,
    I have a requirement of reading an email from the INBOX folder and later save it as a .msg file on my local machine. Although, the file is getting created, I am unable to open it. However, when the file is saved as an .eml file, it works fine.
    I have tried saving a .msg file from outlook and opening it, however, the problem is with the email file saved as .msg file using java.
    Any suggestions on fixing this problem.
    Thanks,
    Nitin

    Hi nithin,
    You can achieve this when the client send the message to you in octet streem then the par object contains the message subject as file name along with .msg files . if you store the same you can retrieve by using
    response.setcontenttype("octet-stream")
    and retrieve the stored message in .msg extension. can you pleasse let us know hoe you are capturing the part and storing in PC , I mean which type of part you are trying to open whether the part object content in octet stream or message/RFC822 format. please let me know.

  • Saving any KM file in local machine

    Hi All,
    I have a  requirment in that i have to save any KM file in my local machine from PDK application.
    Please help me out.
    Regards,
    Deepak

    Hi deepak,
    This may be the one way through which you can copy the KM folder to the local machine.This may not be the best option but may resolve your problem.
    Create a file repository in the KM content which will map to your lacal machine folder. Then you can see the local machine folder name as one of the repository in your KMcontent repository list. Then you can copy any Km folder to that repository. In this way all these folders will be available in your local machine physically.
    This may resolve your problem!!!
    Regards
    Manisha

  • How to write files on Client Machine using JSP

    Hi,
    I am new to JSP. Please tell me how do i write files on Client machine thru a Browser.
    Please let me know at the Earliest.
    Thanks.
    Mehul Dave

    1) Well I find it rather convenient to deploy a web app as just one file rather than a bunch of files. For deployment it's much better. However I prefer using expanded files when developping (to use auto reload in Tomcat for example)
    2) It is a bad idea to upload files inside your webapp's context (ie: in it's deployment directory) because one day an uninformed system administrator might come and redeploy the web app and therefore delete all your uploaded files (believe me, I've already experienced this!)
    What i do usually is upload it in a completely different directory, something like /uploaded_files. Your uploaded files are therefore completely independant from your webapp
    However it is a bit trickyer to get those files back. Let's take the example of image uploads. You have 2 ways of proceeding:
    - the easiest : configure your web server (apache etc...) to redirect a certain url to your external directory. For example the /upload url will point to a /uploaded_files directory. This is easier to do and the fastest way to serve images but not always the best solution: you are dependant on the web server's configuration and you can't control the visibility on your files (no security constraints, anyone can see your uploaded files if they know the url).
    - you can also write a servlet which will load the file as an array of bytes and send it back in the response.
    You can call it this way :
    <img src="/serlvets/showmyimage?path=uploaded.gif">
    in this way you can control your uploaded files better: you may want to define security constraints on the visibity or not of uploaded files depending on the user which has logged on the site.

  • How to upload file from local machine to oracle apps server.

    Hi all,
    Can somebody tell me how to create a OAF page to reads a window based file and writes to UNIX? (similar to FTP but using a OAF page as the interface)
    Thanks in advance!!
    Bhupendra

    Bhupendra
    Read Developer guide"File Upload and Download" section.It shows how to use messageUploadBean.
    Hope it helps!!!
    Thanks
    AJ

Maybe you are looking for

  • Ipod Touch 4G is no longer recognized by Itunes

    pod Touch 4G is no longer recognized by iTunes Today have been the problem that my ipod touch 4G is no longer recognized by itunes. He'll appear in My Computer as a DigitalCamera etc, but not in itunes. I've already uninstalled Itunes + Ipod rebooted

  • Sync multiple (but not all) photo folders?

    I've got a new 4G Touch and I am trying to figure out how to sync multiple folders containing pics to the iPod, preserving the folder structure on the PC to the Album structure on the iPod. My device allows the following: 1) Sync all photos from Phot

  • HP Laserjet M5035mfp duplex issue

    Hi, I have a LJ M5035mfp device. When sending a duplex job to the machine, one side of the page the print quality is fine. The other side of the page the printing is faded. I have changed toner, fuser, duplex unit and transfer roller. Any suggestions

  • User exit  or BADI to validate service request value with PO value

    Dear gurus, Is there any userexit or BADI to validate service request value with PO value. Please help me regarding this. Thanks in advance

  • Queries with CTXRULE Index

    I am trying to build an alerting application when, on receipt of a new XML document, user's are alerted if the document matches one or more of the profiles that they have defined. I have created a CTXRULE index that does this but only with very simpl