SubQuery in a DbFunctionCall

Posts   
 
    
Vonziz
User
Posts: 15
Joined: 05-Feb-2009
# Posted on: 14-Mar-2009 10:46:56   

Hi,

I'm trying to make a query like the following :


SELECT myFields 
FROM myTable 
WHERE MyFieldId = MyFunction(
(SELECT MyOtherId 
FROM MyOtherTable 
WHERE myFields = MyVariable)
)

I don't know how to put a subquery in a DBFunctionCall :


new DBFunctionCall("MyFunction({0})", new object[](??????????????????));

Thanks for your help.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Mar-2009 21:16:34   

I never tried something like that. What if you pass the query string to the param?

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 16-Mar-2009 10:17:14   

Odd requirement, as the function should do the select, you shouldn't pass in the result of the select to the function. (besides that, the function should accept a parameter but of what type?)

Frans Bouma | Lead developer LLBLGen Pro
Vonziz
User
Posts: 15
Joined: 05-Feb-2009
# Posted on: 16-Mar-2009 10:27:06   

With the query string, it works but I want to make that with LLBLGEN because it's not a good idea to put directly SQL code in my DAL... rage

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 16-Mar-2009 10:35:17   

Vonziz wrote:

With the query string, it works but I want to make that with LLBLGEN because it's not a good idea to put directly SQL code in my DAL... rage

Please read my post above. You should have a scalar query which produces the value based on input, and that input is then passed to the function. So the function isn't receiving a set, but does the sql itself.

Frans Bouma | Lead developer LLBLGen Pro
Vonziz
User
Posts: 15
Joined: 05-Feb-2009
# Posted on: 16-Mar-2009 10:36:04   

I have to make this kind of query because i've got a constraint with a clob field.

Before calling my function, i have to convert a string variable (length > 4000) from my Business Layer into a Clob variable in my Oracle side, that's why I use a temporary table and I make a select from this temporary table for my function call.

Any idea to solve this problem with LLGLGEN? simple_smile

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 16-Mar-2009 14:10:22   

Before calling my function, i have to convert a string variable (length > 4000) from my Business Layer into a Clob variable in my Oracle side, that's why I use a temporary table and I make a select from this temporary table for my function call.

Couldn't this function do the first select and the conversion.....(the entire logic)?

Otherwise I see no other way but to pass the SQL string as the function parameter.

Vonziz
User
Posts: 15
Joined: 05-Feb-2009
# Posted on: 16-Mar-2009 18:31:25   

The function can't make that because this is a package of functions from an editor and I can't change any code. That's why my problem is so complex. ^^

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 17-Mar-2009 06:08:01   

Then you'll have to pass pass the SQL string as the function parameter.