I want to get an integer from a database query:
SELECT CAST(concat('id_',substr_of_jointable) AS INTEGER) into integervalue
FROM books_authors where id_books = booksvalue
ORDER BY id_books DESC
LIMIT 1;
subsr_of_jointable
is a TEXT with value authors
. However I always get an error:
ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ERROR: invalid input syntax for integer: "id_authors"
Wobei: SQL statement "SELECT CAST(concat('id_',substr_of_jointable)AS INTEGER) FROM books_authors where id_books = books_value ORDER BY id_books DESC LIMIT 1"
PL/pgSQL function books_ins_trig_proc() line 125 at SQL statement
Does anyone have an idea why? The column id_books
id_authors
is an integer value in the database.
'id_authors'
to a number - that won't work – a_horse_with_no_name