Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 5 of 5 total |
SQL Intercept |
Wed, May 29 2013 3:57 PM | Permanent Link |
Owen | I have an application and no source code that I am attempting to redevelop. I would like to somehow intercept the SQL requests that are being sent to the database. I can run the application locally on my machine with some local database files. The first thing that comes to mind is somehow modify the DBSRVR so that it writes SQL requests to a txt file. Anybody have any ideas on this subject?
|
Thu, May 30 2013 12:14 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Owen,
<< I have an application and no source code that I am attempting to redevelop. I would like to somehow intercept the SQL requests that are being sent to the database. I can run the application locally on my machine with some local database files. The first thing that comes to mind is somehow modify the DBSRVR so that it writes SQL requests to a txt file. Anybody have any ideas on this subject? >> You're going to have to hack the dbisamsv.pas unit (C/S with source code product required) in order to log every operation in real time. If you need more information on this, you can open a support session (support@elevatesoft.com) and I'll be happy to help you out with the details/implementation. Tim Young Elevate Software www.elevatesoft.com |
Fri, May 31 2013 4:34 AM | Permanent Link |
Adam H. | On 30/05/2013 5:57 AM, Owen wrote:
> I have an application and no source code that I am attempting to redevelop. I would like to somehow intercept the SQL requests that are being sent to the database. I've done something similar from a logging perspective, but it's a bit clumsy, and doesn't log every SQL call. (I would LOVE to be able to do that). I'm also suspicious that it does have a bit of a performance hit as well. On the plus side, it doesn't hack at Tim's code but rather just adds some extra code into the DBSRVR application / service. In the ServerEngineAfterUpdateTrigger I have the following: ----------------------- procedure TMainForm.ServerEngineAfterUpdateTrigger(Sender: TObject; TriggerSession: TDBISAMSession; TriggerDatabase: TDBISAMDatabase; const TableName: string; CurrentRecord: TDBISAMRecord); const detailedlogfile = 'c:\temp\mylog.txt'; var i : integer; Msg : TStringList; f1 : TextFile; begin if FileExists(DetailedLogFile) then if uppercase(TriggerDatabase.DatabaseName) <> 'MEMORY' then //DONT LOG MEMORY TABLES if (AnsiCompareText(TableName,'log')<>0) then //don't log this table either begin Msg := TStringList.create; for I := 0 to CurrentRecord.fieldcount - 1 do // Iterate if CurrentRecord.fields[i].fieldkind = fkdata then if CurrentRecord.fields[i].value <> CurrentRecord.fields[i].oldvalue then // Msg.add('Table '+TableName+#9+'RecordID '+inttostr(CurrentRecord.RecordID)+#9+'Field: '+CurrentRecord.fields[i].fieldname+ #9+'Altered'+#9+'Old Value: ' + quotedstr(vartostr(CurrentRecord.fields[i].oldvalue)) + #9+ 'New Value: ' + quotedstr(vartostr(CurrentRecord.fields[i].value))); Msg.add(DateTimeToStr(now)+#9+'RemoteUser '+Triggersession.CurrentServerUser+#9+'Table '+TableName+#9+'RecordID '+inttostr(CurrentRecord.RecordID)+#9+'Field: '+CurrentRecord.fields[i].fieldname+ #9+'Altered'+#9+'Old Value: ' + quotedstr(vartostr(CurrentRecord.fields[i].oldvalue)) + #9+ 'New Value: ' + quotedstr(vartostr(CurrentRecord.fields[i].value))); if msg.text <> '' then begin assignfile(F1, DetailedLogFile); Append(f1); for i := 0 to Msg.Count - 1 do Writeln(f1, Msg[i]); CloseFile(F1) end; msg.free; Msg := nil; end; end; ----------------------- I suspect that you might be wanting to do something completely different and grab the SQL instead - and I REALLY like the idea of intercepting every SQL transaction - and would be very interested if you succeed. (I'd ask Tim to consider adding it as a feature in the next build, but the last time Tim did me a favour with DBISam, I think it created a lot of headaches for him, so I'm pulling my head in for the time being. <vbg>) Cheers Adam. |
Tue, Jun 4 2013 12:26 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Adam,
<< I suspect that you might be wanting to do something completely different and grab the SQL instead - and I REALLY like the idea of intercepting every SQL transaction - and would be very interested if you succeed. >> I think what I'm going to do is add an OnSQL trigger to the engine. It's easy to do, and I was just mucking about with the triggers recently, so the chances of screwing something up is small. << (I'd ask Tim to consider adding it as a feature in the next build, but the last time Tim did me a favour with DBISam, I think it created a lot of headaches for him, so I'm pulling my head in for the time being. <vbg>) >> The biggest problem I have with DBISAM stuff is that I just don't work on it very often anymore, so when I do, I'm just not as familiar with the code. But, that's what the automated regression testing is for. Tim Young Elevate Software www.elevatesoft.com |
Fri, Jun 7 2013 3:42 AM | Permanent Link |
Adam H. | Hi Tim,
> I think what I'm going to do is add an OnSQL trigger to the engine. > It's easy to do, and I was just mucking about with the triggers > recently, so the chances of screwing something up is small. That would be fantastic if you have the time. > The biggest problem I have with DBISAM stuff is that I just don't work > on it very often anymore, so when I do, I'm just not as familiar with > the code. But, that's what the automated regression testing is for. I know exactly where you're coming from. Just had a email from someone wanting a change made to a program that I designed back in the late 90's and haven't touched for who knows how many years. Not looking forward to going back there myself. Have a great weekend - and thanks Cheers Adam |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |