I am getting an error when I execute my script in Java RFT automation.
I am using SQL queries in my java code.
but here its throwing "Invalid pseudocolumn" error and I am not getting what is the mistake !!
[ I have tried passing variable without quotes, and with single quotes both , ending up with the same error.
and when i try the query directly on the database, it works fine ]

Could any one suggest me what can be done??

Following is the part of my code :
System.out.print("Executing ...");
results = DBconn.query("select SOID from tbl_SalesOrders where SalesOrder = $SOnum");

if (results == null) {
logTestResult("SO not present", false);
} else {
logTestResult("SO present ", true);
int SOID = results.getInt("SOID");
System.out.println(" " + SOID + " ");

results1 = DBconn.query("select * from tbl_SalesOrderDetail where SOID = $SOID");

if (results1 == null) {
logTestResult("SO detail not present", false);
} else {
logTestResult("SO detail present ", true);

Out put on the RFT Console :
Connected to Database
Executing .....select * from tbl_SalesOrders where SalesOrder = $SOnum
com.microsoft.sqlserver.jdbc.SQLServerException: Invalid pseudocolumn "$SOnum".
at com.microsoft.sqlserver.jdbc.SQLServerException.ma keFromDatabaseError(SQLServerException.java:197)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.ge tNextResult(SQLServerStatement.java:1493)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.do ExecuteCursored(SQLServerStatement.java:1853)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.do ExecuteStatement(SQLServerStatement.java:749)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$St mtExecCmd.doExecute(SQLServerStatement.java:676)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IO Buffer.java:4874)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.e xecuteCommand(SQLServerConnection.java:1400)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.ex ecuteCommand(SQLServerStatement.java:179)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.ex ecuteStatement(SQLServerStatement.java:154)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.ex ecuteQuery(SQLServerStatement.java:611)
at dbc.DBConnection.query(DBConnection.java:84)
at Tasks.Orders.SODetailsInDB(Orders.java:72)