Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How can I return value from table in korn shell.

Re: How can I return value from table in korn shell.

From: Andrew Mobbs <andrewm_at_chiark.greenend.org.uk>
Date: 13 Sep 2001 16:42:00 +0100 (BST)
Message-ID: <44y*Ytd6o@news.chiark.greenend.org.uk>


Jordan <mj_at_nba.com> wrote:
>Dear All,
>
> How can I write a simple script to return value from the
>following simple sql statement into korn shell.
>e.g. "select student_name from student_info where student_id=00001;". I
>want to store the return student name into korn shell variable
>"$student_name".

I *really* hope somebody knows a less foul method than this, but it sort of works (error checking is left as an exercise to the parser):



#!/bin/ksh
x=`
(
sqlplus scott/tiger << EOF
SELECT ename FROM emp where deptno=23;
EOF
) | paste -s -d' ' - | sed s'/.*---*\([^-][^-]*\)SQL.*/\1/' `

echo $x


-- 
Andrew Mobbs - http://www.chiark.greenend.org.uk/~andrewm/
Received on Thu Sep 13 2001 - 10:42:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US