function user {
sqlplus primeit@$ORACLE_SID/primeit <<EOF
select user_name from test;
EOF
}
function gen {
genpwdfile dec -in $1 -out $2
echo $1
echo $2
}
function reset {
sqlplus primeit@$ORACLE_SID/primeit <<EOF
select user_name from user;
EOF
}
---------- Post updated at 05:28 AM ---------- Previous update was at 05:27 AM ----------
This is error i am getting when m trying to use functions such "USER" but when i am trying to access same directly on the command line it goes to sql without an issue.
The ending label of here document (EOF in your case) must be at the beginning of the line unless you have used -EOF which allows the use of tabs (not spaces) at the beginning.
function reset {
sqlplus primeit@$ORACLE_SID/primeit <<EOF
select user_name from user;
EOF
}
OR
function reset {
sqlplus primeit@$ORACLE_SID/primeit <<-EOF
select user_name from user;
EOF ## must be tabs not spaces
}
function user{
sqlplus primeit@$ORACLE_SID/primeit <<EOF
select user from test;
EOF
}
function gen{
genpwdfile dec -in $1 -out $2
echo $1
echo $2
}
function reset{
sqlplus primeit@$ORACLE_SID/primeit <<EOF
select user_name from user;
EOF
}
its giving an error now 1.sh: Syntax error at line 2 : `sqlplus' is not expected.
thanks a lot its got sorted but further i am getting error
SQL*Plus: Release 11.2.0.2.0 Production on Tue Mar 24 15:12:42 2015
Copyright (c) 1982, 2010, Oracle. All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
Enter user-name: ERROR:
ORA-12545: Connect failed because target host or object does not exist
Enter user-name: SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM}] [edition=value]]
where <logon> ::= <username>[/<password>][@<connect_identifier>]
<proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
and when i am running from the same user as primeit/ptimeit its working there