- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- unix + sql
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2007 09:20 AM
тАО12-15-2007 09:20 AM
Is this possible?
Regards,
Gyan
Solved! Go to Solution.
- Tags:
- SQL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2007 10:49 AM
тАО12-15-2007 10:49 AM
Re: unix + sql
A Google for unix+sql returned these useful examples:
http://www.orafaq.com/forum/t/48103/0/
http://www.tek-tips.com/faqs.cfm?fid=2218
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2007 11:37 AM
тАО12-15-2007 11:37 AM
Solutionlook at fallowin url ;
http://www.dbasupport.com/forums/archive/index.php/t-9326.html
#!/bin/csh -fb
set param ="3"
sqlplus system/manager@orcl << EOF | tee /tmp/$$TMP_FILE
select some_value from some_table where some_param = $param
EOF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2007 03:09 AM
тАО12-18-2007 03:09 AM
Re: unix + sql
print "\
$OraUsr/$OraPwd
set ver off feed off head off pages 0 lines 200 trim on
select col2 from table where update_date=(sysdate -$x);
exit;
"|sqlplus -s|read myvar
print myvar
This piece of code retrun teh value of col2 into var myvar using shell variable $OraUse, $OraPwd, $x
You can improve it a bit adding checks about errors.
HTH,
ART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2007 04:10 AM
тАО12-18-2007 04:10 AM
Re: unix + sql
#!/usr/bin/sh
VAR=$(sqlplus -s user/pass <
where update_date = (sysdate - x)
/
EOF)
# now VAR has a value and is available for further computation
echo $VAR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2007 04:13 AM
тАО12-18-2007 04:13 AM
Re: unix + sql
Thanks for the suggestions. Can we decouple the unix and sql scripts separately.
I mean to call an sql file from unix shell and pass the result back to unix shells.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2007 05:37 AM
тАО12-18-2007 05:37 AM
Re: unix + sql
You can try to put the SQL statement in a file and then use the following:
MYSQLSTMT=$(cat /home/yogeeraj/sql/sql01.sql)
the rest is a matter of running the sql and retrieving the results.
if you need further help, do let u know.
Also if you have a piece of code that is not working, you can always post it here...
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2007 08:55 AM
тАО12-18-2007 08:55 AM
Re: unix + sql
SQ_USER=
SQ_PASSWD=
EZS_DB=database B
EZS_USER=
EZS_PASSWD=
EZS_SQLFILE=/home/gppsq/temp/sample/ezs.sql
SQ_SQLFILE=/home/gppsq/temp/sample/sq.sql
#connect to first database
mysqlstm=$(cat ${SQ_SQLFILE} | sqlplus -s $SQ_USER/$SQ_PASSWD@$SQ_DB);
# here i get the result of the above sql file (SQ_SQLFILE) which is stored in the variable below (st)
st=`echo ${mysqlstm}`
echo "$st" #output is a date (eg: 24-Jun-2007 )
now the question is how do i pass the result of sq.sqlfile ($st) to EZS_SQLFILE
My EZS_SQLFILe has the below sql statements;
select value1 from table_name where col2_date > '$st';
I tried the below
sqlplus -s $EZS_USER/$EZS_PASSWD@$EZS_DB @/home/gppsq/temp/sample/ezs.sql $st
but got error as
ERROR at line 1:
ORA-01858: a non-numeric character was found where a numeric was expected
Regards,
Gyan