Yeah, detached. But you can make it a lot easier if you don't do tricky JALScript.Execute(JalStr) but simply write directly to the schedule.log file without calling JALScript. To update the job log simply append your message to "INFO" & vbTab & "119" & vbTab & "Invoice Batch Status" & vbTav & invstatus & vbCrLf : I run this job every 20 minutes. It's sole purpose is just to monitor when : there are Invoice Batches open and write that information to the 24x7 job : log. This thing (see code below) eats up memory resources like crazy and I : have to restart the 24x7 process at least once every day or so. Sometimes : 24x7 just hangs when I try to shut it down. I know what your going to say, : "Run the job detached". However, when I run it detached, it will : not update the 24x7 job log with start/stop times or anything. So that : defeats the purpose. I have many SQL jobs running written in VB and this : problem makes the automation very unreliable. : Two questions: 1. Is there something wrong with my code causing it not to : properly release the memory when it's complete? : 2. How can I update the job log from a detached process? : Any other thoughts or suggestions? : Thanks, : -Alan : VB Code: Sub Main( ) : ' declare variables : Dim db_conn : Dim rec_set : Dim query : Dim invstatus : Dim JalStr : ' open database connection : Set db_conn = CreateObject("ADODB.Connection") : Set rec_set = CreateObject("ADODB.Recordset") : query = "SELECT * FROM PUB.ARInvoiceBatch WHERE " & Chr(34) : & "Batch-Status" & Chr(34) & "='Open'" : db_conn.open "Progress", "userid", "password" : ' execute query : rec_set.open query, db_conn, 0,1 : If NOT rec_set.EOF then : invstatus = "Open Batch: " & rec_set("Created-By") : & " " & rec_set("Batch-Number") : Else : invstatus = "No Open Batches" : End if : rec_set.close : db_conn.close : JalStr ="LogAddMessageEx ""INFO"", 119, : ""Invoice Batch Status"", """ & : invstatus & """ " & vbCrLf : JALScript.Execute(JalStr) : Set db_conn = Nothing : Set rec_set = Nothing : Set query = Nothing : Set invstatus = Nothing : Set JalStr = Nothing : End Sub
|