MODEL1 and MODE2 are schemas or databases? There's no PL/SQL in your examples...
Test.sh
==========
sqlplus test/test << !
@test
@test2
!
test.sql
==========
show user
select round(788/100) "Value" from dual;
test2.sql
==========
conn scott/tiger@DB1
show user
select round(788/100) "Value" from dual;
> ./Test.sh
SQL*Plus: Release 10.2.0.3.0 - Production on Fri Aug 21 14:53:40 2009
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning and Data Mining options
SQL> USER is "TEST"
Value
----------
8
Connected.
USER is "SCOTT"
Value
----------
8
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning and Data Mining options
select count(*) from equipment where floor is null and suite like 'GND%';
Based on the above count i modify the number of
times the for loop is executed in upd.sql
nwncms$ vi upd.sql
DECLARE
i NUMBER := 0;
BEGIN
FOR i IN 1..12 LOOP----Modify the number of iterations based on step2. if step2 returns 1526 make the number of iterations as 16
update equipment set floor=substr(suite ,1,3), suite=substr(suite ,4), CREATE_DATE=sysdate+1
where floor is null and suite like 'GND%' and rownum < 101;
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(TO_CHAR(SQLCODE)||'-'||SQLERRM);
END;
Save the upd.sql file after modifying the number of iterations.
then i run the following steps
set serveroutput on
SQL>@/ncm/user/ncm_ops/upd.sql
SQL>update equipment set floor='001',suite='01' where code='BNC' and suite='001F01';
SQL>commit;
SQL> conn model2/ncm_mm2
SQL>set serveroutput on
SQL>@/ncm/user/ncm_ops/upd.sql
SQL>update equipment set floor='001',suite='01' where code='BNC' and suite='001F01';
SQL>commit;
now i want that all these things done through a single script . As this is a live server , I do not try my hand at modifying the scripts and i also do not have any server to practice .
Please help me out in finding the solution.
Please specify if any information is needed from my side.