Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(SQL Server) Enter/Leave Context in LoggingDemonstrates EnterContext and LeaveContext using the Chilkat Log API.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls. -- CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int -- Important: Do not use nvarchar(max). See the warning about using nvarchar(max). DECLARE @sTmp0 nvarchar(4000) DECLARE @log int -- Use "Chilkat_9_5_0.Log" for versions of Chilkat < 10.0.0 EXEC @hr = sp_OACreate 'Chilkat.Log', @log OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END -- Initialize the log object with an initial context tag: EXEC sp_OAMethod @log, 'Clear', NULL, 'myLog' -- Add some information.. EXEC sp_OAMethod @log, 'LogInfo', NULL, 'Hello, I''m here...' -- Open a sub-context EXEC sp_OAMethod @log, 'EnterContext', NULL, 'abc' -- New information is now logged within the "abc" context. EXEC sp_OAMethod @log, 'LogInfo', NULL, 'This is inside the abc context' EXEC sp_OAMethod @log, 'LogError', NULL, 'File not found.' -- Perhaps open a new context... EXEC sp_OAMethod @log, 'EnterContext', NULL, 'fileInfo' EXEC sp_OAMethod @log, 'LogData', NULL, 'filename', 'something.txt' EXEC sp_OAMethod @log, 'LogData', NULL, 'path', '/somedir/xyz' EXEC sp_OAMethod @log, 'LeaveContext', NULL -- Close the "abc" context. EXEC sp_OAMethod @log, 'LeaveContext', NULL -- Examine the content of the log: EXEC sp_OAGetProperty @log, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 -- This is the output: -- myLog: -- Hello, I'm here... -- abc: -- This is inside the abc context -- File not found. -- fileInfo: -- filename: something.txt -- path: /somedir/xyz -- --fileInfo -- --abc -- --myLog EXEC @hr = sp_OADestroy @log END GO |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.