Difficulty using "execute immediate" in shell - Sql script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Difficulty using "execute immediate" in shell - Sql script
# 1  
Old 10-11-2009
Difficulty using "execute immediate" in shell - Sql script

Hello members,

I get an unexpected "end of file" error while trying to execute the following piece of code in the bash / ksh shell. I'm assuming the problem is with using the "execute immediate statement"
Code:
#! /bin/bash

tname="table"

for i in *
do
sqlstr="create table $tname$i as select account_no, balance from records_all"
sqlplus username/password@db_name<<EOF
  execute immediate $sqlstr;
EOF

ksh Error:
Code:
+ tname=table
try.ksh[7]: syntax error at line 10 : `<<' unmatched

bash Error:
Code:
tname=table
try.sh: syntax error at line 15: `end of file' unexpected

Appreciate your guidance with the correct syntax.

kris

Last edited by rbatte1; 08-22-2016 at 08:37 AM.. Reason: Added CODE tags
# 2  
Old 10-11-2009
for ... ;do ...;done
# 3  
Old 10-11-2009
add 'done' as the last line to close the for clause
# 4  
Old 10-12-2009
Thanks folks. The following code snippet seems to work for me:

Code:
#! /bin/ksh
tname="table"
for i in temp*
do
    OUTPUT=$(sqlplus -silent username/password@db_name << OK
    set pages 0 feedback off
    create table $tname$i as select account_no, balance from records_all;
OK)
echo " $tname$i table creation is successful "
done

Thanks again!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Solaris

[HW] Script so that when i execute the "rm" command

Hi guys, I need to write a script so that when i execute the "rm" command, the file mentioned need to be copied to other folder and then be deleted. this should be done in back ground. can you please help me out?? I have written a code in c for this but i dont have C compiler and i dont... (0 Replies)
Discussion started by: rajeshb6
0 Replies

3. Shell Programming and Scripting

"Cannot Execute" script, SunOS. [solved]

I have a script in Server A that will run a script in ServerB. #!/bin/ksh/ ssh user@server "/path/script.sh" The script permissions are as follow: -rwxrwxrwx 1 user dba 75 Jun 11 10:00 script.sh I checked the existence of 'ksh' in /bin and its there. (bash isnt) ... (0 Replies)
Discussion started by: RedSpyder
0 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

6. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

7. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. Shell Programming and Scripting

how do execute "vi" commands in shell script?

Hi All, I need to execute the following "vi" commands in my script. How can I do that?? pls help me.... 1. escape (escape mode) 2. gg (goto first line) 3. shift+v (visual mode) 4. shift+g (goto to last line) 5. = (alinment) Thanks in advance, Saravana (3 Replies)
Discussion started by: askumarece
3 Replies

9. AIX

"too big" and "not enough memory" errors in shell script

Hi, This is odd, however here goes. There are several shell scripts that run in our production environment AIX 595 LPAR m/c, which has sufficient memory 14GB (physical memory) and horsepower 5CPUs. However from time to time we get the following errors in these shell scripts. The time when these... (11 Replies)
Discussion started by: jerardfjay
11 Replies

10. UNIX for Dummies Questions & Answers

No utpmx entry: you must exec "login" from lowest level "shell"

Hi I have installed solaris 10 on an intel machine. Logged in as root. In CDE, i open terminal session, type login alex (normal user account) and password and i get this message No utpmx entry: you must exec "login" from lowest level "shell" :confused: What i want is: open various... (0 Replies)
Discussion started by: peterpan
0 Replies
Login or Register to Ask a Question