Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

CONCAT with single blank

10 views
Skip to first unread message

Simon Martinelli

unread,
Oct 27, 2024, 11:31:08 AM10/27/24
to jOOQ User Group
Hi,

If I do this:

concat(ATHLETE.club().ABBREVIATION, field(" "), ATHLETE.club().NAME)

I get

(("alias_128651403"."abbreviation" || cast(  as varchar)) || "alias_128651403"."name")

Which results in
org.springframework.jdbc.BadSqlGrammarException: jOOQ; bad SQL grammar [select "public"."athlete"."id", "public"."athlete"."first_name", "public"."athlete"."last_name", (("alias_128651403"."abbreviation" || cast(  as varchar)) || "alias_128651403"."name") from ("public"."athlete" left outer join "public"."club" as "alias_128651403" on "public"."athlete"."club_id" = "alias_128651403"."id") order by "public"."athlete"."first_name", "public"."athlete"."last_name" offset ? rows fetch next ? rows only]
at org.jooq_3.19.13.POSTGRES.debug(Unknown Source) ~[na:na]


To make it work I have to use

concat(ATHLETE.club().ABBREVIATION, field("' '"), ATHLETE.club().NAME)

Why?

Thanks, Simon

Kian Farah

unread,
Oct 28, 2024, 2:52:06 AM10/28/24
to jooq...@googlegroups.com
I think by using field("' '"), you're explicitly telling jOOQ to treat it as a string literal containing a space, which translates correctly into SQL. This is not what you asked by have u tried DSL.inline(" ") instead of field(" ")?

--
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.
To view this discussion visit https://groups.google.com/d/msgid/jooq-user/5c8aa7ca-75cc-4230-a6b1-8fc526343dc4n%40googlegroups.com.

Alf Lervåg

unread,
Oct 28, 2024, 2:52:12 AM10/28/24
to jooq...@googlegroups.com
You should be using val or inline for value literals. I’d go for the latter in this situation.

Alf Lervåg

27. okt. 2024 kl. 16:31 skrev Simon Martinelli <simon.ma...@gmail.com>:

Hi,
--

Simon Martinelli

unread,
Oct 28, 2024, 3:27:57 AM10/28/24
to jooq...@googlegroups.com
Hi all,

Didn’t think about val and inline!
Thanks for your help I use val:

concat(ATHLETE.club().ABBREVIATION, val(" "), ATHLETE.club().NAME))


Reply all
Reply to author
Forward
0 new messages