Sponsored Content
Top Forums UNIX for Advanced & Expert Users passing unix variable to sqlplus without a file name Post 302099412 by sakthi.abdullah on Tuesday 12th of December 2006 02:32:47 AM
Old 12-12-2006
Some errors are coming

I tried that &&;
sqlplus -s -L $dbausername/$dbapwd $1 $password <<EOF
create user &&1 identified by &&2;
grant create session to &&1;
exit;
EOF
[FONT=Courier New]

Still ,it's giving some errors...

Can someone help me??
Thanks
 

10 More Discussions You Might Find Interesting

1. Programming

Passing C Variable To Unix

I want to pass a variable set in my c program to a shell script (which will also be invoked or initiated from the same C program using the C's system command). Is it possible ? :confused: (3 Replies)
Discussion started by: kapilv
3 Replies

2. UNIX for Advanced & Expert Users

How to pass unix variable to SQLPLUS

hi fellows, can any body tell me how to pass unix variables to oracle code is... #! /bin/ksh echo ENTER DATE VALUE's read START_DATE END_DATE sqlplus xyx/abc@oracle select * from table1 where coloumn1 between $START_DATE and $END_DATE; is this is correct way........... Thanks in... (1 Reply)
Discussion started by: chiru
1 Replies

3. UNIX for Dummies Questions & Answers

select count(*) in sqlplus into variable unix shell

Need to select count(*) from table to check for zero result in unix script (2 Replies)
Discussion started by: struggle
2 Replies

4. Shell Programming and Scripting

error in passing a variable to sqlplus from a shell script

hi, I am using a shell script from where i will be conecting to sqlplus.. i am having a problem in passing a variable to sqlplus query.. i will be assigning the variable in the unix environment..whenever i am trying to pass a variable having the contents greater than 2500 characters, i am... (3 Replies)
Discussion started by: kripssmart
3 Replies

5. Shell Programming and Scripting

Passing the unix variable to sqlplus

Hi, I am writing a script which creates an external table using a shell script. My requirement is like this. Usage: . ./r.ksh <table_name> - this should create an external table. e.g . ./r.ksh abc - this should create an external table as abc_external. How do i achieve this? Please... (5 Replies)
Discussion started by: Anaramkris
5 Replies

6. UNIX for Dummies Questions & Answers

Passing a Unix parameter to SQLPlus login command

hi All, i m trying to pass a user choice paramter from unix to sqlplus connect command here i want the user to enter the username and password he wants to connect in sql plus through read in unix and then automatically connect to that instance. sqlplus -s $1/$2 where $ 1 and $2 will b... (2 Replies)
Discussion started by: Jcpratap
2 Replies

7. Shell Programming and Scripting

How to print huge values in sqlplus variable in UNIX?

Hi, I ahve a unix code as below. sqlTxt=$* sqlReturn=`echo "set feedback off; set heading off; set term off; set verify off; set serveroutput on size unlimited set lin 1000; VARIABLE GV_return_val NUMBER; VARIABLE GV_script_error varchar2(4000); EXEC :GV_return_code := 0; EXEC... (6 Replies)
Discussion started by: bhaski2012
6 Replies

8. Shell Programming and Scripting

Passing sqlplus output to shell variable

Hi , I am using below code : for i in `ps -ef|grep pmon|awk {' print $8 '}|cut -f3 -d'_'|grep -v '^grep'` do ORACLE_SID=$i export ORACLE_SID; dest=`sqlplus "/ as sysdba" <<EOF set heading off feedback on verify off select DESTINATION from v\\$archive_dest where target in... (5 Replies)
Discussion started by: admin_db
5 Replies

9. Shell Programming and Scripting

Passing Oracle function as file input to sqlplus

Apologies if this is the incorrect forum.There is an issue in the function call I am facing while calling the same from a unix shell scripts. Basically, I want the ref cursor to return values to a variable in sqlpus. The function call is currently saved in a ".txt" file in a unix location. I want... (7 Replies)
Discussion started by: amvip
7 Replies

10. UNIX for Beginners Questions & Answers

Sqlplus variable UNIX

hi guys i have a sqlplus : sqlplus -s username/password << EOF @mysql.sql EOF in mysql.sql there is a count of a table, i want to write in a variabile unix. how can i do? Thanks a lot Regards Francesco. (3 Replies)
Discussion started by: Francesco_IT
3 Replies
SQL(1)								     parallel								    SQL(1)

NAME
sql - execute a command on a database determined by a dburl SYNOPSIS
sql [options] dburl [commands] sql [options] dburl < commandfile #!/usr/bin/sql --shebang [options] dburl DESCRIPTION
GNU sql aims to give a simple, unified interface for accessing databases through all the different databases' command line clients. So far the focus has been on giving a common way to specify login information (protocol, username, password, hostname, and port number), size (database and table size), and running queries. The database is addressed using a DBURL. If commands are left out you will get that database's interactive shell. GNU sql is often used in combination with GNU parallel. dburl A DBURL has the following syntax: [sql:]vendor:// [[user][:password]@][host][:port]/[database][?sqlquery] See the section DBURL below. commands The SQL commands to run. Each argument will have a newline appended. Example: "SELECT * FROM foo;" "SELECT * FROM bar;" If the arguments contain ' ' or 'x0a' this will be replaced with a newline: Example: "SELECT * FROM foo; SELECT * FROM bar;" If no commands are given SQL is read from the keyboard or STDIN. Example: echo 'SELECT * FROM foo;' | sql mysql:/// --db-size --dbsize Size of database. Show the size of the database on disk. For Oracle this requires access to read the table dba_data_files - the user system has that. --help -h Print a summary of the options to GNU sql and exit. --html HTML output. Turn on HTML tabular output. --show-processlist --proclist --listproc Show the list of running queries. --show-databases --showdbs --list-databases --listdbs List the databases (table spaces) in the database. --show-tables --list-tables --table-list List the tables in the database. --noheaders --no-headers -n Remove headers and footers and print only tuples. Bug in Oracle: it still prints number of rows found. -p pass-through The string following -p will be given to the database connection program as arguments. Multiple -p's will be joined with space. Example: pass '-U' and the user name to the program: -p "-U scott" can also be written -p -U -p scott. -r Try 3 times. Short version of --retries 3. --retries ntimes Try ntimes times. If the client program returns with an error, retry the command. Default is --retries 1. --sep string -s string Field separator. Use string as separator between columns. --skip-first-line Do not use the first line of input (used by GNU sql itself when called with --shebang). --table-size --tablesize Size of tables. Show the size of the tables in the database. --version -V Print the version GNU sql and exit. --shebang -Y GNU sql can be called as a shebang (#!) command as the first line of a script. Like this: #!/usr/bin/sql -Y mysql:/// SELECT * FROM foo; For this to work --shebang or -Y must be set as the first option. DBURL
A DBURL has the following syntax: [sql:]vendor:// [[user][:password]@][host][:port]/[database][?sqlquery] To quote special characters use %-encoding specified in http://tools.ietf.org/html/rfc3986#section-2.1 (E.g. a password containing '/' would contain '%2F'). Examples: mysql://scott:tiger@my.example.com/mydb sql:oracle://scott:tiger@ora.example.com/xe postgresql://scott:tiger@pg.example.com/pgdb pg:/// postgresqlssl://scott@pg.example.com:3333/pgdb sql:sqlite2:////tmp/db.sqlite?SELECT * FROM foo; sqlite3:///../db.sqlite3?SELECT%20*%20FROM%20foo; Currently supported vendors: MySQL (mysql), MySQL with SSL (mysqls, mysqlssl), Oracle (oracle, ora), PostgreSQL (postgresql, pg, pgsql, postgres), PostgreSQL with SSL (postgresqlssl, pgs, pgsqlssl, postgresssl, pgssl, postgresqls, pgsqls, postgress), SQLite2 (sqlite, sqlite2), SQLite3 (sqlite3). Aliases must start with ':' and are read from /etc/sql/aliases and ~/.sql/aliases. The user's own ~/.sql/aliases should only be readable by the user. Example of aliases: :myalias1 pg://scott:tiger@pg.example.com/pgdb :myalias2 ora://scott:tiger@ora.example.com/xe # Short form of mysql://`whoami`:nopassword@localhost:3306/`whoami` :myalias3 mysql:/// # Short form of mysql://`whoami`:nopassword@localhost:33333/mydb :myalias4 mysql://:33333/mydb # Alias for an alias :m :myalias4 # the sortest alias possible : sqlite2:////tmp/db.sqlite # Including an SQL query :query sqlite:////tmp/db.sqlite?SELECT * FROM foo; EXAMPLES
Get an interactive prompt The most basic use of GNU sql is to get an interactive prompt: sql sql:oracle://scott:tiger@ora.example.com/xe If you have setup an alias you can do: sql :myora Run a query To run a query directly from the command line: sql :myalias "SELECT * FROM foo;" Oracle requires newlines after each statement. This can be done like this: sql :myora "SELECT * FROM foo;" "SELECT * FROM bar;" Or this: sql :myora "SELECT * FROM foo; SELECT * FROM bar;" Copy a PostgreSQL database To copy a PostgreSQL database use pg_dump to generate the dump and GNU sql to import it: pg_dump pg_database | sql pg://scott:tiger@pg.example.com/pgdb Empty all tables in a MySQL database Using GNU parallel it is easy to empty all tables without dropping them: sql -n mysql:/// 'show tables' | parallel sql mysql:/// DELETE FROM {}; Drop all tables in a PostgreSQL database To drop all tables in a PostgreSQL database do: sql -n pg:/// 'dt' | parallel --colsep '|' -r sql pg:/// DROP TABLE {2}; Run as a script Instead of doing: sql mysql:/// < sqlfile you can combine the sqlfile with the DBURL to make a UNIX-script. Create a script called demosql: #!/usr/bin/sql -Y mysql:/// SELECT * FROM foo; Then do: chmod +x demosql; ./demosql Use --colsep to process multiple columns Use GNU parallel's --colsep to separate columns: sql -s ' ' :myalias 'SELECT * FROM foo;' | parallel --colsep ' ' do_stuff {4} {1} Retry if the connection fails If the access to the database fails occationally --retries can help make sure the query succeeds: sql --retries 5 :myalias 'SELECT * FROM really_big_foo;' Get info about the running database system Show how big the database is: sql --db-size :myalias List the tables: sql --list-tables :myalias List the size of the tables: sql --table-size :myalias List the running processes: sql --show-processlist :myalias REPORTING BUGS
GNU sql is part of GNU parallel. Report bugs to <bug-parallel@gnu.org>. AUTHOR
When using GNU sql for a publication please cite: O. Tange (2011): GNU SQL - A Command Line Tool for Accessing Different Databases Using DBURLs, ;login: The USENIX Magazine, April 2011:29-32. Copyright (C) 2008,2009,2010 Ole Tange http://ole.tange.dk Copyright (C) 2010,2011 Ole Tange, http://ole.tange.dk and Free Software Foundation, Inc. LICENSE
Copyright (C) 2007,2008,2009,2010,2011 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or at your option any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Documentation license I Permission is granted to copy, distribute and/or modify this documentation under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the file fdl.txt. Documentation license II You are free: to Share to copy, distribute and transmit the work to Remix to adapt the work Under the following conditions: Attribution You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Share Alike If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license. With the understanding that: Waiver Any of the above conditions can be waived if you get permission from the copyright holder. Public Domain Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license. Other Rights In no way are any of the following rights affected by the license: o Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; o The author's moral rights; o Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. Notice For any reuse or distribution, you must make clear to others the license terms of this work. A copy of the full license is included in the file as cc-by-sa.txt. DEPENDENCIES
GNU sql uses Perl. If mysql is installed, MySQL dburls will work. If psql is installed, PostgreSQL dburls will work. If sqlite is installed, SQLite2 dburls will work. If sqlite3 is installed, SQLite3 dburls will work. If sqlplus is installed, Oracle dburls will work. If rlwrap is installed, GNU sql will have a command history for Oracle. FILES
~/.sql/aliases - user's own aliases with DBURLs /etc/sql/aliases - common aliases with DBURLs SEE ALSO
mysql(1), psql(1), rlwrap(1), sqlite(1), sqlite3(1), sqlplus(1) 20120422 2012-04-21 SQL(1)
All times are GMT -4. The time now is 06:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy