Using FTP via PL/SQL

Hi all,
i have the need to implement an FTP procedure and accordingly to what i found here : http://www.oracle-base.com/articles/misc/ftp-from-plsql.php i try this code:
DECLARE
     l_conn  UTL_TCP.connection;
     l_result  PLS_INTEGER;
BEGIN
     l_conn := UTL_TCP.open_connection('remotehost', '21');
     dbms_output.put_line('1 '||UTL_TCP.get_line(l_conn, TRUE));
     l_result := UTL_TCP.write_line(l_conn, 'USER user');
     dbms_output.put_line('2 '||UTL_TCP.get_line(l_conn, TRUE));
     l_result := UTL_TCP.write_line(l_conn, 'PASS passord');
     dbms_output.put_line('3 '||UTL_TCP.get_line(l_conn, TRUE));
     l_result := UTL_TCP.write_line(l_conn, 'cwd /some/remote/path');
     begin
          loop
              dbms_output.put_line('4 '||UTL_TCP.get_line(l_conn, TRUE));
          end loop;
     exception
            when UTL_TCP.END_OF_INPUT then
              null;
    end;
     l_result := UTL_TCP.write_line(l_conn, 'bye');
     UTL_TCP.close_connection(l_conn);
END;     in order to intercept all the returning messages ... but the loop never raise exception.
Any suggestion?
Thanks
Alex

OraclePSP wrote:
Paul Horth wrote:
"I NEED to do ftp in a procedure, if possible"
What business function are you trying to satisfy?Hi Paul,
in a higher vision the all process have to :
- transfer files in directory and subdirectory (eg. /2012/Nov , /2012/Dec, /2013/Jan, etc)
- "check and make" the path
- the success or errors of the entire flow has to be reported to the user
I know that all this can be done with os command, and i already does, but i have an apex app that manage the files i would like to export.
Is easier to report os commands result in apex vs. reproducing the command in apex directly?
Any suggestion is welcome and appreciated.
AlexWithout knowing more it is difficult to say what would be the best fit to your requirements but two
approaches spring to mind.
One is to use Unix scripts to do the ftp and write the results to a table whcih can then be interrogated by an Apex
report as to what the result was. When you say the Apex app manages the files you want to export, do you mean
the user picks the files to transfer? One way of doing that would be for the Unix script to read a table to see what needs
ftping (the app would obviously set the required data up in the table).
The second approach might be to write a Java procedure that sits in the DB and invokes the OS commands required. This procedure
can be invoked like a normal PL/SQL procedure stored on the DB.
Others may have other ideas.

Similar Messages

  • How to copy file to another server from database using FTP in oracle

    How to copy file to another server from database using FTP in oracle.
    Please do the needfaul.

    Billy  Verreynne  wrote:
    BluShadow wrote:
    Not to mention that some FTP servers can return more than one return message per operation whereas others may return one message for the same operation.I had the problem using the LIST command to determine if a file exists on the server. Cannot be determined via the FTP server's return code. Which means parsing and checking the text response from the server to the command. And this vary from server to server.
    But the basics were quite easy to code. The entire package is 500 lines, includes comments and blank lines for formatting, and supports the basic FTP client command set. Not really a complex piece of software to write - but I found that many developers seem to think that writing network socket software is complex. Not really the case...Mine's a big larger, but incorporates functionality similar to what Chris provided in his, such as being able to use SQL to query a remote file using pipelined functions, or functionality to write the results of a query directly to a remove file.
    :)

  • Not able to send file Using FTP in SSIS 2005

    I am using SSIS 2005
    I am trying to send file to ftp server using FTP task in SSIS but i am getting following error.
    Error Message-:An error occurred in the requested FTP operation.
    Detailed Description-:550 /FileName.txt: Access is denied.
    RemotefilePath is /
    I need a advice.
    Thanks in advance.

    I got this error recently from the FTP task in SSIS:
         Unable to send files using "FTP".
    I had everything correct, by the book.  I was trying to send a file, but I got the same error when trying to receive a file. 
    I already verified that I could send the file via command line FTP, so the FTP was not "secure FTP" (which wouldda required FileZilla or WinSCP or something similar) and my credentials were fine. 
    But I still got the above error.  Heck, I was beginning to thing that the FTP task in SQL Server 2008 was broken and just couldn't send files.
    Well, this issue is now resolved.  The problem was in the
    destination folder.  I was assuming that the root folder for my FTP account held the files. 
    So I entered the destination folder as this:   
    /data_in/
    But... the FTP task sees the root folder as one up from that. 
    So I had to use my account name in the path... meaning I had to change the destination folder to this:    
        /myaccountname/data_in/
        (where "myaccountname" was my login to the FTP site.)
    I hope this post helps someone else.
    Donna

  • Creating Report via PL/SQL

    We have an application using HTML DB from which the we need to create reports for which the standard CSV will not work. The report can be created via PL/SQL except that the report needs to be created on the users workstation or a public location and not the server. Since UTL_FILE writes to the server, I am looking for help from the HTML DB and PL/SQL experts on packages/tools that can be used to output reports to local directories.

    not sure of your exact requirements, but consider using utl_file or Oracle Reports to generate your report on the server and then providing your users a "download report" link that lets them pull the file down locally. we talked about using Reports for this at...
    PDF file creation
    ...regards,
    raj

  • Can do via SQL but not via PL/SQL

    is it possible that a simple; 'create global temporary table..' SQL can run, yet same code being called from an 'execute immediate' within a PL/SQL block throw an; ORA-01031: insufficient privileges exception...(same user)
    is it a role/privilege issue or do I need to de a better job debugging?

    short version, each user will pass unique values to the proc that via dynamic sql will build these tables based on that iterative select criteria, to be used only during their current working session.
    so it's not the 'same' table in structure each time
    would not having 'TEMP grantable' be the issue?
    trying to find a way to communicate this to the DBA

  • Send an email with attacment via PL/SQL

    Hi Guru's,
    First of all thank you some much to help me all the time.
    I need to send an email via pl/sql with attachment. Email is simple but i need to attache the file from the directory on the server. File already created from different process only i need to use that file for attachment and send an email.
    I am using utl_smtp for email.
    Could you please help me out
    Thanks in advance!
    Kind regards

    user590978 wrote:
    I need to send an email via pl/sql with attachment. Email is simple but i need to attache the file from the directory on the server. File already created from different process only i need to use that file for attachment and send an email.
    I am using utl_smtp for email.You need to read the file from the directory - and format an e-mail using MIME (<i>Multipurpose Internet Mail Extensions</i>). As part of this Mime e-mail body, your code needs to add the contents of the file.
    If the file is binary, the file's contents have to base64 encoded before adding it a Mime attachment to the e-mail body.
    The complete e-mail body is then send using the SMTP DATA command.
    You can also use UTL_MAIL - it creates a Mime body for the e-mail and supports a single (small) attachment. However, you still need to read the file from disk using UTL_FILE or DBMS_LOB.LoadFromFile() and pass the file contents to UTL_MAIL for base64 encoding and attachment.
    There is no standard Oracle PL/SQL interface that supports reading the file from disk to attach to the e-mail body - so the file reading part you need to do yourself.
    If the file is large, then UTL_MAIL (a poorly designed and written interface) will be unable to handle it. In which case you also need to write the base64 encode and generation of a Mime e-mail body with attachments.

  • How do I delete an LDAP entry and all of its child entries via PL/SQL

    I need to be able to delete (via PL/SQL) an entry and all of its child entries on my OID LDAP Server. None of the the procedures in the provided DBMS_LDAP package seem to bable to do this. For example, the delete_s procedure can only delete entries that are leaf nodes (no children). This will not work for me.
    I realize that I can execute the bulk delete shell script to do this, but this is via the command line, not PL/SQL.
    While I think I could write some PL/SQL code to parse through each entry using the "search_s" procedure and delete them one by one using the "delete_s" procedure, this doesn't seem very efficient. It seems like this should be a fairly common request and Oracle should have already addressed it.

    Sorry, to be clear, it's form fields on a web page that bring up all previously entered information.... I want to deleted some of these individually, but not all

  • Inserting to a clob field using cx_Oracle via a stored procedure

    Hello,
    Does anyone have experience using cx_Oracle to call a stored procedure which inserts to a clob field? I have found examples of doing this via straight SQL but I was hoping it was possible to do this via a stored procedure call. Thanks for any help you can provide.
    Jason

    And cursor.callproc('insert_clob_proc', (clob,))
    doesn't work for you?
    PrzemekYes - I should have been more clear in my original post. The callproc function works until we have a value which is over 32K. At values over 32K, we get an error message "ORA-01460: unimplemented or unreasonable conversion requested". I believe this is because we are sending the value as a string and so we would need to figure out how to send as a CLOB in cx_Oracle? Here is some code to use to test if interested...
    Oracle (Oracle Database 10g Release 10.1.0.4.0 - Production):
    CREATE TABLE clob_test (CLOB_FIELD CLOB);
    CREATE OR REPLACE PROCEDURE ins_clob_test (v_clob_field IN CLOB)
    AS
    BEGIN
    INSERT INTO clob_test (clob_field) VALUES (v_clob_field);
    END ins_clob_test;
    Python (2.5):
    conn = cx_Oracle.connect(xhash['oraclelogin'])
    cursor = conn.cursor()
    clob_var = 'Some test data' * 10000
    cursor.callproc('ins_clob_test',(clob_var,))
    conn.commit()
    cursor.close()
    conn.close()
    I should also mention that I am the Oracle developer and not the Python programmer - my knowledge of Python is very limited. I would like the Python programmers to use the procedures (packages) I have created to do their inserts but this situation has caused them to put the SQL directly in their code.
    Thanks again for any assistance you can provide.
    Jason

  • Trying to use Linked Servers in SQL 2005 to connect to RDB 7

    I'm looking for detailed info on how to set up a linked server in SQL 2005 to connect to my Oracle RDB 7 database (running on VMS). I'm able to connect via odbc using VS.Net and Sql Server 2005 Reporting Services. I'm not sure if I need to use the ODP.NET or not. I have created a generic linked server, but it requires me to use the OpenQuery function to access the data, which is not giving me the functionality I'm looking for.

    Hi doanpq,
    Please download and install OLE DB Provider for Visual FoxPro 9.0, which exposes OLE DB interfaces that you can use to access Visual FoxPro databases and tables from other programming languages and applications. Please see:
    http://www.microsoft.com/en-us/download/details.aspx?id=14839
    Then, please follow up the following article to create a linked server:
    Creating Linked Servers:
    http://technet.microsoft.com/en-us/library/ff772782(v=sql.105).aspx
    For more information, you can also take a look at the following article, especially Dave K's comment:
    http://blog.dbase.integralwebsolutions.co.za/2008/10/accessing-your-dbf-tables-via-linked.html
    Elvis Long
    TechNet Community Support

  • Avaibility of FTP option in SQL Developer

    Hello,
    Can any one please help me regarding the FTP option in SQL Developer.As this is avaibable in TOAD. Also let me the navigation if at all there (step in detail)
    Thankyou for your help.

    Similar thought,
    In JDeveloper, there is support for 'External Tools.' I use this feature to do things like FTP and run builds on our servers with the tcl tool 'expect'. When file support becomes available, can the external tools feature be ported over to SQL Developer? That would provide many of us with an option for adding some missing features like FTP.
    Eric

  • How come the item value does not come thru via PL/SQL anonymous block?

    Hi,
    It's a Form with 3 tables -
    1) ClinicianProfileTb (with about 40 columns, insert/update via DML),
    2) PeopleTb (with about 7 columns, insert/update via PL/SQL anonymous block) and
    3) ClinicianPracticeTb (with about 10 columns, insert/update via PL/SQL anonymous block) for after-submit-processes.
    So I have several After-Submit-Processes. For some reason, it appears that PeopleId which is supposed to come thru via the 2nd After-Submit-Process (ie: Insert/Update PeopleTb) does not do the way it's supposed to. And when I press "Create" button at the bottom, I got the following error msg:
    ORA-01400: cannot insert NULL into ("TEST_0712"."CLINICIANPRACTICETB"."PEOPLEID")
    I tried the "debug" mode (via edit page link), but to no avail. (I'm newbie, trying to learn and deliver at the same time :)).
    I uploaded the app to apex.oracle.com, if someone could kindly take a look and let me know what goes wrong, it'd be greatly appreciated.
    workspace: test_0712
    app: 43408 - TEST
    user: demo
    pswd: demoPswd
    Page#21 -> look at the After-Submit-Processes -> in "Insert/Update PeopleTb" it appears that PeopeId does not come thru; thus it cannot be updated to ClinicianProfileTb.PeopleId (allows null) -> and thus cannot be inserted into ClincianPracticeTb.PeopleId (which does NOT allow null). Basically my logic is that in order to create ANY row in ClinicianPracticeTb, BOTH PracticeId AND PeopleId must be present.
    Acutally I should have used the PeopeTb as DML (as the driving table) to enforce that PeopleId must be present in order to insert ClinicianProfileTb and ClinicianPracticeTb, but it'd be lots of codes to write to insert/update in ClinicianProfileTb (40 columns).
    In addition, does ApEx consider EVERY SINGLE after-submit-process are in ONE transaction for commit/rollback? It appears that it treats all PL/SQL anonymous blocks are in ONE transaction, while Automatic Row Processing (DML) is commited/rolled back on its own?
    Thanks much,
    Helen

    All blocks that do not commit in one of the ways I detailed (and which do not explicitly commit using a commit statement) are part of the transaction started with > the first DML statement issued in any of the page processes and continuing until a commit is issued.Say, there are the following processes in the After-Submit-Processes:
    1. Process1 -> Automatic Row Processing (DML)
    2. Process2 -> PL/SQL anonymous block
    3. Process3 -> PL/SQL anonymous block
    Based on what you describe, in the event that if there is no explicit "commit" issued in any of these processes, then an implicit "commit" will be issued at the end of Process3?
    Thanks, Scott.
    Doreen

  • Retrieve SQL Agent Process ID via T-SQL below SQL Server 2008 R2 SP1.

    Dear Folks,
    I have to retrieve the process ID of SQL Agent (as shown in Configuration Manager) via T-SQL Script. It can be easily retrieved in SQL Server 2008 R2 SP1 or above using 'sys.dm_server_services'
    DMV. But I have to retrieve it in SQL Server 2008 R2 RTM and above DMV was not introduced in it. Using XP_cmdshell 'tasklist' is useless as well, as it doesn't reflect the instance specific details of SQLAgent process. Please Suggest the solution. Thanks in
    advance. :)   
    Pranshul Gupta

    Dear Folks,
    I have to retrieve the process ID of SQL Agent (as shown in Configuration Manager) via T-SQL Script. It can be easily retrieved in SQL Server 2008 R2 SP1 or above using 'sys.dm_exec_request' DMV.
    But I have to retrieve it in SQL Server 2008 R2 RTM and above DMV was not introduced in it.
    Using XP_cmdshell 'tasklist' is useless as well, as it doesn't reflect the instance specific details of SQLAgent process. Please Suggest the solution. Thanks in advance. :)   
    Pranshul Gupta
    Hello,
    Sys.dm_exec_requests DMV was introduced from sql server 2005.See this link
    http://technet.microsoft.com/en-us/library/ms177648(v=sql.90).aspx
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Using Entity Framework with SQL Azure - Reliability

    (This is a cross post from http://stackoverflow.com/questions/5860510/using-entity-framework-with-sql-azure-reliability since I have yet to receive any replies there)
    I'm writing an application for Windows Azure. I'm using Entity Framework to access SQL Azure. Due to throttling and other mechanisms in SQL Azure, I need to make sure that my code performs retries if an SQL statement has failed. I'm trying to come up with
    a solid method to do this.
    (In the code below, ObjectSet returns my EFContext.CreateObjectSet())
    Let's say I have a function like this:
      public Product GetProductFromDB(int productID)
         return ObjectSet.Where(item => item.Id = productID).SingleOrDefault();
    Now, this function performs no retries and will fail sooner or later in SQL Azure. A naive workaround would be to do something like this:
      public Product GetProductFromDB(int productID)
         for (int i = 0; i < 3; i++)
            try
               return ObjectSet.Where(item => item.Id = productID).SingleOrDefault();
            catch
    Of course, this has several drawbacks. I will retry regardless of SQL failure (retry is waste of time if it's a primary key violation for instance), I will retry immediately without any pause and so on.
    My next step was to start using the Transient Fault Handling library from Microsoft. It contains RetryPolicy which allows me to separate the retry logic from the actual querying code:
      public Product GetProductFromDB(int productID)
         var retryPolicy = new RetryPolicy<SqlAzureTransientErrorDetectionStrategy>(5);
         var result = _retryPolicy.ExecuteAction(() =>
               return ObjectSet.Where(item => item.Id = productID).SingleOrDefault;
         return result;
    The latest solution above is described as ahttp://blogs.msdn.com/b/appfabriccat/archive/2010/10/28/best-practices-for-handling-transient-conditions-in-sql-azure-client-applications.aspx Best Practices for Handling Transient Conditions in SQL Azure Client
    Application (Advanced Usage Patterns section).
    While this is a step forward, I still have to remember to use the RetryPolicy class whenever I want to access the database via Entity Framework. In a team of several persons, this is a thing which is easy to miss. Also, the code above is a bit messy in my
    opinion.
    What I would like is a way to enforce that retries are always used, all the time. The Transient Fault Handling library contains a class called ReliableSQLConnection but I can't find a way to use this with Entity Framework.
    Any good suggestions to this issue?

    Maybe some usefull posts
    http://blogs.msdn.com/b/appfabriccat/archive/2010/12/11/sql-azure-and-entity-framework-connection-fault-handling.aspx
    http://geekswithblogs.net/iupdateable/archive/2009/11/23/sql-azure-and-entity-framework-sessions-from-pdc-2009.aspx

  • Getting Session ID via PL/SQL Statement

    Hi,
    I'd like to fill an item in my form with the current session id. Can I query this id via PL/SQL statement?
    Thank you

    i think you misunderstood.....
    i'd like to fill an item on my page with the current session id using a computation. this computation has to query this id.

  • SELECT ROWID using ABAP without Native SQL ?

    Hi All,
    is that possible to query Oracle ROWID from ABAP without using Native SQL ? Please advise.
    Thank You and Best Regards
    FL

    Since this is usually not relevant for application programming and also database specific, I'm fairly sure this information hidden by the DBI and you cannot access it via Open SQL, so native SQL seems to be your only choice.
    Thomas

Maybe you are looking for

  • Displaying message  in JApplet while downloading a file

    hi In my applet Im trying to download a file from server to client while downloading i want display progressbar/ msg when i try to do this my applet GUI dosnot loads untill that file download complete and i tried with a button so that ofter clicking

  • Oracle ODBC BLOB examples.

    We are currently writing a VB application to harvest data from an Access 2000 database, which is to large to convert to 97 and use migration workbench, and stuff it into an Oracle 8 database, which already has the table structures from the Access dat

  • NEF files won't launch app

    This is what I'm getting with almost every NEF file: "file.NEF" is damaged and can't be opened. You should move it to the Trash. Files seem to be intact, I can open them from Bridge itself or from Photoshop, just can't launch the apps from the file.

  • Timer functions (1.4.2 X 1.5.0)

    !!!!!!!! *********** Sorry for the CROSS POST, i ask the moderators to erase the same message that i wrongly posted on New To Java Techonology. I`m reposting it here cause i only saw the mistake now and i really need this information (in the other fo

  • Is it possible to move documents to folder based on metadata by workflow?

    We have a document library, which have several folders. We need a process so that documents are stored to the right place based on metadatas. Is this possible? Any better method for this? 1. User uploads a document and defines it as a "personnel" doc