Asynchronous calls with stored procedure

Is it possible to call a stored procedure asynchronously from another stored procedure?

Edit: In particular, I am working with a DB2 database.

+5
sql stored-procedures db2
source share
3 answers

Summary: Yes, if your database has a message queue service.

You can send a message to the queue, and the queue processor will consume it asynchronously.

  • Oracle: Queues
  • Sql server: service broker
  • DB2: event broker

For pure stored procedure languages ​​(PL / Sql or T-Sql), the answer is no, because it works against the main transaction model, which has most databases.

However, if your database has a queuing mechanism, you can use it to get the same result.

+5
source share

With MS Sql Server 2005, try the Service Broker and / or CLR stored procedures. I do not think that there is something built directly in TSQL.

+1
source share

It looks like you need to host some scheduled tasks using Cron (or windows equiv). You can use the initial stored call to proc to set a flag in the database, which is then checked periodically by the cron job. If you need to complete a certain delay before completing the second task, you should be able to do this by completing the task scheduled by the cron task.

0
source share

All Articles