When I enter the following prepared statement:
PREPARE pstmt AS SELECT substring(indhold from $1 for $2) FROM mediefil WHERE id = $3
And execute it by entering the following command:
EXECUTE pstmt (1, 524288, '{01428c12-6c7c-148b-ca35-9d344dfbf8e8}')
I get a strange error:
2013-11-25 18:47:37 CET ERROR: invalid escape string
2013-11-25 18:47:37 CET HINT: Escape string must be empty or one character.
2013-11-25 18:47:37 CET CONTEXT: SQL function "substring" statement 1
2013-11-25 18:47:37 CET STATEMENT: EXECUTE pstmt (1, 524288, '{01428c12-6c7c-148b-ca35-9d344dfbf8e8}')
Why does this happen? And how can I make the prepared statement work?
Try casting the parameters:
PREPARE pstmt(int, int, uuid) AS
SELECT substring(indhold from $1 for $2) FROM mediefil WHERE id = $3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.