Sponsored Content
Top Forums Shell Programming and Scripting Passing PL/SQL variable value to Shell Varible Post 302105020 by ganapati on Tuesday 30th of January 2007 08:32:20 AM
Old 01-30-2007
Great help and many thanks for your guide 'Radoulov'.

Below code is working perfectly to pass multiple values from SQL to Shell script.

printf "%s\n" "set pages 0 serverout on feed off" \
"select ENAME from emp where ENO=7021;" \
"select sysdate from dual;" \
"select min(sal) from emp;" \
"select max(sal) from emp;" \
"select avg(sal) from emp;" \
| sqlplus -s scott/tiger \
| { read var1; read var2; read var3; read var4; read var5;
}
echo "Employee Name is $var1"
echo "Date is $var2"
echo "Minimum of Salary is $var3"
echo "Maximum of Salary is $var4"
echo "Average of Salary is $var5"


But still I've one more requirement.....,
What is the case for the same query where if I want assign more values to var1 ?


printf "%s\n" "set pages 0 serverout on feed off" \
"select ENAME from emp;" \
"select sysdate from dual;" \
"select min(sal) from emp;" \
"select max(sal) from emp;" \
"select avg(sal) from emp;" \
| sqlplus -s scott/tiger \
| { read var1; read var2; read var3; read var4; read var5;
}
echo "Employee Name is $var1"
echo "Date is $var2"
echo "Minimum of Salary is $var3"
echo "Maximum of Salary is $var4"
echo "Average of Salary is $var5"


Please help me last time.

With Regards,
Ganapati. Smilie
 

10 More Discussions You Might Find Interesting

1. Linux

Passing variables to sql from batch shell in linux

Hi, I need to put this command in a batch shell. sqlplus -s user/password @test.sql and in the test.sql I have this command select * from pbempl where pebempl_id = $1; How I can pass the variable $1 from the batch shell??? Thanks (2 Replies)
Discussion started by: rama71
2 Replies

2. UNIX for Advanced & Expert Users

passing value to a variable in a SQL

Hi Folks, This is a small chunk of the bigger problem which i am facing and some help here will help me resolve the rest of the issue. Problem is that i need to pass the value of a variable from a shell script to a SQL query (infact a lot of SQL's) i have the following solution but somehow... (4 Replies)
Discussion started by: kamitsin
4 Replies

3. Shell Programming and Scripting

Passing argumnets from shell script to sql

hi I all , I have sql statment in my shell script , I pass two argument to the script I need to pass the this two arguments to the sql statment example : runsql.sh "1" "2" sql : updat tables_x set y=0 where A=:x should subsituted by "1" and B=:y shuold subsituted bt "2"... (1 Reply)
Discussion started by: habuzahra
1 Replies

4. Shell Programming and Scripting

passing values from sql to shell script

Hi guyz, Posting a thread after a long time. I want to pass two variables to unix shell script from sql script. Note: I am calling sql script from unix script. sql script has 2 variables one is the return code for status of program run and second one email flag. I don't know how to capture... (3 Replies)
Discussion started by: sachin.gangadha
3 Replies

5. UNIX for Advanced & Expert Users

Passing Hash variable in to sql query in perl

Hi Everyone, Can anyone help me how do i call hash variable in to sql query in perl. Please see the script below i have defined two Hash %lc and %tab as below $lc{'REFF'}='V_RES_CLASS'; $lc{'CALE'}='V_CAP_CLASS'; $lc{'XRPD'}='V_XFMR_CLASS'; $tab{'V_RES_CLASS'}='V_MFR_SERS';... (6 Replies)
Discussion started by: jam_prasanna
6 Replies

6. Shell Programming and Scripting

Passing filename dynamically in SPOOL of SQL*PLUS in shell script

Hi all, I am executing shell script in which I am using SQLLDR In this SQLLDR I am passing text file having PL/SQL script. This script will produce some formated output, this output I have to spool in another text file. Currently I have given this in script file as following Spool... (2 Replies)
Discussion started by: shekharjchandra
2 Replies

7. Shell Programming and Scripting

Passing a string variable from Unix to Sql Plus

Hi Guys, I am trying to pass a string variable from Unix shell script to sqlplus as a parameter. I have tried using single quotes with the variable name but it does not work. Please help me with it. I am using BASH. My code: Your help is much appreciated. Thanks, shil (2 Replies)
Discussion started by: infintenumbers
2 Replies

8. Shell Programming and Scripting

Passing the result of an anonymous pl/sql block to a shell script

Hello, Here is the code i have written to get the count of a plsql query back to the unix. function checkforCOIDs { countcheck=`sqlplus -s $1/$2@$3 whenever oserror exit sql.oscode rollback whenever sqlerror exit sql.sqlcode rollback set serverout on size 2000; set head off feedback off... (2 Replies)
Discussion started by: santosh2eee
2 Replies

9. Shell Programming and Scripting

Passing variable to sql

How to pass variable to sql file. Im tryin in two ways, Method 1: my.sql select * from table where col1 = '$1' and col2 = 'text'; Method 1execute: dbaccess database my.sql $var Method2: select * from table col1 in (`cat inputfile`) and col2 = 'text'; method... (2 Replies)
Discussion started by: Roozo
2 Replies

10. Shell Programming and Scripting

Passing variable from file to sql from script

Hi Friend, I have one file in which some number are mentioned and number of lines are vary every time And i need to pass that number to my sql command from script. Suppose i have file acc.txt 45456546456 45464564565 67854353454 67657612132 Number of records are vary every time.... (20 Replies)
Discussion started by: pallvi_mahajan
20 Replies
QAxScriptManager(3qt)													     QAxScriptManager(3qt)

NAME
QAxScriptManager - Bridge between application objects and script code SYNOPSIS
This class is part of the Qt ActiveQt Extension. #include <qaxscript.h> Inherits QObject. Public Members QAxScriptManager ( QObject * parent = 0, const char * name = 0 ) ~QAxScriptManager () void addObject ( QAxBase * object ) void addObject ( QObject * object ) QStringList functions ( QAxScript::FunctionFlags flags = QAxScript::FunctionNames ) const QStringList scriptNames () const QAxScript * script ( const QString & name ) const QAxScript * load ( const QString & code, const QString & name, const QString & language ) QAxScript * load ( const QString & file, const QString & name ) QVariant call ( const QString & function, const QVariant & var1 = QVariant ( ), const QVariant & var2 = QVariant ( ), const QVariant & var3 = QVariant ( ), const QVariant & var4 = QVariant ( ), const QVariant & var5 = QVariant ( ), const QVariant & var6 = QVariant ( ), const QVariant & var7 = QVariant ( ), const QVariant & var8 = QVariant ( ) ) QVariant call ( const QString & function, QValueList<QVariant> & arguments ) Signals void error ( QAxScript * script, int code, const QString & description, int sourcePosition, const QString & sourceText ) Static Public Members bool registerEngine ( const QString & name, const QString & extension, const QString & code = QString ( ) ) QString scriptFileFilter () DESCRIPTION
This class is defined in the Qt ActiveQt Extension, which can be found in the qt/extensions directory. It is not included in the main Qt API. The QAxScriptManager class provides a bridge between application objects and script code. The QAxScriptManager acts as a bridge between the COM objects embedded in the Qt application through QAxObject or QAxWidget, and the scripting languages available through the Windows Script technologies, usually JScript and VBScript. Create one QAxScriptManager for each separate document in your application, and add the COM objects the scripts need to access using addObject(). Then load() the script sources and invoke the functions using call(). Warning: This class is not available with the bcc5.5 and MingW compilers. MEMBER FUNCTION DOCUMENTATION
QAxScriptManager::QAxScriptManager ( QObject * parent = 0, const char * name = 0 ) Creates a QAxScriptManager object. parent and name are passed on to the QObject constructor. It is usual to create one QAxScriptManager for each document in an application. QAxScriptManager::~QAxScriptManager () Destroys the objects, releasing all allocated resources. void QAxScriptManager::addObject ( QAxBase * object ) Adds object to the manager. Scripts handled by this manager can access the object in the code using the object's name property. You must add all the necessary objects before loading any scripts. void QAxScriptManager::addObject ( QObject * object ) This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Adds a generic COM wrapper for object to the manager. object must be exposed as a COM object using the functionality provided by the QAxServer module.. Applications using this function you must link against the qaxserver library. QVariant QAxScriptManager::call ( const QString & function, const QVariant & var1 = QVariant ( ), const QVariant & var2 = QVariant ( ), const QVariant & var3 = QVariant ( ), const QVariant & var4 = QVariant ( ), const QVariant & var5 = QVariant ( ), const QVariant & var6 = QVariant ( ), const QVariant & var7 = QVariant ( ), const QVariant & var8 = QVariant ( ) ) Calls function, passing the parameters var1, var1, var2, var3, var4, var5, var6, var7 and var8 as arguments and returns the value returned by the function, or an invalid QVariant if the function does not return a value or when the function call failed. The call returns when the script's execution has finished. In most script engines the only supported parameter type is "const QVariant&", for example, to call a JavaScript function function setNumber(number) { n = number; } use QValueList args; args << 5; script->call("setNumber(const QVariant&)", args); As with dynamicCall the parameters can directly be embedded in the function string. script->call("setNumber(5)"); However, this is slower. Functions provided by script engines that don't support introspection are not available and must be called directly using QAxScript::call() on the respective script object. Note that calling this function can be significantely slower than using call() on the respective QAxScript directly. QVariant QAxScriptManager::call ( const QString & function, QValueList<QVariant> & arguments ) This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Calls function passing arguments as parameters, and returns the result. Returns when the script's execution has finished. void QAxScriptManager::error ( QAxScript * script, int code, const QString & description, int sourcePosition, const QString & sourceText ) [signal] This signal is emitted when an execution error occured while running script. code, description, sourcePosition and sourceText contain information about the execution error. QStringList QAxScriptManager::functions ( QAxScript::FunctionFlags flags = QAxScript::FunctionNames ) const Returns a list with all the functions that are available. Functions provided by script engines that don't support introspection are not included in the list. The functions are either provided with full prototypes or only as names, depending on the value of flags. QAxScript * QAxScriptManager::load ( const QString & code, const QString & name, const QString & language ) Loads the script source code using the script engine for language. The script can later be referred to using its name which should not be empty. The function returns a pointer to the script for the given code if the code was loaded successfully; otherwise it returns 0. If language is empty it will be determined heuristically. If code contains the string "End Sub" it will be interpreted as VBScript, otherwise as JScript. Additional script engines can be registered using registerEngine(). You must add all the objects necessary (using addObject()) before loading any scripts. If code declares a function that is already available (no matter in which language) the first function is overloaded and can no longer be called via call(); but it will still be available by calling its script directly. See also addObject(), scriptNames(), and functions(). QAxScript * QAxScriptManager::load ( const QString & file, const QString & name ) This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Loads the source code from the file. The script can later be referred to using its name which should not be empty. The function returns a pointer to the script engine for the code in file if file was loaded successfully; otherwise it returns 0. The script engine used is determined from the file's extension. By default ".js" files are interpreted as JScript files, and ".vbs" and ".dsm" files are interpreted as VBScript. Additional script engines can be registered using registerEngine(). bool QAxScriptManager::registerEngine ( const QString & name, const QString & extension, const QString & code = QString ( ) ) [static] Registers the script engine called name and returns TRUE if the engine was found; otherwise does nothing and returns FALSE. The script engine will be used when loading files with the given extension, or when loading source code that contains the string code. QAxScript * QAxScriptManager::script ( const QString & name ) const Returns the script called name. You can use the returned pointer to call functions directly through QAxScript::call(), to access the script engine directly, or to delete and thus unload the script. QString QAxScriptManager::scriptFileFilter () [static] Returns a file filter listing all the supported script languages. This filter string is convenient for use with QFileDialog. QStringList QAxScriptManager::scriptNames () const Returns a list with the names of all the scripts. SEE ALSO
http://doc.trolltech.com/qaxscriptmanager.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qaxscriptmanager.3qt) and the Qt version (3.3.8). Trolltech AS 2 February 2007 QAxScriptManager(3qt)
All times are GMT -4. The time now is 01:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy