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: Pete Finnigan <pete_at_peterfinnigan.demon.co.uk>
Date: Thu, 13 Sep 2001 18:39:14 +0100
Message-ID: <vhdugPBC9Oo7EwTn@peterfinnigan.demon.co.uk>


Hi

Just add

set head off
set feed off
set termout off

before the select statement in your here document and call sqlplus -s if you wish

this should prevent the need to filter out the headings etc.

cheers

Pete Finnigan
www.pentest-limited.com

In article <44y*Ytd6o_at_news.chiark.greenend.org.uk>, Andrew Mobbs <andrewm_at_chiark.greenend.org.uk> writes
>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
>----------------------------------------------------------------------
>

-- 
Pete Finnigan
IT Security Consultant
PenTest Limited

Office  01565 830 990
Fax     01565 830 889
Mobile  07974 087 885

pete.finnigan_at_pentest-limited.com

www.pentest-limited.com
Received on Thu Sep 13 2001 - 12:39:14 CDT

Original text of this message

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