?
Solved

parameters in the shell?

Posted on 2011-11-01
15
Medium Priority
?
376 Views
Last Modified: 2012-05-12
Hi experts, I have a stored procedure that receives, 1,2,3,4 or 5 parameters. This stored procedure is called from a shell, my question is how should I handle the parameters in the shell?
SH-EXP-04-SERV-.txt
SP-EXTRAE-SERV-.txt
0
Comment
Question by:enrique_aeo
  • 7
  • 4
  • 4
15 Comments
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37062301
We need quite a bit more information:

How do you want to handle them?
Where do they come from?
What are they?

Posting the proc and the script isn't much help without the supporting information.
0
 
LVL 31

Accepted Solution

by:
farzanj earned 1500 total points
ID: 37062308
You can receive parameters from command line like $1, $2

If you would like -a -b kind of command line parameters, you can use getopts.

let me know what you want
0
 

Author Comment

by:enrique_aeo
ID: 37062315
of course, for example
 1. if the shell command without any parameters the sp is executed with the dates of the previous day.
 2. But what happens if I send a date range? sp if you can solve, but in the shell should I change something?
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 1500 total points
ID: 37062338
Try something like

if [[ -z $1 ]]
then
    #do something
else
    date1=$1
    date2=$2
fi
0
 
LVL 78

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 500 total points
ID: 37062343
Define ALL the allowed parameters for the shell script and the order they will be entered or with what 'options' for getopts like suggested above.

Date range?  Is the procedure set up to handle date ranges?  I don't see any DATE input parameters.

This question sounds like something better given to a consultant since appears to be a much larger project than a simple question for a Q&A site.

We can help with how to pass parameters in to a shell script but not how to rewrite all your code.
0
 

Author Comment

by:enrique_aeo
ID: 37062344
where $ 1 declare?
0
 

Author Comment

by:enrique_aeo
ID: 37062354
the stored procedure if it supports sending parameters of type Date
do not need to re-write my code, just show me where I make the change
0
 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 1500 total points
ID: 37062355
./scriptname 20110801 20110911

$1 will be set to the first date and $2 would receive the second.

If you don't have any $1 and $2 would pass the -z test
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37062570
>>just show me where I make the change

Please answer the questions asked:  re: http:#a37062343

We need to know the script parameters allowed, the order of them, if you want to use command line options like '-x', etc...

Generically shell positional parameters is answered above.


0
 

Author Comment

by:enrique_aeo
ID: 37067800
Thank you very much experts, I am very gratefull, I can see that the shell is working with the parameters (date range  20101123), I attached a picture, since the sp returns nothing, ie
 1. I run the sp with parameters and return data
 2. I run the shell with the parameters and does not return data, Please help me with the shell
la-foto.JPG
0
 
LVL 31

Expert Comment

by:farzanj
ID: 37069354
Show the script please
0
 
LVL 78

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37069696
>>Please help me with the shell

Please answer our questions.

You have not answered what the parameters are, order, how they need to be used, etc...

We cannot help you if we do not know what you want/need.
0
 

Author Comment

by:enrique_aeo
ID: 37069739
I arrive at work not yet
0
 

Author Comment

by:enrique_aeo
ID: 37071917
if [[ -z $1 ]]
then
      #do something
      USER_SERV=`whoami`
else
      PI_FECHA_DEVOLUCION_INI=$1
      PI_FECHA_DEVOLUCION_FIN=$2
fi

this is the code amd work it
0
 

Author Comment

by:enrique_aeo
ID: 37071930
I CALL
sh nameSHELL 20111011 20111011
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses
Course of the Month17 days, 12 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question