Home » Infrastructure » Unix » assign output
assign output [message #252774] Thu, 19 July 2007 23:35 Go to next message
sowmyar123
Messages: 1
Registered: July 2007
Junior Member
I am writing a unix kshell script where i need to update some table.. and also after the update i have to echo on the unix screen the no of records updated.
how do i do this?
Re: assign output [message #252775 is a reply to message #252774] Thu, 19 July 2007 23:46 Go to previous messageGo to next message
DreamzZ
Messages: 1666
Registered: May 2007
Location: Dreamzland
Senior Member
unix scren?? not clear
you want to generate log file for your ksh script??
USE SPOOL in your script.

[Updated on: Thu, 19 July 2007 23:47]

Report message to a moderator

Re: assign output [message #252776 is a reply to message #252774] Thu, 19 July 2007 23:47 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
I'd use vi, but the choice of editor is up to you.
Re: assign output [message #252792 is a reply to message #252774] Fri, 20 July 2007 00:47 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
There are many ways.
I give you 2.
First one, value returned in the SQL*Plus return code:
myprompt> sqlplus -s / <<EOF
> var nb number
> begin
>   update t set col=col+1;
>   :nb := sql%rowcount;
> end;
> /
> exit :nb
> EOF
myprompt> echo $?
9

Second one, value returned in a shell variable:
myprompt> x=`sqlplus -s / <<EOF
> set serveroutput on
> set feedback off
> begin
>   update t set col=col+1;
>   dbms_output.put_line(sql%rowcount);
> end;
> /
> exit
> EOF`
myprompt> print $x
9

Regards
Michel
Re: assign output [message #252927 is a reply to message #252792] Fri, 20 July 2007 11:47 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
watch out for "exit :nb" Unix return code is limited to 1 byte - use dbms_output if necessary or just grep the usual standard output...
Previous Topic: Shell scripts error
Next Topic: Getting core (merged)
Goto Forum:
  


Current Time: Mon Nov 25 09:05:02 CST 2024