Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for scripts to select data and return resultset to console output for logging purposes #60

Open
shantstepanian opened this issue Jul 21, 2017 · 1 comment

Comments

@shantstepanian
Copy link
Contributor

Example: to keep track of purging rows from a table that might take a while. We should think about whether to enable this by default for all cases

Consider doing this alongside #59

/* CREATE TABLE */
CREATE TABLE album(
  Id int identity,
  title VARCHAR(100),
  artist VARCHAR(100)
)

/* POPULATE TABLE in 1 minute with 100k rows */
declare @mycount int
select @mycount=1
while  (@mycount < 100000)
begin
insert into album values ('title_'+ str (@mycount) ,'artist_'+ str(@mycount))
select @mycount=@mycount+1
end

/* PURGE TABLE WHERE id < 50000 in 10 batches of 5000*/
declare @rows int
declare @RetCode int
select @rows=1, @RetCode=0
SET ROWCOUNT 5000
WHILE (@rows !=0 and @RetCode=0)
BEGIN
        delete album where Id <= 50000
        select @rows=@@rowcount, @RetCode=@@error
        select “Album Purge”, getdate(), @rows, @RetCode
END

(5000 rows affected)
(1 row affected)                                                                     
 ----------- ------------------------------- ----------- ----------- 
 Album Purge             Jul 20 2017  4:20PM        5000           0 

(1 row affected)
(5000 rows affected)
(1 row affected)                                                                    
 ----------- ------------------------------- ----------- ----------- 
 Album Purge             Jul 20 2017  4:20PM        5000           0 

(1 row affected)
(5000 rows affected)
(1 row affected)                                                                  
 ----------- ------------------------------- ----------- ----------- 
 Album Purge             Jul 20 2017  4:20PM        5000           0 

(1 row affected)
(5000 rows affected)
(1 row affected)                                    
 ----------- ------------------------------- ----------- ----------- 
 Album Purge             Jul 20 2017  4:20PM        5000           0 

(1 row affected)
(5000 rows affected)
(1 row affected)
----------- ------------------------------- ----------- ----------- 
 Album Purge             Jul 20 2017  4:20PM        5000           0
@shantstepanian shantstepanian changed the title Allow for scripts to select data to console output for logging purposes Allow for scripts to select data and return resultset to console output for logging purposes Oct 16, 2017
@shantstepanian shantstepanian added this to the 6.4.0 milestone Oct 19, 2017
@shantstepanian shantstepanian modified the milestones: 6.4.0, 6.5.0 Nov 18, 2017
@shantstepanian
Copy link
Contributor Author

Example to verify this on in DB2: CALL SYSPROC.ADMIN_MOVE_TABLE

@shantstepanian shantstepanian modified the milestones: 6.5.0, External Contributions Jan 27, 2018
@shantstepanian shantstepanian removed this from the External Contributions milestone Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant