How to implement this SQL statement with LLBLGenPro

Posts   
 
    
Sticky
User
Posts: 21
Joined: 02-Sep-2008
# Posted on: 14-Jan-2009 15:49:10   

Hi,

I'm using Adapter and the latest official release of LLBLGen Pro.

I have this SQL Statement:


(
select
    person.projekt_id,
    reg.projekt_titel,
    ans.afdelingsnavn,
    person.proj_deltager_init,
    person.proj_deltager_navn,  
    to_char(allo.uge, 'YYYY') aar,
    to_char(allo.uge, 'MM') maaned,
    TO_CHAR(allo.UGE, 'IW') uge, 
    allo.antal_timer allokeret,
    0 registreret 
from ((Hest.PAS$PROJ_ALLOKERINGER_T allo 
  left join Hest.PAS$PROJ_DELTAG_PERSONER_V person ON PERSON.PROJ_DELTAG_PERSON_ID = ALLO.PROJ_DELTAG_PERSON_ID)
  left join Hund.crm$ansatte_v ans ON ans.initialer=person.proj_deltager_init)
  left join pas$tidsregistreringer_v reg ON reg.projekt_id=person.projekt_id 
where 
  to_char(allo.uge, 'YYYY') > '2007'
  and (TO_CHAR(allo.UGE, 'IW') > '36' OR to_char(allo.uge, 'YYYY') > '2008')
  and allo.antal_timer > 0
)

union

(
select 
  reg.projekt_id,
  reg.projekt_titel, 
  ans.afdelingsnavn,
  reg.TIDSREG_INIT Initialer,
  reg.tidsreg_navn,
  to_char(tidsreg_dato, 'YYYY') aar,
  to_char(tidsreg_dato, 'MM') maaned,
  TO_CHAR(TIDSREG_DATO, 'IW') uge,
  0 allokeret,
  sum(reg.varighed) registreret
from pas$tidsregistreringer_v reg 
     left join Hund.CRM$ANSATTE_V ans ON ans.initialer = reg.TIDSREG_INIT
where 
  to_char(tidsreg_dato, 'YYYY')  > '2007'
  and reg.varighed > 0
  and reg.projekt_id is not null 
group by 
  reg.projekt_id,
  reg.projekt_titel, 
  ans.afdelingsnavn,
  reg.TIDSREG_INIT,
  reg.tidsreg_navn,
  to_char(tidsreg_dato, 'YYYY'),
  to_char(tidsreg_dato, 'MM'),
  TO_CHAR(TIDSREG_DATO, 'IW')
)

the _v are views.

and I would like to convert the code into some databindable object via LLBLGen Pro. How do I do this? simple_smile

Thanks in advance

/Kasper

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 14-Jan-2009 16:31:34   

Here are your options:

1- If you need to perform the UNION on the database side, then you should use a database View to host the entire posted SQL, and then map this to a TypedView or an Entity to be fetched by LLBLGen Pro.

2- If you want to pass paramteres, then instead of a View use a Stored Procedure which then can be mapped to a StoredProcedureCall.

3- If the Union can be done at client side (outside the database and inside your application), then maybe you need to use 2 DynamicLists for which the resultsSets (dataTables) can be merged.