I want to translate this SQL query, in JOOQ. I want the new field from calculated value, but here i just add it with constant value.
select
*,
100 as "newField"
from author
I tried this
Result<Record> r=create.select(DSL.asterisk(),DSL.val(100).as("newField"))
.from(DSL.table("author"))
.fetch();
That generates this SQL (which looks fine)
select
*,
? as "newField"
from author
But i get this as result (expected is all table with 1 extra column with value 100)
+--------+
|newField|
+--------+
|1 |
|2 |
+--------+
In pgAdmin, the sql above query does what i need(adds a new field to the table with all values 100).
I don't know what i do wrong, the results seems like newField
gets as value the row number.
Also in SQL generation how i can print the SQL with the 100
value instead of ?