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)
 SQL-Server to Oracle

Author  Topic 

shahzeb
Starting Member

6 Posts

Posted - 2008-03-30 : 05:39:15
Hi guys, I have some queries in SQL-Server. Now i am supposed to convert one of the queries in Oracle, so that it works there. i dont have oracle server running with me. So i wanted to know that if i want to write this query for oracle, how would it be ? any idea.

SELECT top @@5 Id,StartDate,OwnerId,Subject,TypeId FROM Interaction WHERE (Interaction.Subject) like ('@@1%') and Interaction.StartDate >= '@@2' and Interaction.StartDate <= '@@4' and Interaction.ContactId ='@@3' and MediaTypeId='email' and TypeId like 'Inbound' ORDER BY Interaction.StartDate DESC<

bfoster
Starting Member

30 Posts

Posted - 2008-03-30 : 14:22:29
As a starting point, I think in place of "top @@5", you'd use "rownum <= @@5" in the where clause. Your dates would need to be sent in a format that Oracle understands or you could use the Oracle TO_DATE function where you specify the format. I haven't worked with Oracle very much in the last 2-3 years so I may have missed something.
Go to Top of Page

kbsimm
Starting Member

5 Posts

Posted - 2008-03-30 : 15:08:54
Oracle uses & for variable rather then @ so you want rownum<=&&5 to use arg #5 and preserve it or just rownum<=&5 to use arg #5 and discard it.

And to use the TO_DATE function makes sure you wrap both sides with TO_DATE like TO_DATE(Interaction.StartDate) <= TO_DATE('30-MAR-08')
Go to Top of Page
   

- Advertisement -