Showing posts with label executes. Show all posts
Showing posts with label executes. Show all posts

Wednesday, March 28, 2012

Running a Sql query from Crontab.

Hi,

I want to run a sql query from a crontab.
I hav written a script which enters SQLPLUS , executes the query and directs the output to a flat file.

My problem is when Iam palcing the script in crontab it is throwing an error .But when executed in the prompt ,it is running.

pls give ur suggestions on that.If you don't spell the name of the script correctly, then SQL Plus will throw an error.

As you probably guessed, I'm trying to be funny. ;) Without you providing information about the error being thrown, we have to guess at it. There's a pretty wide area for guessing!

Please be more specific. Cut the error message from the log (SQL Plus output) file, and post it here. If possible (without security or related problems), cut the whole command you are using, and post that here too.

With all of the people that contribute here, I'm sure that someone can help you if you can give them the information that they need to do that!

-PatPsql

Friday, March 9, 2012

Run DTS from ASP.NET (VB)

I have a DTS package which imports data from a legacy app to SQLServer 2000. Right now I have a page in classic ASP which executes a SP which in turn calls the DTS package. After the user hits the "Update" button on the ASP page they are redirected to a page that says "This process takes several minutes, check back later." The current setup is causing problems because Joe may hit the "Update" button to refresh the data and get an error because the DTS package is already running from when Mary just ran the same process.

I want to rewrite this in .NET (2.0) to accomplish the following:

    Eliminate the SPCheck the status of the DTS package and alert the user if it is already running.Show a "Please wait while we process your request" message to the person who started the update while the DTS is running.Automatically show the report when the DTS is done.

I think I can find code in the forum to execute the DTS, but how do check the current status first? I've read about SQLDMO but the Web server and SQLServer are on different machines. Would this still work?

Thanks in advance.

I'm having trouble getting the DTS execute to run asynchronously. All the examples I've found show executing queries asynchronously, but nothing on DTS (there all in C# as well). Here's what I have in my class.

Imports System.IO
Imports System.NetImports System.Net.Mail
Imports System.ThreadingImports System.Runtime.Remoting.Messaging
Imports DTS
Imports DTS.DTSSQLServerStorageFlags

PartialClass Reporting_AmSherReports_rptColStats
Inherits System.Web.UI.Page
'----------------------------
'Remember, if you change the package, these numbers will need to be modified too.
'----------------------------

Private sPkgIDAs String ="{4CFD14F0-12D8-445C-AD98-E0DD784B166A}"
Private sPkgVersionAs String ="{F0CAFA3B-9A52-4780-B0C6-5B86C38BCFC5}"
Protected sMessageAs String =""

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Load
If Page.IsPostBackThen

'Show processing message...

Processing.Visible =True
Report.Visible =False
Refresh.Visible =False

Dim stateAs New Object()
Dim beginHandlerAs New BeginEventHandler(AddressOf ExecuteDTS)
Dim endHandlerAs New EndEventHandler(AddressOf DTSComplete)
Dim timeoutHandlerAs New EndEventHandler(AddressOf DTSTimeout)
Dim taskAs New PageAsyncTask(beginHandler, endHandler, timeoutHandler, state)
RegisterAsyncTask(task)
End If
End Sub

Private Function ExecuteDTS(ByVal senderAs Object,ByVal eAs EventArgs,ByVal cbAs AsyncCallback,ByVal stateAs Object)As IAsyncResult
Try
Dim sSourceAs String =""
Dim sDescAs String =""
Dim lErrAs Long
Dim oPKGAs DTS.Package =New DTS.Package
Dim oStepAs DTS.Step

'Load Package

oPKG.LoadFromSQLServer("server","sa","", DTSSQLStgFlag_UseTrustedConnection, , sPkgID, sPkgVersion,"Refresh Stats")

'Execute

oPKG.Execute()

'Get Status and Error Message

For Each oStepIn oPKG.Steps
If oStep.ExecutionResult = DTSStepExecResult.DTSStepExecResult_FailureThen
oStep.GetExecutionErrorInfo(lErr, sSource, sDesc)
sMessage = sMessage &"Step """ & oStep.Name &""" Failed" & vbCrLf & _
vbTab &"Error: " & lErr & vbCrLf & _
vbTab &"Source: " & sSource & vbCrLf & _
vbTab &"Description: " & sDesc & vbCrLf & vbCrLf
End If
Next
Catch exAs Exception
Finally
Processing.Visible =False
Report.Visible =True
Refresh.Visible =False
End Try
End Function

Private Sub DTSComplete(ByVal arAs IAsyncResult)
Processing.Visible =False
Report.Visible =True
Refresh.Visible =True
End Sub

Private Sub DTSTimeout(ByVal arAs IAsyncResult)
'No implementation -- needed for PageAsyncTask

End Sub
End Class

Wednesday, March 7, 2012

run a Package from package

I have a DTS package that executes a procedure returns a global variable.

In the next ActiveX task (vb) I'd like to examine the variable and based on its value run other DTS packages but I do not know how to set up the code to run a DTS package from within an ActiveX script.

Any help appreciated .
SteveGo to Start > Run and type DTSRUNUI
Type in the SQL Server connection info at the bottom
Click the [...] button at the to choose the package name. Click [Advanced]
Click the [Generate] button
To the left of the [Generate] button, you will see the command to run the DTS from command line.