Sponsored Content
Top Forums Shell Programming and Scripting Why does my for loop does not work right in ksh? Post 302412960 by ryukishin_17 on Wednesday 14th of April 2010 05:59:16 AM
Old 04-14-2010
Why does my for loop does not work right in ksh?

hi all,

i have a for loop statement in my ksh code. it only returns the first value retrieved not the value for the other rows.

ex: acct_id value = returned value in the for loop
1 = 1
2 = 1 (instead of 2)
3 = 1 (instead of 3)

Is there something wrong on the syntax? Need help thanks.

Code:
sqlplus -s ${USERNAME}/${PASSWORD}@${SID} << END1 >> $LOGFILE
whenever sqlerror exit
set serveroutput on size 1000000
--
-- create customer contacts from the uploaded records
--
declare 
  l_rc                  varchar2(1)   := null;
  cursor c1 is
    select first_name as acct_id
      from sr11007_call_results_table;
begin
  dbms_output.enable(1000000);
  for i in c1 loop
      l_rc = i.acct_id
  end loop;
END1

 

10 More Discussions You Might Find Interesting

1. AIX

Force delete key to work in aix ksh ?

I'm using AIX console over putty. I'm not very happy with default ksh command editing capabilities so I forced insert mode, arrow keys and command history by issuing: set -o emacs alias __D=`echo "\002"` alias __C=`echo "\006"` in emacs mode history works using ctrl+p, so only thing... (2 Replies)
Discussion started by: vilius
2 Replies

2. UNIX for Dummies Questions & Answers

The loop that dosent work

I have a serious problem and Im sure im just doing something stupid ######Start Load while do /export/home/mldwh/rkem_refresh/int_load/scripts/rkem_refresh.sh sleep 10 while do sleep 5 done done ######Log and Runstats sleep... (12 Replies)
Discussion started by: jadionne
12 Replies

3. UNIX for Dummies Questions & Answers

Ksh Why Won't IF Statement work?

I'm trying to figure out why this if statement won't work: if || $zipcount != 6 ]] then echo ${myline} echo "ZIPCODE WARNING! ${zipcode} ${zipcount}" fi if ]] then echo ${myline} echo "STATE WARNING!... (3 Replies)
Discussion started by: developncode
3 Replies

4. Shell Programming and Scripting

how to make ksh to work on solaries

i have a script i which i am using #!/bin/ksh todate=$(date +%m%d%y) dir="$dir/port${todate}" the above one works in linux ...ut not working in solaries could some one please help me in that (13 Replies)
Discussion started by: mail2sant
13 Replies

5. Shell Programming and Scripting

for loop doesn't work

I have a script which uses below for loop: for (( i = 0 ; i <= 5; i++ )) do echo "Welcome $i times" done But when I run the script, it gives error message: Syntex Error : Bad for loop variable Can anyone guide to run it? Thanks in advance. (10 Replies)
Discussion started by: naw_deepak
10 Replies

6. Shell Programming and Scripting

Date command does not work in a KSH when called from Cron

Hi, I'm trying to execute a job on the last day of every month, for which i'm using the following code in my Korn shell script : if ]; then echo allowed only on last day of month. Today is `date +%d` >t.stm echo Tomorrow is `date +%d -d tomorrow` >s.stm exit 0 fi ... ....... (7 Replies)
Discussion started by: devilsadvocate
7 Replies

7. Shell Programming and Scripting

export variable from ksh script doesn't work

Hi there, in a script I have #!/usr/bin/ksh TEST=hello export TEST Problem is, that the variable doesn't get exported. I also tried typeset -x TEST=hello When I put the two lines in my .profile, the variable is set fine. Whats could be the problem here? (4 Replies)
Discussion started by: doc_symbiosis
4 Replies

8. Shell Programming and Scripting

loop doesnt work

It just does the break...even though the files are not the same... # Compare extracts #========================================== count=0 while (( count < 5 )) do (( count+=1 )) echo "Try $count" file1=$(ls -l /tmp/psjava.xml|... (5 Replies)
Discussion started by: sigh2010
5 Replies

9. Shell Programming and Scripting

while - loop does not work

Hey guys, maybe you can help me.. what am i doing wrong? Why this doesn`t work in ksh. while do echo "Type y or n" read decision if then doInstall fi done i also tried this ... (6 Replies)
Discussion started by: xcitan
6 Replies

10. Shell Programming and Scripting

${!var} does not work in ksh

Anyone knows why the following function does not work in ksh (it does in bash)? var() # Displays var value; case insensitive { _var="$1" if ; then echo ${!_var} else _var=$(echo "$_var" | tr 'a-z' 'A-Z') echo ${!_var} fi unset _var }$ var home ksh:... (4 Replies)
Discussion started by: victorbrca
4 Replies
All times are GMT -4. The time now is 07:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy