In my work we are using variables as the parameters for our queries in a microsoft sql server database.
There we work using queries such as:
Code: Select all
DECLARE @YEAR as INT
SET @YEAR = ?
-- the "?" thing is because we are working with Java's prepared statements
SELECT TOP 10, * FROM TABLE_NAME WHERE YEAR = @YEAR
-- the query itself comes here
The problem arrived when we decided to move our development platform from windows to linux. But there is a problem with that: our client's database will still be Microsoft SQL Server and then our code must work in both servers.
Is there a standard way (ie, ANSI SQL) for variable declaration in queries? If not, do you know another (better) way for accomplishing what we need?
By the way: using hybernate or any other mapping is not desired because we don't need object mappings. We need to receive a table-like structure. I know hybernate has it own query language and I'd love to use it, but I have no idea on how to extrat the data without mapping it to an object (I did research on this matter and I found nothing).
And please, don't RTFM me. I already did it and I couldn't find anything usefull. Also, I'm posting this here because this is the best forum about anything related to computers that I know and because we are going to use gentoo linux in our server.


