The UNIX and Linux Forums  


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
Problem In Shell Script satyakide Shell Programming and Scripting 11 09-24-2007 11:00 AM
Shell Script Menus - Rejecting invalid input (KSH) rockysfr Shell Programming and Scripting 2 06-26-2007 04:14 PM
shell script problem djt0506 UNIX for Dummies Questions & Answers 2 12-07-2005 11:29 PM
Problem with shell script zylwyz Shell Programming and Scripting 2 06-29-2005 02:01 PM
shell script problem strpeski UNIX for Advanced & Expert Users 10 09-03-2001 09:22 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-13-2006
bhagat.singh-j bhagat.singh-j is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 18
Problem with shell script...ORA-00904:invalid identifier

Guys,
Please suggest me what's wrong with this script?


#!/usr/bin/sh
##############################################################################
# Author : Bhagat Singh
#
#
# Date : Nov 13,2006
#
##############################################################################
OUTPUT=$(sqlplus -s xxx/yyy#@zzz << EOF | grep -v "^$"
set head off
select max(ctrl_perd) from prod where code='123';
select max(ctrl_perd) from geo where code='456';
exit
EOF)
PROD_CTRL_PERD=$(echo $OUTPUT | awk '{ print $1 }')
GEO_CTRL_PERD=$(echo $OUTPUT | awk '{ print $2 }')

I'm getting error below:
ERROR at line 1:
ORA-00904: "123": invalid identifier
(note:the output of both the queries are of "date" data type)
Help me out..
Thanks,
Bhagat
  #2 (permalink)  
Old 11-13-2006
mona's Avatar
mona mona is offline
Registered User
  
 

Join Date: Nov 2005
Location: Singapore
Posts: 96
Are these columns code and ctrl_perd valid in your database? Did you execute these queries in SQL Plus?
  #3 (permalink)  
Old 11-13-2006
bhagat.singh-j bhagat.singh-j is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 18
.Thanks for your reply.
They are perfectly valid in my database.
I get the result when I execute the same query in SQL plux..
Intruiging...
  #4 (permalink)  
Old 11-13-2006
mona's Avatar
mona mona is offline
Registered User
  
 

Join Date: Nov 2005
Location: Singapore
Posts: 96
It's weird !!. I ran your script with the table and column names replaced with valid table and column names in my database. It works perfectly for me.
  #5 (permalink)  
Old 11-13-2006
nir_s nir_s is offline
Registered User
  
 

Join Date: Jun 2004
Posts: 148
I checked the syntax of the shell script and it's OK.
I agree with mona that you have problem with the sql statements.
Try to remove the commas from the sql statements:
select max(ctrl_perd) from prod where code=123;
select max(ctrl_perd) from geo where code=456;
Execute the statements first in sqlplus and see if they run successfully.
Send us the output you get.

Nir
  #6 (permalink)  
Old 11-13-2006
mona's Avatar
mona mona is offline
Registered User
  
 

Join Date: Nov 2005
Location: Singapore
Posts: 96
Quote:
Originally Posted by nir_s
Try to remove the commas from the sql statements:
The colon should not cause any problems. Oracle will do internal type conversion if the "code" column is number.
  #7 (permalink)  
Old 11-13-2006
er_aparna er_aparna is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 52
output syntax error

Hello,

Well the error 0094 symbolize :
oerr ora 904
00904, 00000, "%s: invalid identifier"

Hence i believe that there z error in declaration of yr variable output so , its better u use the variable and before that mention the default directories of yr oracle file like

mention in starting of yr script

. /in/local/bin/.tools.sh

where tools .sh is a hidden script to call and set yr env variables of oracle and then u cal directly call sql .

KRegards,
Aparna
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 08:43 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