Oracle ROWID

Posts   
 
    
Kazak1
User
Posts: 39
Joined: 30-May-2006
# Posted on: 13-Jul-2006 01:45:10   

Is there a way to include ROWID pseudocolumn in a resultset?

I tried the following code, but it did not work as the rowid column was included with parenthesises and an alias.

        ResultsetFields fields = new ResultsetFields(2);
        fields.DefineField(MyEntityFields.MyEntityId, 0, MyEntityFields.MTestId.Name);
        fields.DefineField(MyEntityFields.MyEntityId, 1, "ROWID");
        fields[1].ExpressionToApply = new DbFunctionCall("ROWID", null);

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 13-Jul-2006 09:28:30   

I once did a similar trick to fetch random rows from Sqlserver using NEWID() This is the code converted to your case with ROWID IEntityField2 rowIDField = new EntityField2("ROWID", null); rowIDField .Alias = "ROWID"; rowIDField .ExpressionToApply = new Expression();

I'm not sure if it works (not tested with ROWID), but I think it will turn out OK. Be sure that it's not the first field in the resultset.

Frans Bouma | Lead developer LLBLGen Pro
Kazak1
User
Posts: 39
Joined: 30-May-2006
# Posted on: 13-Jul-2006 18:26:56   

I tried what you suggested. It fails on FetchTypedList with NullReferenceException.

ResultsetFields fields = new ResultsetFields(2);
fields.DefineField(MyEntityFields.MyEntityId, 0, MyEntityFields.MTestId.Name);
fields[1] = new EntityField2("ROWID", null);
fields[1].Alias = "ROWID";
fields[1].ExpressionToApply = new Expression();

DataTable table = new DataTable();
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
   adapter.FetchTypedList(fields, table, null);
}
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 14-Jul-2006 12:16:43   

I've to say it's not going to work. The context in which I used it (the NEWID()) was in a sortexpression, which basicly tricked the DQE to simply emit the alias because the expression was there, so as the alias was the actual function, it worked.

In your case, it doesn't do that, as it either wants to emit the field or the expression. However as you're using adapter, under the hood the persistence info has to be retrieved for the fields/expression, and there's no way around that.

Frans Bouma | Lead developer LLBLGen Pro