Showing posts with label returned. Show all posts
Showing posts with label returned. Show all posts

Wednesday, March 7, 2012

Best method to access web service

We have a billing web service where you passs in the account and amount and get returned an XML string with result.

I had suggested that I open up an endpoint and have the service listen for messages but the programming team wont go for it.

What is the best method for me to call an external web service? I have tried sp_OACreate and run into memory leaks and have not had much luck with assemblies. See http://www.codeproject.com/script/comments/forums.asp?forumid=1725&select=2180035&df=100&msg=2180035

The best method should be assemblies, follow the old post from Vineet: http://blogs.msdn.com/sqlclr/archive/2005/07/25/Vineet.aspx, it shows how to explictly generate the serialization code If I remeber correctly the problem is that the default option for Visual studio projects is to generate code that creates the serialization at runtime, invoking csc.exe on the fly, which clearly won't work for SQL assemblies.

Openning an endpoint (I asumme an HTTP endpoint) won't solve your problem, that is available only for incomming calls (an app can access your SQL endpoint as an WS call) and my understanding is that you want to do it the other way (have a SQL procedure invoke a WS)

Monday, February 13, 2012

Beginners Question on SQL-DISTINCT

Hi.

I did this
SELECT BOTTLEA, BOTTLEB, BOTTLEC FROM MYPRODUCTS

But, I would like to have the result returned only for distinct
BOTTLEB. BOTTLEA and C can be anything. But the result that I get from
the statement must have BOTTLEB as distinct. How do I do that?

I tried

SELECT DISTINCT BOTTLEA, BOTTLEB, BOTTLEC FROM MYPRODUCTS

The result returned include duplicated BOTTLEB. I'm stuck. Appreciate
any help. Thanks in advance!SELECT MAX(BOTTLEA), BOTTLEB, MAX(BOTTLEC) FROM MYPRODUCTS
GROUP BY BOTTLEB

(MAX being a subset of "anything" ;-)
If SQL Server allows TOP in subqueries you could also do a correlated join:
SELECT ANY.BOTTLEA, DIST.BOTTLEB, ANY.BOTTLEC
FROM (SELECT DISTINCT BOTTLEB FROM MYPRODUCTS) AS DIST,
(SELECT TOP 1 BOTTLEA, BOTTLEB, BOTTLEC FROM MYPRODUCTS
WHERE BOTTLEB = DIST.BOTTLEB) AS ANY

(hope I got the TOP syntax right)

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab|||>> I tried > SELECT DISTINCT BOTTLEA, BOTTLEB, BOTTLEC FROM
MYPRODUCTS; The result returned include duplicated BOTTLEB. <<

The SELECT DISTINCT clause works on whole rows and removes redundant
duplicates; it has nothing to do with columns.

Do a GROUP BY on Bootle_B and some aggregatge function on the other
two.|||Thanks for the pointer. It works!

But if I want to include a requirement that says where BOTTLEB >= 20
dollars, it doesnt seem to work.

Doesnt work->
SELECT MAX(BOTTLEA), BOTTLEB, MAX(BOTTLEC) FROM MYPRODUCTS GROUP BY
BOTTLEB WHERE BOTTLEB>= 20

Any advise please? Thank you once again!

Serge Rielau <srielau@.ca.eye-be-em.com> wrote in message news:<cbhbe4$f3q$1@.hanover.torolab.ibm.com>...
> SELECT MAX(BOTTLEA), BOTTLEB, MAX(BOTTLEC) FROM MYPRODUCTS
> GROUP BY BOTTLEB
> (MAX being a subset of "anything" ;-)
> If SQL Server allows TOP in subqueries you could also do a correlated join:
> SELECT ANY.BOTTLEA, DIST.BOTTLEB, ANY.BOTTLEC
> FROM (SELECT DISTINCT BOTTLEB FROM MYPRODUCTS) AS DIST,
> (SELECT TOP 1 BOTTLEA, BOTTLEB, BOTTLEC FROM MYPRODUCTS
> WHERE BOTTLEB = DIST.BOTTLEB) AS ANY
> (hope I got the TOP syntax right)
> Cheers
> Serge|||Never mind about my last message.
I just have to reverse the order and it works again.

SELECT MAX(BOTTLEA), BOTTLEB, MAX(BOTTLEC) FROM MYPRODUCTS WHERE
BOTTLEB>= 20 GROUP BY BOTTLEB

Thanks!!!

Serge Rielau <srielau@.ca.eye-be-em.com> wrote in message news:<cbhbe4$f3q$1@.hanover.torolab.ibm.com>...
> SELECT MAX(BOTTLEA), BOTTLEB, MAX(BOTTLEC) FROM MYPRODUCTS
> GROUP BY BOTTLEB
> (MAX being a subset of "anything" ;-)
> If SQL Server allows TOP in subqueries you could also do a correlated join:
> SELECT ANY.BOTTLEA, DIST.BOTTLEB, ANY.BOTTLEC
> FROM (SELECT DISTINCT BOTTLEB FROM MYPRODUCTS) AS DIST,
> (SELECT TOP 1 BOTTLEA, BOTTLEB, BOTTLEC FROM MYPRODUCTS
> WHERE BOTTLEB = DIST.BOTTLEB) AS ANY
> (hope I got the TOP syntax right)
> Cheers
> Serge