count really updated rows
Kerstin Volkenand, February 17, 2017 - 1:00 pm UTC
I changed the script, but it is still not running.
SQL pluzs commmandline call:
@ W:\SG-323\TeamZentraleKatalogredaktion\Bankleitzahlen\ZZZTest-ZZB\2017-Q1\ZD_ZZB-update-nicht-historisch-Merker-M-2017-Q1.sql
script:
--@ W:\SG-323\TeamZentraleKatalogredaktion\Bankleitzahlen\ZZZTest-ZZB\2017-Q1\ZD_ZZB-update-nicht-historisch-Merker-M-2017-Q1.sql
--keine Variblensubstitution wie z.B &
set define off
--wegen Umlautedarstellung
SET NLS_LANG=GERMAN_GERMANY.WE8PC850
set COLSEP '|'
set verify off
set feedback off
set trimspool on
set trimout on
--output welche SQL statements
set echo on
--Variable zum Zählen der Zeilen
--code
declare tot int := 0;
begin
spool W:\SG-323\TeamZentraleKatalogredaktion\Bankleitzahlen\ZZZTest-ZZB\2017-Q1\saetze-zum-modifizieren-nicht-historisch-2017-Q1.txt
--update nicht historische Sätze
update ZD_ZZB set ZZBV='010',ZZBPLZ='30890', ZZBBTEXZ='Commerzbank Barsinghausen', ZZBPAN='24250', ZZBNBLZ='00000000' where ZZBS = '056053' and ZZBDATB='20991231';
tot:=tot + sql%rowcount;
update ZD_ZZB set ZZBV='010',ZZBPLZ='49406', ZZBBTEXZ='VB Diepholz-Barnstorf', ZZBPAN='62386', ZZBNBLZ='00000000' where ZZBS = '025945' and ZZBDATB='20991231';
tot:=tot+sql%rowcount;
update ZD_ZZB set ZZBV='010',ZZBPLZ='30890', ZZBBTEXZ='Commerzbank Barsinghausen', ZZBPAN='28250', ZZBNBLZ='00000000' where ZZBS = '014871' and ZZBDATB='20991231';
tot:=tot + sql%rowcount;
--returnrowanzahl
dbms_output.put_line('Totalrows='||tot);
end;
--Einstellungenfürspoolzurücknehmen
spool off
set verify on
set feedback on
February 18, 2017 - 4:29 am UTC
Add
set serveroutput on
to your script to let SQLPlus know to return the output from dbms_output.
MS SQL Scripts
Rajeshwaran, Jeyabal, February 17, 2017 - 2:30 pm UTC
BTW, this is not Oracle script, those are from MS SQL scripts.
DECLARE @rowsreturned INT
SET @rowsreturned = @@ROWCOUNT
count really updated rows
Kerstin Volkenand, February 20, 2017 - 7:55 am UTC
could you send a complete sample for Oracle with spool file and get really updated rows printed ?
February 20, 2017 - 1:23 pm UTC
My first answer does that, no ?
really updated rows
Kerstin Volkenand, February 20, 2017 - 1:33 pm UTC
I'm not sure where to set the SET commmand and how I get the sum after the update Statements.
So I Need a full SQL sample.
February 21, 2017 - 1:47 am UTC
SQL> spool /tmp/output.log
SQL> drop table t purge;
Table dropped.
SQL> create table t as select * from dba_objects;
Table created.
SQL> set serverout on
SQL> declare
2 s int := 0;
3 begin
4 update t set object_id = object_id+1 where owner = 'SYS';
5 s := s + sql%rowcount;
6 commit;
7 update t set object_id = object_id+1 where owner = 'SCOTT';
8 s := s + sql%rowcount;
9 commit;
10 dbms_output.put_line('Rows = '||s);
11 end;
12 /
Rows = 42780
PL/SQL procedure successfully completed.
SQL> spool off
really updated rows
Kerstin Volkenand, February 21, 2017 - 7:50 am UTC
I miss the
DECLARE @rowsreturned INT
SET @rowsreturned = @@ROWCOUNT
it is the same as:
declare s int := 0;
and is there any difference in behavior when I call from SQL*Plus Window ?
@ W:\SG-323\TeamZentraleKatalogredaktion\Bankleitzahlen\ZZZTest-ZZB\2017-Q1\ZD_ZZB-update-nicht-historisch-Merker-M-2017-Q1.sql
I always have Oracle SQL.
February 22, 2017 - 1:14 am UTC
I'm really sorry - I dont understand what you're asking/saying here