Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DOEVENTS in SQL

Posted on 2004-08-04
8
Medium Priority
?
2,508 Views
Last Modified: 2012-05-05
Hi,

anyone know of a DOEVENTS type command in SQL Server?

For info, this is to allow processor time to catch-up while processing OA objects.

bukko
0
Comment
Question by:bukko
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 26

Expert Comment

by:Hilaire
ID: 11715702
There is no event handling in SQL Server, at least not the same kind of events(mousemove, keypress, paint, activate) than in client applications in which you'd use DoEvents in VB.

The only "events" in SQL server are, unless I'm wrong, the INSERT, UPDATE, DELETE events that fire triggers.
You can disable and enable triggers using alter table ....

COuld you be more precise on what you want to achieve ?
0
 
LVL 8

Author Comment

by:bukko
ID: 11715779

I'm calling a method in an OA object, then reading an IsRunning type property, which contantly returns 1 (Yes).
I'm wondering if this is because it doesn't have time to do what it needs because of being contanly polled.
If I build the object into an exe and call using xp_cmdshell, all works fine. However, I'm not allowed access to xp_cmdshell for security reasons.
So, what I need is a way to release processor time so the component can get on with its life without me bothering it too much.

Any ideas?

bukko
0
 
LVL 26

Accepted Solution

by:
Hilaire earned 2000 total points
ID: 11715808
If you use the OA objects in a loop,

I think (not sure but it's worth a try) the issuing a
WAITFOR DELAY '00:00:01'
inside the loop
will leave a little CPU time (1 sec) for other processes

If it's the OA objects that take CPU time and don't leave enough for SQL Server to handle client requests properly, I'm afraid there's not much you can do.

Can you post your code ?
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 8

Author Comment

by:bukko
ID: 11715833
I'll try the WAITFOR thing; if that doesn't work I'll post my code.

Ta...
0
 
LVL 8

Author Comment

by:bukko
ID: 11715986
Hilaire,

I think your logic is ok, but it still aint working. Maybe it's not a CPU thing at all.

The component is a PDF creating component.
My SQL code as follows:

      -- Check if object busy
      EXEC      @result      = master.dbo.sp_OAGetProperty @h_pdf, 'StillRunning', @running OUT
      IF (@@ERROR|@result > 0)
            RAISERROR('Unable to read StillRunning property', 16, 1)

      WHILE      @running = 1
            BEGIN
            WAITFOR DELAY '00:00:01'
            EXEC      @result      = master.dbo.sp_OAGetProperty @h_pdf, 'StillRunning', @running OUT
            IF (@@ERROR|@result > 0)
                  RAISERROR('Unable to read StillRunning property', 16, 1)
            PRINT @running
            END

      EXEC      @result      = master.dbo.sp_OADestroy 16711422
      IF (@@ERROR|@result > 0)
            RAISERROR('Unable to destroy PDF component', 16, 1)


Any ideas?
0
 
LVL 26

Expert Comment

by:Hilaire
ID: 11716015
the "createObject" or sp_OACreate should return an INT value @h_pdf

You should use this handle to destroy the object
Instead, you use a hard-coded 16711422

Is it a typo ?

it should be

EXEC     @result     = master.dbo.sp_OADestroy @h_pdf

0
 
LVL 8

Author Comment

by:bukko
ID: 11716073
Yeah, that's just my test snip.
I do normally use @h_pdf
0
 
LVL 8

Author Comment

by:bukko
ID: 11716478
I wrapped the PDf component in an ActiveX dll and it works fine now.

I'm giving you the points for your suggestion, which is actually what I asked for!

Thanks.

bukko
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question