12-21-2006
use like this
user=xxxx
passwd=xxxx
dbname=xxx
sqlplus -s $user/$passwd@$dbname >test.sql <<END
select * from dual;
END
It works for me,If u still get the error,then use
/oracle/product/<yourversion>/bin/sqlplus -s $user/$passwd@$dbname >test.sql <<END
Regards,
cskumar
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi Guys, how do I connect to a Oracle Database from my machines running on Solaris 5 and 9. Do I need a Oracle client installed or is there any other way to connect to the Oracle Db without using the oracle client?
Any inputs will be highly appreciated. (2 Replies)
Discussion started by: darmat0712
2 Replies
2. UNIX for Advanced & Expert Users
Hi,
Can some one help me in connecting to oracle through unix shell scripts with examples.
Regards
Narayana Gupta (1 Reply)
Discussion started by: guptan
1 Replies
3. Shell Programming and Scripting
if;
sql="select username from dba_users where username = '$FromUser';"
check_FromUser=`ExecSql "$sql"`
I want to connect to Oracle database & check the users in the database, store the value in check_FromUser.
First how to connect to Oracle database from the shell script ?
Appreciate your... (4 Replies)
Discussion started by: dreams5617
4 Replies
4. Shell Programming and Scripting
Hi all,
I am satyakiran , i am new to the forum. i never done shell scripts for connecting to the data base (oracle) and fetching the data from the database( thru sql select statements ) i want to know
1. how to connect to the data base(oracle) using shell script
2. how to retrieve data... (8 Replies)
Discussion started by: satyakiran
8 Replies
5. Shell Programming and Scripting
Hi, I have problems with running shell script connecting to Oracle from the crontab. Here is the script:
#!/sbin/sh
ORACLE_HOME=/opt/oracle/10g/
export ORACLE_HOME
if
then
echo "Source path is not specified"
exit
fi
/opt/oracle/10g/bin/sqlplus user/pass@testdb << EOF
truncate table... (6 Replies)
Discussion started by: apenkov
6 Replies
6. Shell Programming and Scripting
Hi :),
I have installed CA Autosys in my Unix system. It contains 3 ( .pm ) files namely AutoSys.pm, Job.pm, Status.pm ....... in a directory CA.
Am trying to work with autosys for first time. Please guide in how do i connect autosys to oracle DB in my system. My oracle db name is XE..
Thank... (0 Replies)
Discussion started by: bhuvaneshlal
0 Replies
7. Shell Programming and Scripting
Hi,
I am trying to connect to oracle database (9.2.0.7.0) through Sun solaris.
But I am unable to do so.
The content of my script is as follows:
Shell Sript:
RESULT=`$ORACLE_HOME/bin/sqlplus schema/'pwd'@db << EOF
set echo on;
set feedback on;
@/home/count/qry.sql`
echo... (10 Replies)
Discussion started by: fidelis
10 Replies
8. UNIX for Dummies Questions & Answers
Hi,
I am very new to shell scripting and trying to write a simple shell script in which i am trying to achieve the following:
1. Connect to oracle database hosted on a different server
2. fire a query on the oracle db
3. store the output in a variable
4. use this variable for further logic... (1 Reply)
Discussion started by: shrutihardas
1 Replies
9. Shell Programming and Scripting
Hi,
I am very new to shell scripting and trying to write a simple shell script in which i am trying to achieve the following:
1. Connect to oracle database hosted on a different server
2. fire a query on the oracle db
3. store the output in a variable
4. use this variable for further logic... (26 Replies)
Discussion started by: shrutihardas
26 Replies
10. Solaris
Hi guys, long time no typing :D
I have problems when I try to connect to Oracle database from SQL Developer which is located on my Windows box.
Server is running Solaris 11/11 and Oracle 11 enterprise. I can log in locally with sys account to database, start it up and shut it down but when I... (2 Replies)
Discussion started by: solaris_user
2 Replies
LEARN ABOUT DEBIAN
netsds::dbi
NetSDS::DBI(3pm) User Contributed Perl Documentation NetSDS::DBI(3pm)
NAME
NetSDS::DBI - DBI wrapper for NetSDS
SYNOPSIS
use NetSDS::DBI;
$dbh = NetSDS::DBI->new(
dsn => 'dbi:Pg:dbname=test;host=127.0.0.1;port=5432',
login => 'user',
passwd => 'topsecret',
);
print $db->call("select md5(?)", 'zuka')->fetchrow_hashref->{md5};
DESCRIPTION
"NetSDS::DBI" module provides wrapper around DBI module.
CLASS API
new(%params) - class constructor
$dbh = NetSDS::DBI->new(
dsn => 'dbi:Pg:dbname=test;host=127.0.0.1;port=5432',
login => 'user',
passwd => 'topsecret',
);
dbh() - DBI connection handler accessor
Returns: DBI object
This method provides accessor to DBI object and for low level access to database specific methods.
Example (access to specific method):
my $quoted = $db->dbh->quote_identifier(undef, 'auth', 'services');
# $quoted contains "auth"."services" now
call($sql, @bind_params) - prepare and execute SQL query
Method "call()" implements the following functionality:
* check connection to DBMS and restore it
* prepare chached SQL statement
* execute statement with bind parameters
Parameters:
* SQL query with placeholders
* bind parameters
Return:
* statement handler from DBI
Example:
$sth = $dbh->call("select * from users");
while (my $row = $sth->fetchrow_hashref()) {
print $row->{username};
}
fetch_call($sql, @params) - call and fetch result
Paramters: SQL query, parameters
Returns: arrayref of records as hashrefs
Example:
# SQL DDL script:
# create table users (
# id serial,
# login varchar(32),
# passwd varchar(32)
# );
# Now we fetch all data to perl structure
my $table_data = $db->fetch_call("select * from users");
# Process this data
foreach my $user (@{$table_data}) {
print "User ID: " . $user->{id};
print "Login: " . $user->{login};
}
begin() - start transaction
commit() - commit transaction
rollback() - rollback transaction
quote() - quote SQL string
Example:
# Encode $str to use in queries
my $str = "some crazy' string; with (dangerous characters";
$str = $db->quote($str);
INTERNAL METHODS
_add_sets() - add initial SQL query
Example:
$obj->_add_sets("set search_path to myscheme");
$obj->_add_sets("set client_encoding to 'UTF-8'");
_add_attrs() - add DBI handler attributes
$self->_add_attrs(AutoCommit => 1);
_check_connection() - ping and reconnect
Internal method checking connection and implement reconnect
_connect() - connect to DBMS
Internal method starting connection to DBMS
EXAMPLES
samples/testdb.pl
SEE ALSO
DBI, DBD::Pg
TODO
1. Make module less PostgreSQL specific.
AUTHOR
Michael Bochkaryov <misha@rattler.kiev.ua>
LICENSE
Copyright (C) 2008-2009 Net Style Ltd.
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 2 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, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
perl v5.10.1 2010-04-28 NetSDS::DBI(3pm)