QuerySpec - call to DB function

Posts   
 
    
AVA
User
Posts: 12
Joined: 22-Feb-2016
# Posted on: 10-May-2016 14:55:47   

Hello,

I'm a newbee in QuerySpec. I have a custom function in Oracle database. Is it possible to call this function with QuerySpec? How can I achieve this?

Thanks in advance,

This is the sql query that I have to rewrite. I made a Queryspec query, but I don't know how to call the function get_active_adres without rewriting it

select p.insz_nr as betrokkene_insz, naam.naam || ', ' || DECODE(naam.voornaam, NULL, '''', '', '') || naam.voornaam AS betrokkene_naam, get_active_adres(p.id) as betrokkene_adres, u.bestemmeling_id_cd as bestemmeling_type, ... from tob_uitbericht u join tob_uitbericht_ag b ON (u.bericht_ag_id = b.bericht_ag_id) LEFT JOIN tob_uitbericht_type t on ( b.TYPE_BERICHT_CD = t.uitbericht_type_cd) LEFT JOIN tob_inbericht_in_divisie di on ( t.TOB_UITBERICHT_TYPE_ID = di.tob_inbericht_type_id) left join tag_partij p on (b.betrokkene_id = p.id) left join tag_partij m on (u.partij_bestemmeling_id = m.id) left join tob_omschrijving o on (u.omschrijving_id = o.omschr_id) left join tve_gebruiker c on (b.gb_beheerder_id = c.gbrk_id) left join tob_opdracht d on (b.opdracht_id = d.opdracht_id) left join tob_opdracht_type dt on (d.opdracht_type_id = dt.opdracht_type_id) left join tve_gebruiker e on (u.gb_ontwerper_id = e.gbrk_id) left join tag_gebruiker ontwerper_gerbuiker ON (e.fys_gebruiker_id = ontwerper_gerbuiker.id) left join tag_naam naam on (naam.partij_id = p.Id) left join tve_gebruiker verificator on (verificator.gbrk_id = u.verificator_id) left join tob_berichtgever r on (u.bestemmeling_tijdelijk_id = r.berichtgever_id) where u.bericht_id = BerichtId;

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 10-May-2016 23:46:21   

You need to map this db function to a custom function or method you write yourself in code. Mapping is also done in code through a class that inherits from FunctionMappingStore

Then you can use the custom function you defined in your code inside the QuerySpec or the Linq query. The system will replace it with the db function when it builds the sql query.

All is detailed here: http://www.llblgen.com/documentation/5.0/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/Linq/gencode_linq_functionmappings.htm

This is under the Linq section, but the same analogy and steps work for QuerySpec. http://www.llblgen.com/documentation/5.0/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/QuerySpec/gencode_queryspec_functionmappings.htm (It refers to the Linq section).