Computing.Net > Forums > Unix > New to Scripting

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

New to Scripting

Reply to Message Icon

Name: boagus1
Date: May 31, 2007 at 16:02:37 Pacific
OS: AIX 5.1
CPU/Ram: 4 Core Duo 3gb RAM
Product: IBM
Comment:

I'm trying to get this script to execute an insert after verifying that the requirements are satisfied. the logic gets as far as the insert and I recieve this error:

0403-057 Syntax error at line 48 : `(' is not expected.

Here is the script:

#!/bin/ksh

. /adwprod/di/jobserver/11.5/bin/al_env.sh
. /adwprod/env/setOracle.sh

JOB_SUCCESS_STATUS=0


JOB_SUCCESS_STATUS=`sqlplus -s aiwadmin/tawanai@adwp <<xx
set head off
set feedback off
select count(*) from aiw_table_load_status
where table_name='VENDOR'
and bo_environment='PROD'
and load_region_cd='GBL'
and run_dt = trunc(sysdate-1);
xx
`

JOB_SUCCESS_STATUS=`sqlplus -s aiwadmin/tawanai@adwp <<xx
set head off
set feedback off
select count(*) from aiw_table_load_status
where table_name='CUSTOMER'
and bo_environment='PROD'
and load_region_cd='GBL'
and run_dt = trunc(sysdate-1);
xx
`

JOB_SUCCESS_STATUS=`sqlplus -s aiwadmin/tawanai@adwp <<xx
set head off
set feedback off
select count(*) from aiw_table_load_status
where table_name='CUSTOMER_SALES_ORG'
and bo_environment='PROD'
and load_region_cd='GBL'
and run_dt = trunc(sysdate-1);
xx
`

while [[ ${JOB_SUCCESS_STATUS} -ne 1 ]] ; do
echo ${JOB_SUCCESS_STATUS}
sleep 900

if [ ${JOB_SUCCESS_STATUS} -eq 1 ];
then
insert into aiw_table_load_status (table_name,load_region_cd,run_dt,last_status_cd,bo_environment,status_upd_date,job_nam
e,rowcnt_status_flg) values ('VENDOR','INT',trunc(sysdate),'COMPLETE','PROD',sysdate,'J_RM_MasterData_D',null);
insert into aiw_table_load_status (table_name,load_region_cd, run_dt,last_status_cd,bo_environment,status_upd_date,job_na
me,rowcnt_status_flg) values ('CUSTOMER','INT',trunc(sysdate),'COMPLETE','PROD',sysdate,'J_RM_MasterData_D',null);
insert into aiw_table_load_status (table_name,load_region_cd,run_dt,last_status_cd,bo_environment,status_upd_date,job_nam
e,rowcnt_status_flg) values ('CUSTOMER_SALES_ORG','INT',trunc(sysdate),'COMPLETE','PROD',sysdate,'J_RM_Sales_Dimension_Load',
null);
commit;

fi
exit

Where did I go wrong?



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: May 31, 2007 at 16:43:47 Pacific
Reply:

I am not an Oracle/sqlplus person, but it looks like you are trying to execute an SQL at line 48:

insert into aiw_table_load_status .....

Don't you want this within an sqlplus command block???


0

Response Number 2
Name: boagus1
Date: May 31, 2007 at 16:48:36 Pacific
Reply:

It is an SQL statement. I figured it would work this way ? How would you do it in an
sqlplus command block???


0

Response Number 3
Name: nails
Date: May 31, 2007 at 20:41:59 Pacific
Reply:

The shell is interpreting "insert" as a valid unix command.

Like I said, I'm not an Oracle guy, but I would expect it would be something like this:

sqlplus -s aiwadmin/tawanai@adwp <<xx
insert into aiw_table_load_status (table_name,load_region_cd,run_dt,last_status_cd,bo_environment,status_upd_date,job_nam
e,rowcnt_status_flg) values ('VENDOR','INT',trunc(sysdate),'COMPLETE','PROD',sysdate,'J_RM_MasterData_D',null);
insert into aiw_table_load_status (table_name,load_region_cd, run_dt,last_status_cd,bo_environment,status_upd_date,job_na
me,rowcnt_status_flg) values ('CUSTOMER','INT',trunc(sysdate),'COMPLETE','PROD',sysdate,'J_RM_MasterData_D',null);
insert into aiw_table_load_status (table_name,load_region_cd,run_dt,last_status_cd,bo_environment,status_upd_date,job_nam
e,rowcnt_status_flg) values ('CUSTOMER_SALES_ORG','INT',trunc(sysdate),'COMPLETE','PROD',sysdate,'J_RM_Sales_Dimension_Load',
null);
commit;
xx

But I'm just guessing.

You might look at this link:

http://www.tek-tips.com/faqs.cfm?fi...


0

Response Number 4
Name: boagus1
Date: June 1, 2007 at 10:58:47 Pacific
Reply:

You were 100% correct and I figured it out right after you suggested that I put in within an sqlplus command block:

sqlplus -s aiwadmin/tawanai@adwp <<EOF
insert into aiw_table_load_status (table_name,load_region_cd,run_dt,last_status_cd,bo_environment,status_upd_date,job_nam
e,rowcnt_status_flg) values ('VENDOR','INT',trunc(sysdate),'COMPLETE','PROD',sysdate,'J_RM_MasterData_D',null);
insert into aiw_table_load_status (table_name,load_region_cd, run_dt,last_status_cd,bo_environment,status_upd_date,job_na
me,rowcnt_status_flg) values ('CUSTOMER','INT',trunc(sysdate),'COMPLETE','PROD',sysdate,'J_RM_MasterData_D',null);
insert into aiw_table_load_status (table_name,load_region_cd,run_dt,last_status_cd,bo_environment,status_upd_date,job_nam
e,rowcnt_status_flg) values ('CUSTOMER_SALES_ORG','INT',trunc(sysdate),'COMPLETE','PROD',sysdate,'J_RM_Sales_Dimension_Load',
null);
commit;
EOF

Worked fine.

Thanks for your help.



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Will ibm aix run mac os x... korn shell help



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: New to Scripting

help with script - I am new to Unix www.computing.net/answers/unix/help-with-script-i-am-new-to-unix/2638.html

New user script problem www.computing.net/answers/unix/new-user-script-problem/6617.html

Brand new to unix www.computing.net/answers/unix/brand-new-to-unix/7950.html