dbTalk Databases Forums  

Sybase ASE - track all changes in DB made by a stored procedure

comp.databases.sybase comp.databases.sybase


Discuss Sybase ASE - track all changes in DB made by a stored procedure in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Krzysztof Adamczyk
 
Posts: n/a

Default Sybase ASE - track all changes in DB made by a stored procedure - 03-05-2009 , 02:16 AM






Hi all,

I have a bunch of undocumented stored procedures (legacy).
What I want, is to find out for each procedure, what changes it makes
in all the database. We want to replace these procedures with some
equivalent (maby sth java-based), and thus I have to know what values
are modified, or inserted to the db.

What is the best approach to track these updates/inserts/deletes done by
stored procedure? Is it possible at all?

Regards,
Chris

Reply With Quote
  #2  
Old   
mpeppler@peppler.org [Team Sybase]
 
Posts: n/a

Default Re: Sybase ASE - track all changes in DB made by a stored procedure - 03-05-2009 , 06:57 AM






I suppose that you can do a code analysis to try to see which procs
are called from your proc, and which tables these modify, etc.

I know of a tool (non-free) that will do this for you and generate a
comprehensive report of the entire SQL code base (well - based on the
code in the database). You can check out www.sqlbrowser.com in case
you're interested.

Michael

On Mar 5, 9:16*am, Krzysztof Adamczyk
<krzysztof_DOT_adamczyk (AT) gmail_CUT_ (DOT) com> wrote:
Quote:
Hi all,

I have a bunch of undocumented stored procedures (legacy).
What I want, is to find out for each procedure, what changes it makes
in all the database. We want to replace these procedures with some
equivalent (maby sth java-based), and thus I have to know what values
are modified, or inserted to the db.

What is the best approach to track these updates/inserts/deletes done by
stored procedure? Is it possible at all?

Regards,
Chris


Reply With Quote
  #3  
Old   
Krzysztof Adamczyk
 
Posts: n/a

Default Re: Sybase ASE - track all changes in DB made by a stored procedure - 03-05-2009 , 07:51 AM




Thanks for your reply!

mpeppler (AT) peppler (DOT) org [Team Sybase] wrote:
Quote:
I suppose that you can do a code analysis to try to see which procs
are called from your proc, and which tables these modify, etc.
Of course I will do a lot of code analysis, but these procedures are
extremely huge (BTW I'd like to talk to the authors...) and I'm looking
for a tool that will help me with this analysis.

Quote:
I know of a tool (non-free) that will do this for you and generate a
comprehensive report of the entire SQL code base (well - based on the
code in the database). You can check out www.sqlbrowser.com in case
you're interested.
Thanks again - I'll definitely check it out

Quote:
Michael
Greetings,
Chris


Reply With Quote
  #4  
Old   
Bret_Halford
 
Posts: n/a

Default Re: Sybase ASE - track all changes in DB made by a stored procedure - 03-05-2009 , 12:28 PM



On Mar 5, 1:16*am, Krzysztof Adamczyk
<krzysztof_DOT_adamczyk (AT) gmail_CUT_ (DOT) com> wrote:
Quote:
Hi all,

I have a bunch of undocumented stored procedures (legacy).
What I want, is to find out for each procedure, what changes it makes
in all the database. We want to replace these procedures with some
equivalent (maby sth java-based), and thus I have to know what values
are modified, or inserted to the db.

What is the best approach to track these updates/inserts/deletes done by
stored procedure? Is it possible at all?

Regards,
Chris
I think you have to do it by code analysis. Just looking at what a
single run of a proc
does isn't good enough because of conditional logic.



Reply With Quote
  #5  
Old   
bslade
 
Posts: n/a

Default Re: Sybase ASE - track all changes in DB made by a stored procedure - 04-14-2009 , 08:56 AM



If you have auditing installed/enabled you could try commands like:

use mydb
go
sp_audit "exec_procedure", "all", "myproc",'on'
go
-- do the following for each table, where <operation> = insert/update/
delete
sp_audit "<operation>", "all", "mytbl", "on"
go
select a.spid, a.event, a.eventtime, suser_name(a.suid), dbname,
objname, objowner, extrainfo
from sybsecurity..sysaudits_01 a /* 01 could be a different number */
where eventtime>"a recent time"
and dbname="mydb" and objname not like "sys%"
-- look for events: delete, insert, update, and exec procedure
where event in (18,19,41,42,70,71, 38)
go

and look for insert/update/deletes which occur at almost the same time
as an exec procedure, with the same spid. You could probably write
some sort of fancy synchronized subquery to extract what you're
looking for.

This will generate a lot of audit logging which could slow down your
server. Depending on how you have auditing setup, the audits logs
could be archived to a repository where you can run these queries. If
audit logs are setup to reuse themselves, you'll have to run the
queries before the audit log gets reused/overwritten.

Not particularly easy, but doable.

Ben Slade
Chevy Chase, MD

On Mar 5, 4:16*am, Krzysztof Adamczyk
<krzysztof_DOT_adamczyk (AT) gmail_CUT_ (DOT) com> wrote:
Quote:
Hi all,

I have a bunch of undocumented stored procedures (legacy).
What I want, is to find out for each procedure, what changes it makes
in all the database. We want to replace these procedures with some
equivalent (maby sth java-based), and thus I have to know what values
are modified, or inserted to the db.

What is the best approach to track these updates/inserts/deletes done by
stored procedure? Is it possible at all?

Regards,
Chris


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.