Problem with shell script...ORA-00904:invalid identifier


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with shell script...ORA-00904:invalid identifier
# 1  
Old 11-13-2006
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  
Old 11-13-2006
Are these columns code and ctrl_perd valid in your database? Did you execute these queries in SQL Plus?
# 3  
Old 11-13-2006
.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  
Old 11-13-2006
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  
Old 11-13-2006
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  
Old 11-13-2006
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  
Old 11-13-2006
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

ORA-00904: invalid identifier

I've been trying to debug this for 3 hours now. TAB is a table where it contains all the table names. If I try to run it without the filter 'where' it runs fine and outputs the number of rows. But when I put a filter it shows that error. I want to be able to know if the table exists, if it doesn't,... (2 Replies)
Discussion started by: gmatcat
2 Replies

2. UNIX for Dummies Questions & Answers

Sql invalid identifier ORA-00904

Hello I am trying to use the following inside a shell script : S_TAB=$(sqlplus -s / as sysdba <<EOF set feedback off linesize 132 pages 0 echo off verify off heading off select created from v\$database; select 'hurrah' from dual; EOF) Spews out lots of rubbish... (2 Replies)
Discussion started by: d_b
2 Replies

3. Shell Programming and Scripting

How to turn off ora errors in shell script?

I have a shell script which select total count from a table and use its value in a if condition like below connect_string="username/password@tnsname" tot=`sqlplus -s $connect_string << EOF set echo off set feedback off set head off select count(*) from test_table; EOF ` if then echo... (2 Replies)
Discussion started by: vel4ever
2 Replies

4. Shell Programming and Scripting

Shell Scripting Problem - Invalid Back Reference

Here is the question... Create a new script, sub2, taking three parameters... 1.) the string to be replaced 2.) the string with which to replace it 3.) the name of the file in which to make the substitution ...that treats the string to be replaced as plain text instead of as a regular... (1 Reply)
Discussion started by: johnhisenburg
1 Replies

5. Shell Programming and Scripting

Shell script to capture ORA errors from Alert Log

Hi, as the title says, I am after a simple script, which will open the Alert log from an 11.2.0.1 Linux environment and mail the error message and description to a recipient email address. I can then schedule this job via cron and let it run every 15 minutes. I have searched online... (16 Replies)
Discussion started by: jnrpeardba
16 Replies

6. Solaris

maxuprc and maxusers - ORA-27300, ORA-27301, ORA-27302

Hi all, Am intermittently getting the following errors on one of my databases. Errors in file /oracle/HRD/saptrace/background/hrd_psp0_13943.trc: ORA-27300: OS system dependent operation:fork failed with status: 12 ORA-27301: OS failure message: Not enough space ORA-27302:... (1 Reply)
Discussion started by: newbie_01
1 Replies

7. Shell Programming and Scripting

Identifier In Shell script

Hi, I have a shell script and inside that shell script it calls a local .env file to set the environment for the shell script ,but the thing is that i got a error while running the script like ./myscript.sh it gives DB_NAME=dvcl021: is not an identifier that DB_Name is accessed from my .env... (6 Replies)
Discussion started by: malickhat
6 Replies

8. Shell Programming and Scripting

shell script to find and replace a line using a identifier

Hi all im having trouble starting with a shell script, i hope someone here can help me i have 2 files file1: 404905.jpg 516167 404906.jpg 516168 404917.psd 516183 404947.pdf 516250 file2: 516250 /tmp/RecyclePoster18241.pdf 516167 /tmp/ReunionCardFINAL.jpg 516168... (7 Replies)
Discussion started by: kenray
7 Replies

9. Shell Programming and Scripting

How to get ORA errors in alertlog file using shell script.

Hi, Can anyone tell me how to get all ORA errors between two particular times in an alertlog file using shell script. Thanks (3 Replies)
Discussion started by: suman_dba1
3 Replies

10. UNIX for Dummies Questions & Answers

Shell Script Unique Identifier Question

i All I have scripting question. I have a file "out.txt" which is generated by another script the file contains the following my_identifier8859574 logout The number is generated in the script and I have put the my_identifier bit in front of it as a unique identifier I now have... (7 Replies)
Discussion started by: grahambo2005
7 Replies
Login or Register to Ask a Question