The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How is use sselect statement o/p in insert statement. nkosaraju Shell Programming and Scripting 2 08-06-2008 09:26 PM
(sed) parsing insert statement column that crosses multiple lines jjordan Shell Programming and Scripting 3 10-09-2007 12:23 AM
Script does not execute Insert Statement Amruta Pitkar Shell Programming and Scripting 4 08-24-2006 11:14 PM
Insert TAB in echo statement sunils27 Shell Programming and Scripting 5 08-26-2005 03:36 AM
awk command for INSERT statement nattynatty Shell Programming and Scripting 4 05-10-2002 02:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-08-2008
ragavhere ragavhere is offline
Registered User
  
 

Join Date: Apr 2008
Location: Chennai,India
Posts: 79
error in insert statement

hi,

When i try to run the code below, i get the following error

"ksh: syntax error: `(' unexpected"

i am not able to figure it out. Can anyone help me?

Code:
Quote:
ERROR_CD=$1
PARAM_PASSED=$#
CUR_YEAR=`date | awk '{print$6}'`
CUR_MONTH=`date +%m`
CUR_DAY=`date +%d`
CUR_TIME=`date | awk '{print$4}' | sed -e 's/:/./g'`
TODAY_DATE=`echo $CUR_YEAR-$CUR_MONTH-$CUR_DAY-$CUR_TIME.00`
if [ $PARAM_PASSED = 1 ]; then
if [ $ERROR_CD = 01 ]; then
db2 connect to databasename user <username> using <password>
insert into <tablename> (col1,col2,col3,col4,col5,col6) values('$TODAY_DATE','$ERROR_CD','Val1','Val2','VAl3','Val4');
terminate
elif [ $ERROR_CD = 02 ]; then
db2 connect to databasename user <username> using <password>
insert into <tablename> (col1,col2,col3,col4,col5,col6) values('$TODAY_DATE','$ERROR_CD','Val1','Val2','VAl3','Val4');
terminate
elif [ $ERROR_CD = 03 ]; then
db2 connect to databasename user <username> using <password>
insert into <tablename> (col1,col2,col3,col4,col5,col6) values('$TODAY_DATE','$ERROR_CD','Val1','Val2','VAl3','Val4');
terminate
fi
else
exit
fi
  #2 (permalink)  
Old 12-08-2008
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Bangalore
Posts: 219
try this

Code:
ERROR_CD=$1
PARAM_PASSED=$#
CUR_YEAR=`date | awk '{print$6}'`
CUR_MONTH=`date +%m`
CUR_DAY=`date +%d`
CUR_TIME=`date | awk '{print$4}' | sed -e 's/:/./g'`
TODAY_DATE=`echo $CUR_YEAR-$CUR_MONTH-$CUR_DAY-$CUR_TIME.00`
if [ $PARAM_PASSED = 1 ]; then
if [ $ERROR_CD = 01 ]; then
db2 connect to databasename user <username> using <password>
db2 "insert into <tablename> (col1,col2,col3,col4,col5,col6) values('$TODAY_DATE','$ERROR_CD','Val1','Val2','VAl3','Val4');"
terminate
elif [ $ERROR_CD = 02 ]; then
db2 connect to databasename user <username> using <password>
db2 "insert into <tablename> (col1,col2,col3,col4,col5,col6) values('$TODAY_DATE','$ERROR_CD','Val1','Val2','VAl3','Val4');"
terminate
elif [ $ERROR_CD = 03 ]; then
db2 connect to databasename user <username> using <password>
db2 "insert into <tablename> (col1,col2,col3,col4,col5,col6) values('$TODAY_DATE','$ERROR_CD','Val1','Val2','VAl3','Val4');"
terminate
fi
else
exit
fi
  #3 (permalink)  
Old 12-08-2008
ragavhere ragavhere is offline
Registered User
  
 

Join Date: Apr 2008
Location: Chennai,India
Posts: 79
Thanks

Thanks.. It worked!!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0