How to pass a procedure argument to the script from sqlplus and run

I would like to pass a procedure as a parameter to a file of sqlplus and run the procedure.

The file sqlplus, test.sql, looks like:
set serveroutput on
set verify off
set feedback off
set echo off

spool output.txt
begin
  dbms_output.put_line('Start~&1'||'~'||user);
  &1;
  dbms_output.put_line('END~&1');
end;
/
spool off
A simple procedure:
create or replace procedure proc1( p_arg in varchar2 default 'n' )
as
begin
  if nvl(p_arg,'n') = 'n' then
    dbms_output.put_line('Success');
  else
    dbms_output.put_line('Failed'); 
  end if;
end proc1;
/
In sqlplus:
SQL> @test.sql proc1  --This works
SQL> @test.sql proc('x')  --This doesn't work
SQL> @test.sql proc(''x'') --This also doesn't work
I should be grateful if you would help or alternatives.

Hello

If & 1 is:

proc ('x')

then

dbms_output.put_line('Start~&1'||'~'||user);

will be passed to the compiler as

dbms_output.put_line('Start~proc ('x')'||'~'||user);

where the quote before x is interpreted as closing the quote before you begin

It is an ideal opportunity to use Q-rating:

dbms_output.put_line ( Q'[Start~&1~]' || user);

Otherwise, use REPLACE to double apostrophes in & 1 before using it in the context of a literal string:

dbms_output.put_line ( REPLACE ( 'Start~&1~'||user
                               , ''''
                      , ''''''
                      )
                 );

Tags: Database

Similar Questions

  • All files generated by a coil in sqlplus receive ownership of oracle: dba instead of the user of the BONE started sqlplus and run the script. There's a file with users owners of BONES of the coil.

    All files generated by a coil in sqlplus receive ownership of oracle: dba instead of the user of the BONE started sqlplus and run the script. There's a file with users owners of BONES of the coil.

    Script launched in until OS user 'A' on the 'A' server which launches sqlplus, then connects to a remote database through a service of tnsnames.ora as another user of the database and the results of this script are spoulées on the server "A".

    The file queued on the old server is written with rw-rw-r: read write user, group read the writing, reading and possession header that is the user of the OS. The file queued on the new server is written to rw-r-r user: reading writing, reading group, public reading and ownership oracle: dba.

    "" The user then has no privileges to modify the file and continue the process of transmitting the file, editing and deleting the file for the next set of commands. This allows us to keep the possibility to migrate to the new server we are unable to process orders.

    $ORACLE_HOME/bin/sqlplus - s user/password@prd1 @./script/CustomScript/R12_OM_UFPC-oracle.sql

    Background: old server running 4.8, Oracle 10.2.0.4 OEL

    New server running OEL 6.5, Oracle 11.2.0.4

    Tested so far:

    File and update umask to 0002 instead of 0022 is now generated as rw-r-r. However, the property is still oracle: dba.

    Update of ownershipt of $ORACLE_HOME/bin/oracle.exe of oracle: oracle (edi added the user to the oracle group) and chmod 6751 oracle.exe. This created several problems where crucial scripts, that is to say of sqlplus failed to run.

    Added! chmod 755 output.file.name - OS user 'A' is not allowed to change to mod.

    Added! command cp MV output file and that generated the file as a user of the operating system: oracle. It is a potential work around in case of emergency, but the developer would have to rewrite the countless scripts.

    Any ideas?

    I have reproduced the behavior of the old server and am able to spool a file via sqlplus under OS user. No changes have been made on the remote database server. All the changes have been on the new server hosting a small 11.2.0.4 database on a server running OEL 6.5 32 - bit OS.

    (1) removed the sticky bit $ORACLE_HOME/bin/sqlplus using chmod u-s, g-s, o - s suggestion of Billy ~ Verreynne

    (2) modified the main group for the 'oracle' user match the user operating system applications, while maintaining membership in the groups 'oracle' and 'dba '.

    -We are dealing with here EDI processes, so the Group was called edi.

    (3) modified property of the files tnsnames.ora and listener.ora for oracle: edi

    (4) restart the receiver

    (5) disconnect / reconnect

    Script runs as expected, the output file contains the correct ownership and permissions.

    Thank you all for taking a look and offering options.

    -Josh

  • Passing arguments to the script

    Hello

    I have created a dialog box load the files in the folder and when I click the button I run another script of command StartScript (...)

    How can I pass arguments to the script (the paths of files)?

    Thank you

    Hey OzShimon,

    As long as you use a tiara predefined global variables (T1, T2,...)  you'd be fine. You can also define user variables (.) SAV files) or even to declare your own global variables with: call GlobalDim ("Myname").

    These variables are not re-initialized until you restart the script engine. So just change 'obj' for T1 your test should work

    ' Dim obj

    Void Button1_EventClick (ByRef This)

    T1 = "Hello World".

    Call ScriptStart("C:\Users\Oz\Desktop\test.vbs")

    End Sub

    * the script code (test.vbs):

    Call MsgBox (T1)

    Kind regards

    Javier

  • How to pass an xml CDATA in the string element when OSB call a webservice?

    How to pass an xml CDATA in the string element when OSB call a webservice?

    I have a business service (biz) this route to exploitation of a Web service.

    An example of this legacy Web service request:
    < soapenv:Envelope xmlns:soapenv = 'http://schemas.xmlsoap.org/soap/envelope/' xmlns: ex = "example" >
    < soapenv:Header / >
    < soapenv:Body >
    < ex: run >
    < ex: arg > <! [CDATA [< searchCustomerByDocumentNumber >
    < documentNumber > 12345678909 < / documentNumber >
    [[< / searchCustomerByDocumentNumber >]] > < / ex: arg >
    < / ex: run >
    < / soapenv:Body >
    < / soapenv:Envelope >

    type ex: arg is a string.

    How to pass this structure CDATA webservice in OSB?

    Steps to resolve this problem:
    1 create an XML schema. For example:


    elementFormDefault = "unqualified" >


              
                   
                        
                             
                             

                        

                        
                             
                        

                   

         

         

         
         

    With this XSD, XML can be generating:


    documentNumber

    2 create an XQuery query to create a ComplexType searchCustomerByDocumentNumber. For example:
    (: pragma bea: element global-element-return = "searchCustomerByDocumentNumber" location = "searchCustomerByDocumentNumber.xsd" ::))

    declare namespace xf = "http://tempuri.org/NovoSia/CreateSearchCustomerByDocumentNumber/";

    declare function xf:CreateSearchCustomerByDocumentNumber($documentNumber_as_xs:string)
    as {(searchCustomerByDocumentNumber)}

    {$documentNumber}

    };

    declare the variable $documentNumber as XS: String external;

    XF:CreateSearchCustomerByDocumentNumber ($documentNumber)

    3. in your step in proxy pipeline add to assign the created the XQuery function call from the number of the document of your payload.
    Assign to a variable (for example: called searchCustomerByDocumentNumberRequest)

    4. create an another Transformation of XQuery (XQ) to create a request to the existing Web service. For example:
    {fn - bea: serialize ($searchCustomerByDocumentNumberRequest)}

    For more information about xquery Serialize function:
    41.2.6 fn - bea: serialize()
    You can use the fn - bea: serialize() function if you need to represent an XML document as a string instead of as an XML element. For example, you can share an XML document through an EJB interface and the EJB method takes the string as an argument. The function has the following signature:

    FN - bea: serialize($input as item()) as xs: string

    Source: http://docs.oracle.com/cd/E14571_01/doc.1111/e15867/xquery.htm

  • How to add white Gaussian noise to the picture of her and her negative?

    How to add white Gaussian noise to the picture of her and her negative?

    Is that what you're trying to accomplish:

    TO:

    Here's the code to do.

    Michel

  • How can I add a program to the start selective msconfig and how to delete a startup item?

    How can I add a program to the start selective msconfig and how to delete a startup item? Once, I knew but forgot.

    Remove items not controlled in MSConfig
    http://www.PCWorld.com/article/255514/remove_unchecked_items_from_msconfig.html

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/default.aspx/KB/929135

  • How can I crossgrade my CS5 of the license from Windows to Mac OS?

    I want to switch a computer laptop windows to Mac and still use may CS5. How can I crossgrade my CS5 of the license from Windows to Mac OS?

    Best regards, Viktor

    You can not.  Platform swaps are supported only for the most recent published suite which is currently CS6.

  • I have used Muse on a 30 trial and created a site and added my own domain name and it is now online. I now want to muse and edit and add a few things, but I don't know how to do it? I opened the software, go file and tried to open the is

    I have used Muse on a 30 trial and created a site and added my own domain name and it is now online. I now want to muse and edit and add a few things, but I don't know how to do it? I open the software, go file and tried to open the site, but there is nothing there?

    Please provide a screenshot of the design view after opening the file, also the url of the site online.

    In case the trial is expired, you need to upgrade your membership/registration.

    Thank you

    Sanjit

  • I would like to bring to the text from Word (and the web) which is already a hypertext link in InDesign. How can I do it while keeping the links active?

    I would like to bring to the text from Word (and the web) which is already a hypertext link in InDesign. How can I do it while keeping the links active?

    Whenever I have to copy and paste from the web or Word it removes hyperlinks.  And when I try to do in 'Place' ing a Word document in my InDesign project that it retains formatting with it, the rectangles around the text.

    I have the latest version of InDesign.

    Any help is appreciated.

    Copy-paste might not include the shaped. A regular import using square is the best way.

    The rectangles around the hyperlinks are just to indicate that they are links - they do not print, but they appear in your PDF.

    You can delete them by double clicking on the hyperlink in the hyperlinks Panel and select "Rectangle Invisible" as the type.

    In general, Word formatting of hyperlinks - blue text, underline - with a character Style. If you want to remove or change the formatting, all you have to do is to change the character style. My experience, however, is that you need to check all the hyperlinks because no reason apparent, sometimes they appear in the document without the character style.

  • trying to print from quicken and I get an error message that says that I have to be in the mode of administration and run restore pdfdriver.ba

    I try to print from quicken and I get an error message that says that I have to be in the mode of administration and run restore pdfdriver.bat.  I don't know what is a mode of administration, nor I know what is a pdfdriver.bat. Can anyone help?

    Hello

    1. what operating system do you use?

    2. what web browser do you use?

    3. have you made changes on your computer?

    4. What is the brand and model of the printer?

    5. are you able to print from other applications?

    When a printer is installed, members of the Administrators group on the computer are given permission to manage the printer by default. If you have an administrator account, you can probably change the printer properties. Otherwise, you must obtain permission to manage the printer before you can change the properties of the printer.

    Method 1:

    If you are using, I suggest you send the link to learn how to open a session as an administrator.

    How can I connect as an administrator?

    http://Windows.Microsoft.com/en-us/Windows7/how-do-I-log-on-as-an-administrator

    Method 2:

    I also suggest you to see link and check.

    Error when printing to a PDF file: PDF driver is not found

    http://Quicken.Intuit.com/support/help/error-when-printing-to-a-PDF-file--the-PDF-driver-cannot-be-found/GEN82191.html

    Cannot print from Quicken

    http://Quicken.Intuit.com/support/help/not-able-to-print-from-Quicken/GEN82237.html

  • at the start of geta pop up = document Manager service could not be started, check the filter of the vault is loaded and run

    starting to get a pop up = document Manager service could not be started, check the filter of the vault is loaded and run

    Hello

    ·        Since when are you facing this problem?

    ·        Remember to make changes to the system?

    Method 1:

    I suggest you uninstall and reinstall download System Manager and check if the problem is resolved. See the article mentioned below.

    How to change or remove a program in Windows XP

    http://support.Microsoft.com/kb/307895

    Thanks and regards.

    Thahaseena M
    Microsoft Answers Support Engineer.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • We had a power outage in our area, the computer was on and running, got the blue screen of death with the following: __0x000000C2, 0 x 00000043, 0xD6C61000, 0 x 00000000, 0 x 00000000 BAD POOL CALLER

    We had a power outage in our area, the computer was on and running, got the blue screen of death with the following:
    0X000000C2, 0 X 00000043, 0XD6C61000, 0X00000000, 0X00000000 BAD POOL CALLER

    If you have not saved your data and you want to start the computer with Linux Livecd such as Knoppix and copy your data files on an external hard drive. It is a precautionary measure before the step follows because things happens. ;-)

    Then do a repair installation.

    http://www.michaelstevenstech.com/XPrepairinstall.htm

    If the repair installation does not work, test the equipment to ensure that none have been damaged during the blackout and then do a clean install of Windows.

    http://www.elephantboycomputers.com/page2.html#Hardware_Tshoot

    http://michaelstevenstech.com/cleanxpinstall.html - Clean install - how-to
    http://www.elephantboycomputers.com/page2.html#Reinstalling_Windows - what you will need at hand

    If all goes well, no equipment was damaged during the shutdown. Consider buying a power supply (battery backup). APC and Belkin are good; for a computer, simply spend about $60. MS - MVP - Elephant Boy computers - don't panic!

  • I am trying to install some Elements 9 on a new computer. I downloaded the files, .7z, .exe and run the installer. When I try to open the items, I get an error message "please the product using Setup.exe in the root folder of installation/uninstallation.

    I am trying to install some Elements 9 on a new computer. I downloaded the files, .7z, .exe and run the installer. When I try to open the items, I get an error message "please the product using Setup.exe in the root folder of installation/uninstallation. I did it

    Hello

    Please see error: 'Please install Adobe installation using Setup.exe' when you install non-English versions of Adobe Creative Suite 3

    Hope that helps!

    Kind regards

    Sheena

  • I got a mac book pro with Yosemite. Today started to ask me to enter in the first series. Uninstalled all the app from adobe and I loggin and install all the app and still the problem

    I got a mac book pro with Yosemite. Today started to ask me to enter in the first series. Uninstalled all the app from adobe and I loggin and install all the app and still the problem. What do I do?

    If you are prompted for a serial number in the creative clouds, see this link:

    https://helpx.Adobe.com/creative-cloud/KB/CCM-prompt-serial-number.html

    Guinot

  • Using the script for import and export

    Hello

    Can any such a me what is the use of the script for import and export.

    After you move the pages from / to server what is the need to import / export command.

    export/oracle/apps/ap/setup/webui/customizations/site/0/SetupPG - rootdir < destination path > - user < database username > - password < database password > - dbconnection "(description = (address_list = (address = (community = tcp.world) (protocol = tcp) (host = < host name > (port < port id > =))) (connect_data = (sid = < sid >)))".) "

    Thanks in advance,
    Roselyne

    Hi Flo,

    Page and the region are stores in database import/export we really want pages/areas to store in the database.

    Thank you
    -Anil

Maybe you are looking for

  • A lot of apps is not found in the app store

    Since a week or two when I search for some applications in the app store they do not appear in the search results more. If I got them until I find them under "purchases" and can the re - install. Even a few apps I have installed will not be displayed

  • HP Officejet Pro 7555: HP Solution Center

    I'm trying to find a download for the HP for my HP Officejet Pro 7555 Solution Center, if I can do scanning.  Any help would be appreciated.    I downloaded a file from the HP customer service, but when it goes to install, it says that it is newer da

  • TCP/IP read returns new data with a huge delay

    Hello I did a server using LabView application. The application translates simplified data of a device and translated them into more complex protocol with another party. The problem is that responses from my application take too long. I tried to anal

  • Aspire V Nitro Spacebar malfunctions

    Thespacebar on this laptop does not work. Is their a driver which can be downloaded to increase the space bar thesensitivity or is the only way to send the itin for repair. As you can see the fromthis, the spacebarsometimesworks message and sometimes

  • WAG160N, names of host and Ubuntu 9.04

    Hi all again,. Next problem, I can now TEU hosts names to access my network, but only under Windows. I also have Ubuntu, but cannot through the network with host names, I thought that the problem would have been fixed by applying the "Spca" work arou