Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to execute URL from T-SQL Script

Author  Topic 

vinay789
Starting Member

40 Posts

Posted - 2010-01-25 : 03:55:03
Hi experts,
I am running a T-SQL script in sql server 2005.In this T-SQL script Actually i need to call this URL http://localhost:65535/project/test.jsp
in which it will invoke my jsp code in server.Can u pls tell me with good example how to do this.
Thanks i advance.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-01-25 : 05:34:20
Something like this.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=111356



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

vinay789
Starting Member

40 Posts

Posted - 2010-01-25 : 05:37:28
Any idea experts
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-01-25 : 05:53:01
What's wrong with my example?



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

vinay789
Starting Member

40 Posts

Posted - 2010-01-25 : 09:42:19
Hi
Peso with your example i have created one T-SQL scrpit to execute URL as shown below

declare @object int
declare @return int
declare @valid int
set @valid = 0

--create the XMLHTTP object
exec @return = sp_oacreate 'Microsoft.XMLHTTP', @object output
if @return = 0
begin

--Open the connection
exec @return = sp_oamethod @object, 'open("GET",
"http://localhost:65535/chart/test.jsp", false)'

if @return = 0
begin
--Send the request
exec @return = sp_oamethod @object, 'send()'
--PRINT @return
end

if @return = 0
begin
declare @output int
exec @return = sp_oamethod @object, 'status', @output output

if @output = 200
begin
set @valid = 1
end
end
end

--destroy the object
exec sp_oadestroy @object

if @valid = 1
print 'valid'
else
print 'invalid'

its running successfully and giving output as valid but output is not generating bcoz when we run this url a chart is stored in my system.Pls tell me how to test if the current urk is invoked or not.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-01-25 : 13:39:28
A chart?
Maybe you can help us by providing more information...



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

vinay789
Starting Member

40 Posts

Posted - 2010-01-27 : 00:37:36
Hi peso in my T-sql script i am doing a job scheduling. In this job whenever the GETDATE() matches with my database query i want to run this http URL request http://localhost:65535/chart/test.jsp this will generate one chart in back ground and stored in my system and now i will email this chart to user in run time this is my requirement. I have done all but i dont know how to invoke this http request from T-sql script pls help me how to invoke this URL from T-sql script.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-01-27 : 03:24:08
Chart?
What is that? A component displaying data in bars or a lines?
If you want an image of the chart to be emailed to your customers, you must first invoke a call to the "chart" page to save an image on file.
Then you easily can attach that file to your email.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

vinay789
Starting Member

40 Posts

Posted - 2010-01-27 : 04:17:29
Hi
Peso thanks for your reply a Chart is a component displaying data in bars or a lines.I want exactly what you told in previous post to send an email i have to invoke a call my problem is how to invoke a call is there any stored procedure to call URL pls tell me how to make a call with an example
Go to Top of Page

vinay789
Starting Member

40 Posts

Posted - 2010-01-27 : 05:55:27
Thankyou very much for your replies I got it.
Go to Top of Page
   

- Advertisement -