> I'm now facing the following concern, which I don't know how to
> achieve, even since I've read the doc and browsed the api javadoc :
Where did you run into problems? Converting your " - " string to an
org.jooq.Field?
Something along these lines should work:
------------------------------------------------------------
import static org.jooq.impl.Factory.*;
Factory create = new Factory(...);
// Alias the countries table:
Countries t = Countries.COUNTRIES.as("t");
// Concat several org.jooq.Field objects.
// Use Factory.val() to create a bind value
create.select(t.ccode, concat(t.ccode, val(" - "), t.cname).as("value_"))
.from(t)
.orderBy(t.country.asc());
------------------------------------------------------------
Although, I don't know what t.country should refer to... If you do
need the casting to char, use the Field.cast() methods...
Cheers
Lukas
2012/3/18 Lukas Eder <lukas...@gmail.com>:
Hi,Thanks to reply, here i can't able to define DSL.groupConcat(). will u give the function definition.b'ços the site become very complex to understand.
Regards,Manikandan
jOOQ supports MySQL's GROUP_CONCAT()
function natively as DSL.groupConcat()
. Here's your corrected query with comments:
// Don't forget, of course:
import org.jooq.impl.DSL;
And then
// Use DSL.groupConcat() here
dslContext.select(DSL.groupConcat(AcUserField.AcLineId))
.from(AcHeader)
// Lower-case join()
.join(AcDetails)
.on(AcDetails.AcHeaderId.equal(AcHeader.AcHeaderId))
// Lower-case join()
.join(AcUserField)
.on(AcUserField.AcLineId.equal(AcDetails.AcLineId))
// Forgot to pass the parameter "1"
.and(AcUserField.FieldNo.equal(1))
// Lower-case where() and use .equal() or .eq() rather than a Java assignment "="
.where(AcHeader.Company.equal(1))
.and(AcHeader.AccountNo.equal(190000))
// List values in in(...) predicate individually, don't put them all
// in a single string.
.and(AcHeader.Status.in("C", "D")).fetch()
Optionally, if you prefer to use aliased versions of your tables, you can do so:
AcHeader AH = AcHeader.as("AH");
AcDetails AD = AcDetails.as("AD");
AcUserField AUF = AcUserField.as("AUF");
dslContext.select(DSL.groupConcat(AUF.AcLineId))
.from(AH)
.join(AD)
.on(AD.AcHeaderId.equal(AcHeader.AcHeaderId))
.join(AUF)
.on(AUF.AcLineId.equal(AD.AcLineId))
.and(AUF.FieldNo.equal(1))
.where(AH.Company.equal(1))
.and(AH.AccountNo.equal(190000))
.and(AH.Status.in("C", "D")).fetch()
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.