Not able to get result to unix variables

I am trying to get the Srcreccnt and Tgtreccnt from unix files and update the oracle table.

But i get the below error:

ERROR at line 1:
ORA-00936: missing expression
 
update velocity_process_control set SOURCE_RECORD_COUNT=,SOURCE_RECORD_COUNT= where batch_id=
*
ERROR at line 1:
ORA-00936: missing expression
 

Can you help me where i doing wrong in capturin the values into unix variables and passing to Oracle.

Srcreccnt=cat `ls ${SOURCE_DIR}/ATRPU_RP_ATU_*.csv | head -1`|wc-l
Tgtreccnt=cat `ls ${IMF_TARGET_DIR}/IMF_ATRPU_*.csv | tail -1`|wc-l
echo "Source record count is ${Srcreccnt}"
echo "Source record count is ${Tgtreccnt}"
sqlplus -S core/core@cptest <<EOF
set feedback off
set head off
update velocity_process_control set SOURCE_RECORD_COUNT=${Srcreccnt},SOURCE_RECORD_COUNT=${Tgtreccnt} where batch_id=
(select batch_id from velocity_process_control
minus
select batch_id from velocity_process_control
where rownum < (select count(*) from velocity_process_control))
;
/
EOF

please don't reformat text like that. Thank you

I noticed you are using:

wc-l

instead of:

wc -l

First I saw this "mistake"

Srcreccnt=`cat ls ${SOURCE_DIR}/ATRPU_RP_ATU_*.csv | head -1 |wc -l`
Tgtreccnt=`cat ls ${IMF_TARGET_DIR}/IMF_ATRPU_*.csv | tail -1 |wc -l`

the characters ` enclosing the sentence

But now I'm confused, because when you use tail and head you only display 1 line, and wc always will result in 1. Is this ok? Can you explain a little bit more?

can you explain what are you trying to extract from these commands... because it won't make any sense...

It seems to me he is counting the number of lines in the first file returned by the ls commands.

The commands seem pretty strange to me.

Variable equals word "cat" plus line count of head count 1 of listing of files... i.e. 1.

HI All

My Requirement is

I have source file directory and Target file directory.

  1. From the list of files in source file directory, From the first file i should get the count of records.
  2. From the list of target files in target directory, I should find recent processed file. and get the count of records in the file

so i should update src count and target count to oracle table.

Am i doing any blunders ?.

Please help me as i am new to unix.

Thanks all,
vsmeruga

---------- Post updated at 04:19 PM ---------- Previous update was at 03:39 PM ----------

So friends,

Can i use the below list of cmds to get my results:

Srcreccnt=cat `ls ${SOURCE_DIR}/ATRPU_RP_ATU_*.csv | head -1`|wc-l
Tgtreccnt=cat `ls ${IMF_TARGET_DIR}/IMF_ATRPU_*.csv | tail -1`|wc-l 

or

Srcreccnt=`cat ls ${SOURCE_DIR}/ATRPU_RP_ATU_*.csv | head -1 |wc -l`
Tgtreccnt=`cat ls ${IMF_TARGET_DIR}/IMF_ATRPU_*.csv | tail -1 |wc -l`

Please confirm..
Thanks,
vsmeruga

Try:

Srcreccnt=$(wc -l < $(ls ${SOURCE_DIR}/ATRPU_RP_ATU_*.csv | head -1))

Hi friends,

I tried the below and got error message as

1.)

Tgtreccnt=cat `ls /grid/PowerCenter/stage/velocity_r3_dev/outbound/ATRPU/archive/IMF_ATRPU_*.csv | tail -1`|wc -l

Error msg:

etl-kn-t2-etluser : Tgtreccnt=cat `ls /grid/PowerCenter/stage/velocity_r3_dev/outbound/ATRPU/archive/IMF_ATRPU_*.csv | tail -1`|wc -l
ksh: /grid/PowerCenter/stage/velocity_r3_dev/outbound/ATRPU/archive/IMF_ATRPU_15022010154332.csv: cannot execute
       0
etl-kn-t2-etluser :

2.) tried like this again and got the error as

Tgtreccnt=`cat ls /grid/PowerCenter/stage/velocity_r3_dev/outbound/ATRPU/archive/IMF_ATRPU_*.csv | tail -1|wc -l`

Tgtreccnt=`cat ls /grid/PowerCenter/stage/velocity_r3_dev/outbound/ATRPU/archive/IMF_ATRPU_*.csv | tail -1|wc -l`etl-kn-t2-etluser : Tgtreccnt=`cat ls /grid/PowerCenter/stage/velocity_r3_dev/outbound/ATRPU/archive/IMF_ATRPU_*.csv | tail -1|wc -l`
cat: cannot open ls
etl-kn-t2-etluser :

Gurus, Please help me to sort this out..

---------- Post updated at 05:36 AM ---------- Previous update was at 03:24 AM ----------

1000 Thanks scrutinizer. it worked