Need to convert MS SQL query to Oracle compatible
ArpanMApr 2 2011 — edited Apr 4 2011Hi,
We have a website from which our users can write his/her own qureries and run it whenever he/she wants. and he/she can write as many as he wants. (just like Query Analyzer where you can run query and get output)
The queries are stored in a database field as string and user can run it from the site. previosly our database was MS SQL.
Now we are moving to Oracle.
And when a user runs a query it generates the output and the form of the output is a table/record set, which I can bind it to a grid and show.
I am using ODP.NET for connecting to Oracle.
The problem is now some of our MS SQL queries are procedure type (have declare table/ insert into that table/do some operation and show from the table variable ) and it generates the output as table format. and I can bind it to grid. But in oracle those queries are treated as anonymus block PL/SQL and not generates output as table format.
So can you Oracle masters/gurus help me out of this situation as I need the solution very badly.
I have added one that type of query where I am stuck.
DECLARE @ProductTotals TABLE
(
ProductID int,
Revenue money
)
INSERT INTO @ProductTotals (ProductID, Revenue)
SELECT ProductID, SUM(UnitPrice * Quantity)
FROM [Order Details]
GROUP BY ProductID
UPDATE @ProductTotals
SET Revenue = Revenue * 1.15
WHERE ProductID = 62
DELETE FROM @ProductTotals
WHERE ProductID = 60
SELECT TOP 5 *
FROM @ProductTotals
ORDER BY Revenue DESC
Looking forward to your help.
Thanks,
Arpan