Union Query

Posts   
 
    
JCroain
User
Posts: 10
Joined: 08-Dec-2006
# Posted on: 28-Mar-2007 13:19:57   

Hi all,

Could you help to code this kind of query.



Select society_id, function_id  from ... where .....

union

Select society_id, null from ... where ...

Can I do the union with 2 FetchTypedList and change the DefinedField before the second fetch??? And how to set the column to null.

Thanks!

DvK
User
Posts: 323
Joined: 22-Mar-2006
# Posted on: 28-Mar-2007 13:38:45   

You can REset a ResultFields field to a different IEntityField, but removing it will be difficult. But you should use 2 typedlists to fetch the 2 tables and merge them into one table, as UNION queries are not natively supported.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Mar-2007 14:00:10   

Union Queries are not supported. You will have to perform 2 fetches..i.e. 2 TypedLists (note that a TypedList is a DataTable) Then you should merge them together. Otherwise if you want to perform one fetch only, then you can use database view in which you define the entire query (with the Union), and map it to a TypedView or an Entity.

JCroain
User
Posts: 10
Joined: 08-Dec-2006
# Posted on: 28-Mar-2007 17:33:32   

Thanks for your response, but a last thing.

Is it possible to define a column of my ResultsetField as null ??

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 29-Mar-2007 08:35:25   

Just fetch the needed columns in each TypedList, and then when you come and merge them into a bigger TypedList, just use values of nulls, for the missing column data.

JCroain
User
Posts: 10
Joined: 08-Dec-2006
# Posted on: 29-Mar-2007 09:55:37   

Ok thanks for all.