How to create a Shell (.sh) file in Oracle using PL/SQL?

Hello world

I would like to know how to create a .sh file or any .txt file in Oracle. I would like to get the contents of the file from a table that has different settings. I used bcp in SQL Server and wonder if it's possible in Oracle to create this file.

Here are the DDL and DML in the table:

Hello

With a minor correction, it works on Unix/putty:

-I assume that you have already created the DIRECTORY (line 01); my directory is on Unix "/ tmp"-you can use on Windows

CREATE the DIRECTORY DEST_DIR AS 'C:\Users\Julaayi\Desktop\ ';

-You run SELECT in a variable (ctlCode) and output then the content of this variable in your file.

-If you have multiple records in the ETL_CTL table, and then use a FOR LOOP.

CREATE DIRECTORY XX_DIR AS '/tmp/';
--
DECLARE
  fileHandler UTL_FILE.FILE_TYPE;
  ctlCode varchar2(2000);
BEGIN
  fileHandler := UTL_FILE.FOPEN('XX_DIR', 'test_file.sh', 'W');
  select 'scp abcdf@'|| SOURCE_SERVER_1 ||':'|| SOURCE_PATH_1 || EUROPE_1 || EUROPE_NAME
        ||' ' || DEST_SERVER || DEST_PATH || DEST_EUROPE_1
  into ctlCode
  from ETL_CTL;
  UTL_FILE.PUTF(fileHandler, ctlCode);
  UTL_FILE.FCLOSE(fileHandler);
EXCEPTION
  WHEN utl_file.invalid_path THEN
    raise_application_error(-20000, 'ERROR: Invalid PATH FOR file.');
END;
/

Tags: Database

Similar Questions

  • How to import an excel xls file to oracle database PL/SQL?

    Hello, im having problems to import a xls file to oracle, someone knows an easy way or a script to import this database file? THX!

    Hello

    have converted your excel to CSV, convert csv, you must save the file as option Save as fall to the bottom of the list select CSV Comma-delimited. then try

  • Import from CSV file into oracle using pl/sql - sql loader 3.1

    Hello

    I am trying to learn how to import a CSV file in an oracle table. I tried the import utility in SQL Loader, but it generates specific lines of code to import each line. I would like a loop to go through the CSV file stored on my local disk and transferred it to my table.

    I tried the following, but not luck
    DOWNLOAD THE DATA
    INFILE 'sample_csv.csv '.
    IN THE TEST TABLE
    FIELDS TERMINATED BY ', '.
    ;

    951716 wrote:
    Hello

    I am trying to learn how to import a CSV file in an oracle table. I tried the import utility in SQL Loader, but it generates specific lines of code to import each line. I would like a loop to go through the CSV file stored on my local disk and transferred it to my table.

    line-by-line is slow by slow.
    PL/SQL will be NEVER faster than simple SQL
    INSERT INTO MYTABLE SELECT * FROM EXTERNAL_TBL;

    http://www.orafaq.com/wiki/External_table

  • How to create .wmv (Windows Media Files) files in Adobe Media Encoder.

    How to create .wmv (Windows Media Files) files in Adobe Media Encoder. I use an iMac computer.  I need to deliver .wmv files to my client.  How can we get this option in Adobe Media Encoder?  It is not an option, or I don't know where to look.  Help, please.

    Hello

    Check here: Help! SOUL CS6 WMV Codecs missing on MAC OS

    But I think that Flip4Mac will allow you to do.

    Thank you

    Regalo

  • How to create a shared library of Qt and use it on App without a head?

    Hi all

    I'm experimenting with some waterfalls headless basic application development, and I just hit another problem of blocking.

    I want to create a Qt library with some shared code between the head and user interface elements.

    That's what I did:

    1. created a new application without head the wizard project
    2. created a new library shared by using the wizard project. Adds a simple C++ (Qt not) class
    3. Set up the two parts of the Headless App to use the shared library ("Library in the workspace project" option from the "Add library...) (' Assistant).   Everything compiles and works very well so far.
    4. Now, I want to use the shared library Qt. I choose 'Library of the Standard BlackBerry platform' and ' platform > Qt Core "from the «add library...» "Wizard. Now, I had this error on the shared library project: C:\dev\bbndk\host_10_2_0_15\win32\x86\usr\bin\ntoarm-ld: could not find lQtCore.

    How to create a shared library of Qt and use it on App without a head?

    In fact, I would also use other NDK libraries on library shared as lbbdata and libbbdevice.

    I expect that workers would deal with all the problems for me. As an improvement, I suggest you add the selection screen platform library of the Wizard "Add library...". «the wizard «Shared Library Project»

    There is a model of library project

    https://github.com/BlackBerry/Cascades-community-samples/tree/master/Cascades-library-template

    Unfortunately, the library create Assistant isn't really useful #t

    There is also a great series on using headless headless library and user interface:

    http://devBlog.BlackBerry.com/2014/02/a-flexible-architecture-for-enterprise-mobile-applications-par...

  • How to create a sidecar.xml file?

    Hello - I used generator sidecar very rad Johannes and instructions from adobe on how to download the file, but can't seem to make it work. I have a feeling that it's because they both start with a hypothesis:

    "Use a text editor or an XML Editor to create a file sidecar.xml..." »

    "Writing in a sidecar.xml file.

    How to create the file sidecar.xml of origin, in which paste the metadata generated by Johannes tool?

    http://projects.nordsueddesign.de/sidecarxml/#

    http://help.Adobe.com/en_US/digitalpubsuite/using/WS67cb9e293e2f1f60606c7754128c7a9c00e-7F ff.html

    You use the web interface of the xmlsidecar generator made by Johannes Henseler and push the button it "generate". Copy paste in a plain text file and then replace tex extension txt to xml format. This is how you do a sidecar.xml the easy way.

    Subsequently, yo have to import "multiple files" (or "multiple files"... my DPS is a Spanish) Folio Builder.

    If the folder revolve correctly, folio Builder will start to swallow the sidecar data and download articles.

    This time, while posting, my pc did this with a hundred articles. As happy and busy as a Beaver in heat

    Gustavo (detachment of Madrid)

  • How to create a new Excel file programmatically

    Hello!

    I'm documenting the data acquired permanently in an excel file, what I have to do is to create a new file, excel automatically when the size of the previous file exceeds a certain limit lets say 1 MB.

    I tried using the function ' create/open a file ' simple and function "Write in the spreadsheet file" to create the new excel file. I don't create a file but when I open the file, it says the file format is not what you have opened with.

    Also, when the new file is created, three new worksheet must be added programmatically with the name of the predefined spreadsheet and also the column headers for each worksheet must be added.

    I also use "Labview Report Generation Toolkit for Office."

    Kind regards

    Reeves

    @Reese

    Thank you! I would like to see the copy of the file and rename it.

    PSI has managed to create a new excel file myself and I have attached the solution in this post.

    Reeves

  • How to create the listener.ora file

    Hi all

    My emca start dbconsole... successful because I do not have in network/admin listener.ora. My interlocutor only runs on the default config

    I can't run gui netca bacause I connect only remotely using PuTTY.

    I want to run in silent mode netca to create the listener.ora file... can you give me response.file of the sample for netca?


    Thank you

    Published by: yxes2013 on 3.5.2013 04:14

    I meet emca error before and it is just resolved when I created lisnter.ora, so I want to try it.

    I doubt that listener.ora was the cause.

    Although experience is a better teacher.

    No, trying to find the cause of a problem is a better teacher, just try things at random - it's a good way to teach you things like "emctl start dbconsole does not work without a listener.ora", which is clearly false.

    Once start emca

    The command is not 'emca,' maybe that's your problem.

    We don't know, because you have not copied/pasted something here, including the error message

  • How to create the existing XML file bar chart

    Hi all

    I'm new to flex, I need your help to develop a flex during approx. dashboard we file sample.xml. using what I have to create a bar chart or a pie chart.

    Please help me

    The XML looks like this...

    <? XML version = "1.0" encoding = "utf-8"? >
    < user name = "123412343" >
    < name >
    < name > these < / lastName >
    Vijay < firstName > < / name >
    < / fullName >
    < Preferences >
    < modWidth > 235 < / modWidth >
    < modHeight > 250 < / modHeight >
    < > 1650 totalWidth < / totalWidth >
    < > 1650 totalHeight < / totalHeight >
    < modsX > 4 < / modsX >
    < modsY > 2 < / modsY >
    < / Preferences >
    < id module = "Status2" >
    < fenetreouvrir > true < / fenetreouvrir >
    < pointsToShow >
    < label p = 'Proposals' / >
    < label p = "Project" / >
    < label p = "DEP Ptba" / >
    < label p = "EPA Ptba" / >
    < / pointsToShow >
    < dataSetsToShow >
    < label > 2006 < / label >
    < label > 2007 < / label >
    < / dataSetsToShow >
    < / module >
    < / user >

    convert this ArrayCollection collection called chartData xml file

    var charOption:String = 'totalHeight '; / Use this to set the yField property...



    <>
    dataProvider = "{chartData}.
    categoryField = "time" / >






  • How to create a link on the web to use in an e-mail?

    I don't know how to create a link on the web that I can put in the e-mail addresses. Could you help me please? I know it must be very simple, because thousands of others do regularly. Thank you.

    Katy Anderson

    You can use file-> Send link or copy the web address of the address bar and paste it into an email.

    You are using an older version of Firefox (3.0.7) - you need to update as soon as possible

  • How can store a very large file in Oracle XML DB?

    Hello
    I m looking for a quick way to store an XML file to an oracle 10 g XE. I was trying to store the file of 500 KB in the database as an xmltype or a clob, but I still have the same error: "ORA-01704: string literal too long." I m looking for a long time the possibility to store this file and one other (113 MB) in the database. I had sought by google to see if there is no solution, and the unique solution is to splitt the document in a loop (due to the limit of 32 KB) instruction. But this solution Don t allow storage with an XML schema and must slow down.
    Here is an example how I did it (but it didn t work):
    create table world (Nr int. xmldata xmltype);
    INSERT INTO global VALUES (1, 'big xml file');
    I would also try the alternative with a variable binding as follows:
    create or replace PROCEDURE ProcMondial IS
    poXML CLOB.
    BEGIN
    poXML: = 'large xml file ";
    INSERT INTO the world of the VALUES (1, XMLTYPE (poXML));
    EXCEPTION
    WHILE OTHERS THEN
    raise_application_error (-20101, ' Exception occurred in the :'|| global procedure) SQLERRM);
    END ProcMondial;
    I'm also getting the same error: long chain!
    I use developer sql for the query.
    Please help me, I m desperate.
    Thank you!

    Michael

    This should help
    {: identifier of the thread = 887934}

  • How to create the ellipse path gradient to PDF using object code

    Hello

    Someone tell me how to create PathGradient ellipse in pdf.i found the way to shadow Rectangle in pathgradient, but the ellipse can't shadow as pathgradient, if you know tell me please,

    Kind regards

    Sasi kumar S.

    Please refer to How to create LInearGradient in pdf format for why this isn't the right forum. Thank you.

  • How to load the date and time from text file to oracle using sqlloader table

    Hi friends

    I need you to show me what I miss loading date and time text file in a table oracle using sqlloader

    It's my data in this way (c:\external\my_data.txt)
    7369,SMITH,17-NOV-81,09:14:04,CLERK,20
    7499,ALLEN,01-MAY-81,17:06:08,SALESMAN,30
    7521,WARD,09-JUN-81,17:06:30,SALESMAN,30
    7566,JONES,02-APR-81,09:24:10,MANAGER,20
    7654,MARTIN,28-SEP-81,17:24:10,SALESMAN,30
    my table in the database emp2
    create table emp2 (empno number,
                      ename varchar2(20),
                      hiredate date,
                      etime date,
                      ejob varchar2(20),
                      deptno number);
    the code for the control in this path (c:\external\ctrl.ctl) file
    load data
     infile 'C:\external\my_data.txt'
     into table emp2
     fields terminated by ','
     (empno, ename, hiredate, etime, ejob, deptno)
    This is the error:
    C:\>sqlldr scott/tiger control=C:\external\ctrl.ctl
    
    SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 31 09:45:10 2010
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    Commit point reached - logical record count 5
    
    C:\>
    any help that I enjoyed

    Thank you

    Published by: user10947262 on May 31, 2010 09:47

    load data
    INFILE 'C:\external\my_data.txt '.
    in the table emp2
    fields completed by «,»
    (empno, ename, hiredate, etime, Elysa, deptno)

    Try

    load data
     infile 'C:\external\my_data.txt'
     into table emp2
     fields terminated by ','
     (empno, ename, hiredate, etime "to_date(:etime,'hh24:mi:ss')", ejob, deptno)
    

    This is the error:

    C:\>sqlldr scott/tiger control=C:\external\ctrl.ctl
    
    SQL*Loader: Release 10.2.0.1.0 - Production on Mon May 31 09:45:10 2010
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    Commit point reached - logical record count 5
    
    C:\>
    

    This isn't a mistake, you can see errors in the log file and bad.

  • How to create the associated program file?

    while I want to play the game on my computer, I got a notice, "" this file does not have a program associated with it for the execution of this action.create an association in the set associations control panel please how do? "

    or what program I have to choice to run this game

    Hey abetampumargana,

    Reading your question, I have found a thread which I think will be very useful for you.
    In this thread, the original poster has a similar problem and it is fixed with the steps provided. Look at this thread and try some of these steps. If you have any questions, return to this topic and explain what were your results. Be sure to include all the details that you can when you describe your results.
    Thanks for posting of Microsoft Answers! Good luck with the troubleshooting.
  • How to create multi page PDF file of AI mode saved file?

    Hi all...

    Nice day!

    I wish someone can help (response) me on the recording of the AI file in PDF format as a multi-page view.

    I have log in the following adobe the instraction, but still can not very well how to choose the Save < type > as multi-page,.

    * Selact 'Multi Create PDF' page is something when the wrong?

    My goal is to see in Adobe Reader as scroll Multi page1 page2 and page3.

    Help, please...

    Best regards

    David Chan

    David

    What version of the AI you have you're Mac or Windows?

    What version of Acrobat?

Maybe you are looking for

  • Version? 3.0.0.1002 or 6.18.0.105

    I use 2 computers - work & home Skype version 3.0.0.1002 installed on my work computer. Skype version 6.18.0.105 is installed on the computer at home. 3.0.0.1002 seems to be the latest version. When I ask 3.18.0.105 update I get the message that Skyp

  • Satellite L30 - question video card update

    Hey guys! I have a Toshiba Satellite L30-113 and I am very happy with the way it looks and works. I managed to update the 3 GB RAM, the processor is in a pretty good shape, although it is only 1.7 GHz. Now, my only problem is that the video card, the

  • impression of 8000 poor quaility and blue lines

    Jet office pro 8000 color printing quaility with blue lines all of a sudden.  I used a non HP cartridge and switch to a HP one and the problem is persisiting.

  • WRT610N Self reset on own

    Hello I have used linksys for several years and most of the time always happy but this new unit price starting to upset me. I have a WRT610N new from BestBuy 'two weeks old' because my house is heavy wireless WEP 64 (old XBOX, XBOX 360, 2 x 2200 DMA,

  • Paper jam in the printer HP Deskjet 3520 e-All-in-One (model SNPRH-1102)

    I had been using HP Deskjet 3520 e-all-in-one printer over a year until yesterday the printer suddenly jammed paper. I have some ideas out of A4 paper to let the printer works normally again. I need printer for printing currently. Please help, anyone