Arguments in function passed through shell script

HI all,
I have a shell script test.sh
it contains the following
A=$1
B=$2
C=$3
D=$4
sqlplus usr/pwd<<eof
a varchar2(10);
b varchar2(10);
c date;
d date;
a:='$A';
b:='$B';
c:='$C';
d:='$D';
func(a,b,c,d(;
eof
func() defbn
func(name varchar2,trc varchar2,dt1 date,dt2 date)
end;
When icall test.sh as
./test.sh xyz 0100 01-NOV-09 06-NOV-09
It appneds dt1 with 06-NOV-09 and dt2 remains null.
It should be like:
dt1=01-NOV-09
dt2=06-NOV-09
inside function
Thanks

Are you sure there is no problem in SQL function *"func"* that you are calling?
You haven't pasted the function code so can't really comment on that.
Below test shows that it works really fine:
kallo:DZHLHFC1> cat 1.ksh
A=$1
B=$2
C=$3
D=$4
echo "Shell vars = $A,$B,$C,$D"
sqlplus -s username/pass<<eof
alter session set nls_date_format='DD-MON-YY';
set serverout on size 10000
declare
a varchar2(10);
b varchar2(10);
c date;
d date;
begin
a:='$A';
b:='$B';
c:='$C';
d:='$D';
dbms_output.put_line('');
dbms_output.put_line('SQL vars =' ||a||',' ||b||',' ||c||',' ||d);
end;
eof
kallo:DZHLHFC1> ./1.ksh xyz 0100 01-NOV-09 06-NOV-09
Shell vars = xyz,0100,01-NOV-09,06-NOV-09
Session altered.
SQL vars =xyz,0100,01-NOV-09,06-NOV-09
PL/SQL procedure successfully completed.

Similar Messages

  • Creating user account and setting password in Solaris9 through shell script

    I need to create and set password of user through shell scripts.
    User can be added successfully through "useradd" command but password cant be set through "passwd" command in script.
    Is there any other alternative for the same.

    Hi,
    Did you get the answere for this ? I have the same problem as urs , like I want to creat the users by using useradd and want to hardcode there password in one script.
    But I cant use expect utility which would have made my work easier

  • Reading contents of asm through shell script

    How to read contents of asm through shell script?
    Please paste one small example also.
    Thanks
    Bala

    Hello Bala,
    The ASM contents is not visible from the operating system or its utilities. Only visible to database instances, RMAN, and other Oracle-supplied tools.
    Please see http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/glossary.htm#sthref4105
    Regards,
    Rodrigo Mufalani
    http://mufalani.blogspot.com

  • Calling sql through shell script

    How do i call a sql file through shell script in unix ?

    Rahul India wrote:
    export ORACLE_HOME=$ORACLE_BASE/product/10g
    cd $ORACLE_HOME
    set `sqlplus -s <SCHEMA_NAME>/<SCHEMA_PASSWORD> <<EOF
    @r_100.sql
    exit;   
    EOF`THIS SCRIPT IS OK?You'll also need to set ORACLE_SID
    And I don't know why everyone is putting the reference to sqlplus inside a "set" valuation, nor why they are putting the reference to the script in a redirected input stream. All you need is
    sqlplus -s user/password  @r_100.sqlAnd to insure the invironment is correctly set:
    export ORACLE_SID=whatever
    export ORAENV_ASK=NO
    . oraenv
    unset ORAENV_ASK=NO
    sqlplus -s user/password  @r_100.sql

  • How to execute sql-queries through shell scripting in linux?

    How to execute sql-queries through shell scripting in linux?

    http://www.oracle.com/technology/pub/articles/saternos_scripting.html
    Two simple examples:
    #!/usr/bin/env bash
    set_orafra () {
       orafra=`echo 'set heading off
       select name from v$recovery_file_dest;
       exit' | sqlplus -s / as sysdba`
    set_orafra
    echo $orafra
    #!/usr/bin/env bash
    export ORACLE_SID=instance_name
    export ORACLE_HOME=/path_to_oracle_home_directory
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    export PATH=/$ORACLE_HOME/bin/$PATH
    $ORACLE_HOME/bin/sqlplus -s <<EOF
    connect scott/tiger@my_instance_name
    INSERT INTO table VALUES (sysdate);
    exit
    EOFEdited by: Markus Waldorf on Sep 17, 2010 12:19 AM

  • How to Prompt for User/Pass Running Shell Script Remotely through ARD

    So I finally got my Active Directory Script working! However, I realized that I'm not the only one going to be running this script and to have my user name and password in the script itself is beyond foolish. While I know it's possible just to have whoever's running the script to manually add their username and password, I'd prefer to have prompts to make things easier for the rest of my team.
    Here's my current script. I've tested it on the machine I'm connecting to Active Directory and it works fine if you run it on the machine itself in terminal. However, I'm going to be doing this on about 150 machines and the whole point of the script is to do it remotely.
    #! /bin/bash
    MACNAME=$(scutil --get ComputerName)
    read -p "User Name: " USER
    read -p "Password for $USER: " PASS
    dsconfigad -add "CORP.DOMAIN.NET" \
    -username $USER \
    -password $PASS \
    -computer $MACNAME \
    -mobile disable \
    -mobileconfirm disable \
    -localhome enable \
    -useuncpath enable \
    -shell /bin/bash \
    -ou OU=Macs,CN=Computers,DC=corp,DC=DOMAIN,DC=net \
    -force \
    -localpassword "PASSWORD" \
    -groups "GROUPS"
    When I run the UNIX script through ARD to a machine, I get no prompts for USER or PASS. In fact, it gives me the following error "dsconfigad: Authentication server encountered an error while attempting the requested operation. (5202)" So it's not asking for a user name and password.
    Is there any way to make a shell script prompt you for a User Name and Password when you're sending commands remotely through ARD? Or is there another way to do this?
    Any suggestions would be greatly appreciated.
    -rks

    Best solution is to create an account that is exclusive to binding machines.  By doing this, you can embed the user name and password in the script.  Heck, you can post it on your website.  If the account is configured properly, it will only be able to create machine records in a defined container.  If you are mixing Macs and PCs in your AD domain, I also recommend creating an isolated container for your Mac records.  Now, the account has even less access rights as you can make it so it only has rights to the Mac container.
    Otherwise, ARD does not prompt.  You can play around with an expect script but the reality is that you are still embedding the credentials in the script so it really does not achieve what you want.  ARD is not an interactive shell scripting tool.  It is more a fire and forget.
    Reid
    Apple Consultants Network
    Apple Professional Services
    Author "Mavericks Server – Foundation Services" :: Exclusively available in Apple's iBooks Store

  • How to Call Multiple Sessions through Shell scripting

    Dear Members,
    I have a scenario where I load data into target table from 20 different source tables.
    For this I have written three procedures where there exists an bulk insert executed on a same table in every procedure. Now I have to call these procedures simultaneously so that
    all three bulk loads are executed at once in different sessions.
    For this I have to write a shell script which opens 3 different sessions and execute all these packages at once.
    Can you guide me through.

    When you call sqlplus in your shell script, put a & at the end so that it runs the SQL scripts in the background. For instance:
    #!/bin/bash
    ...oracle home stuff
    $ORACLE_HOME/bin/sqlplus user/pass @script.sql &
    $ORACLE_HOME/bin/sqlplus user/pass @script2.sql &
    $ORACLE_HOME/bin/sqlplus user/pass @script3.sql &

  • Import through Shell Scripts

    Hi Friends ,
         I have run shell scripts for importing from my local system through TELNET It was running fine on the server.But now I need to import the same dump file into my local database.The ORACLE_SID refering to the database in the server is same as the database in my local system.
    So how to tell through the scripts that I need to connect to my local system.
    If anyone could explain this it could be of great help.
    Regards
    Marlon.

    Hi
    It depends on how your script is taken care on syntax of import/export. I can tell you exaxtly if you can past me your import/export shell script. However for your knowlege, you can specify ORACLE_SID with export/import with following ways
    1) exp user/pass@ORACLE_SID file=<file_name> log=<logfile>
    imp user/password@ORACLE_SID file=<dumpfile> fromuser=<username> touser=username
    if you are at same box where oracle server is intalled then you need not to mention oracle_SID but make sure that ORACLES_SID is configured in environment variable.
    All the best
    Alok

  • Catch a value from a pl*sql function in a shell script

    Hi all,
    I have a shell script that simply calls the following pl*sql function.
    echo "execute scott.my_pkg.test('FDLmaster');\n exit;" >./pippo.sql
    sqlplus scott/tiger @/fidcap_ftp/FDL/SCRIPTS/pippo.sql
    What I have to do to catch the value returned from the function test?
    Thanks in advance
    best regards
    Mario

    SQL> create or replace function do_something return varchar2 is
      2  begin
      3      return ('Something');
      4* end;
    SQL> /
    Function created.
    SQL> select do_something from dual;
    DO_SOMETHING
    Something
    SQL> save pippo
    Created file pippo.sql
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    [linuxas tmp test10]$ echo exit >>pippo.sql
    [linuxas tmp test10]$ VAR=`sqlplus -s scott/tiger @pippo`
    [linuxas tmp test10]$ echo $VAR | cut -f3 -d" "
    Something
    [linuxas tmp test10]$

  • Random SP2 error when starting oracle process through SHELL script

    Hi All,
    I am trying to process data in n-Number of tables through a package. The package is called through a shell script to create start data processing. All calls to the package are in a sql script which is basically exec calls-
    exec package.process ('T1','some param');
    exec package.process ('T1','some param');
    exec package.process ('T..n','some param');
    I have a shell script which I use to execute commands from the sql script. There is a reason behind using shell script. For some strange reason, I keep on getting -
    ERROR: logon denied - check for valid user with valid privileges
    SP2-0640: Not connected
    SP2-0641: "EXECUTE" requires connection to server
    SP2-0640: Not connected
    for some EXEC calls. Problem is, errors are generated at random. So in one run, I get error for T10,T11 and then in next run I might get for some other tables.
    However, when I am running the sql script from the sql prompt, all calls to the package are executed without any problem.
    This makes me think, it is something to do with the way database connection being initiated through UNIX.
    Has anyone faced similar issue? Your help/gudence is much appreciated.
    DB: Oracle 10.2.0.5
    OS: SUN Solaris 10
    Thanks in advance.

    Login credentials are provided inside the shell script.
    I did put a sleep(10) after EOF but no help. As mentioned if I run script file from sql promt, it runs without any hiccup. So it is the connection through the UNIX that is causing issue.
    As pointed out by Sybrand, I agree that it does not make a sense to connect and commit after every sql statement. So decided to change the shell script and so far, the result from my initial tests on a sample data is quite encouraging. Hopefully I will have a solution.
    But it will be nice to know why SHELL is doing what it is doing!!
    Legacy prog are sometime big time eye-openers..;)

  • Calling sql script through shell script

    Hi All
    I am trying to run one shell script it will execute the sql file which is in UNIX box. Problem here i am facing is
    when i submit the program through front end it taking time to execute and the status in running even for hours and hours. Manually i am terminating the concurrent program.
    But when same shell script when i tried to execute in putty it generating the output with in seconds
    Can you help what may be the error? I used the syntax like this
    Can you help what may be the error? need to change any syntax
    Thanks
    Prem Raj Dasari
    Edited by: Sravprem on Sep 20, 2012 12:43 AM

    Pl post details of OS, database and EBS versions. In your shell script, insert this line as the first line
    set -xthen run the concurrent program and paste the contents of the log of the concurrent program here
    HTH
    Srini

  • In Automator, how can I pass a shell script output to Display Notification?

    In Automator, how can I pass a Run shell script output to Display Notification?

    Soemthing like this will work

  • Help regarding issue connecting to DB through shell script

    Hi,
    I have a Oracle 8.1.7 Database running on a AIX box. I am trying to truncate one table from within the shell script using here documents.
    Code section of my script -
    succ=`sqlplus -s ${USR} << EOF
    whenever sqlerror exit sql.sqlcode
    set feedback on
    Truncate table abc.xyz;
    exit;
    EOF`
    USR has been set as /. We have ops$ users in the database. So when I run this script using my id it runs fine. The problem seems to be coming when this runs as part of the batch job which runs under a different osuser. The error is -
    + + sqlplus -s /
    + 0< /tmp/sh164108.8
    succ=ERROR:
    ORA-01017: invalid username/password; logon denied
    SP2-0306: Invalid option.
    Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}] | [INTERNAL]
    where <logon> ::= <username>[<password>][@<connect_string>] | /
    SP2-0306: Invalid option.
    Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}] | [INTERNAL]
    where <logon> ::= <username>[<password>][@<connect_string>] | /
    SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
    I am not sure what is going wrong. I have tried and googled for the issue and it seems that the issue is coming because the osuser under which the job runs may not be setup to use "sqlplus -s /" ? Any help appreciated.
    Regards,
    Saurabh

    This is the forum for Oracle's SQL Developer tool, not for general SQL and PL/SQL questions.Questions like this will get a better response in the PL/SQL forum.
    Having said that, it looks likely that the other user doesn't have an ops$ account.

  • Automatic import process through shell script

    Hi all,
    oracle 10.2.0
    RHEL 4
    I have many export dump files in one directory exported from different schemas and different databases.
    I have to import them in different schemas in a single database.Ofcourse, I can manually import each file but to avod tedious work,i want to automate the task.I want linux do it for me.I wrote the below script but it works only for the first time.
    USR=system
    PWD=******
    for $i in `ls *.dmp`;do
    imp $USR/$PWD file=$i fromuser=test touser=`basename` $i
    done
    What else should i include in the script os that automatically oracle navigates through every dump file and import the database in the respective schema?
    Thanks

    Before trying a solution I have to understand something more...
    Are your dump file names <schema name>.dmp, e.g. user1.dmp, user2.dmp and so on, and you want to import into those schemas ? If so, is "fromuser=test" correct ? If not so, please clarify.
    And why "basename" ?

  • Send mail through shell scripts

    hi,
    I am working in oracle9i and solaris 5.8 . i need to send a mail using the following codes
    ORACLE_HOME=/oracle/u01/app/oracle/product/9.2.0; export ORACLE_HOME
    ORACLE_SID=oracle; export ORACLE_SID
    PATH=/oracle/u01/app/oracle/product/9.2.0/bin:/usr/bin:; export PATH
    MAIL=/var/mail/dbacoe; export MAIL
    BASE_SUPPORT_EMAIL=mail [email protected]
    DATA_DIR=/oracle/sunora/
    SHIP_IND=Lynn_FMLA.csv
    uuencode $DATA_DIR/Lynn_FMLA.csv 'Lynn_FMLA.csv' | mailx -s 'Shipping Ind' $BASE_SUPPORT_EMAIL
    me run this file in script.sh and i also give the full permission.. chmod 777 script.sh
    after running this script i didnt get any error...
    but in the mean time i didnt receive any mail...
    please expalin me how to send a mil along with attachments using the scripts above...
    Regs...

    try -
    uuencode $DATA_DIR/Lynn_FMLA.csv Lynn_FMLA.csv | mailx -s 'Shipping Ind' $BASE_SUPPORT_EMAIL
    No single quote around second file name.
    rgds

Maybe you are looking for

  • Euclid Symbol Bold and Italic fonts not working in Indesign CS5

    Hi I created some Maths Text books about 5 years ago in an older Adobe Indesign program. I now have to re-edit the files using Indesign CS5. The Euclid Symbol Bold and Italic fonts i used back in 2005 now do not display in Indesign 5 when i open up t

  • Multi Digital Signature

    Hi to all, I create a Form using Adobe LiveCycle Designer 8.2. The purpose of this form is to have multiple digital signatures from 4 different people. But when the first person fills the form and does a digital signature. The second, third and forth

  • Why is firefox crashing my pc out of the blue?

    I have a windows 8 Toshiba laptop. I've always used firefox for the past year since I got it, that's my choice of web-browsers but today something went wrong. I went open firefox and it crashed to the point where I couldn't even open the task manager

  • Strange characters showing up in Essbase Server pick list

    I have one user, that is logging into her Essbase spreadsheet addin and seeing all kinds of strange characters following each server name in the Server drop down list within the Essbase System Login window.  Any ideas what would cause this? What we h

  • Creating Dreamweaver templates in fireworks

    Hello there, I have just created a image in fireworks CS3 that i would like to use as the basic template in a website. Now i dont want it to simply be set as a background on the site, i am trying to put it into dreamweaver so that i can edit on top o