Hi!

A subquery generated by NHibernate caused a database exception. After 
some debugging, I could track down the problem to the .Net-Provider 
layer. Here is some sample code:

FbCommand cmd = new FbCommand("SELECT count(*) as y0_ FROM Department 
this_ WHERE @p0 < (SELECT count(*) as y0_ FROM Product this_0_ WHERE 
this_0_.Department = this_.Number)");

cmd.Parameters.Add("@p0", 0);
using (cmd.Connection = new 
FbConnection("ServerType=1;User=SYSDBA;Pooling=false;Password=masterkey;Dialect=3;Database=test.fdb"))
{
     cmd.Connection.Open();
     result = Convert.ToInt32(cmd.ExecuteScalar());
}

It fails with "SQL error code = -804 Data type unknown ---> 
FirebirdSql.Data.Common.IscException".

When I change the sql command to:

SELECT count(*) as y0_ FROM Department this_ WHERE 0 < (SELECT count(*) 
as y0_ FROM Product this_0_ WHERE this_0_.Department = this_.Number)

or

SELECT count(*) as y0_ FROM Department this_ WHERE (SELECT count(*) as 
y0_ FROM Product this_0_ WHERE this_0_.Department = this_.Number) > @p0

then it is working perfectly.

So the problem appears only, if the parameter is on the left side of the 
subquery. Could this be a bug in the parameter substitution?

bye,

Tobias

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to