当我输入以下准备好的陈述时:
PREPARE pstmt AS SELECT substring(indhold from $1 for $2) FROM mediefil WHERE id = $3
输入以下命令执行:
EXECUTE pstmt (1, 524288, '{01428c12-6c7c-148b-ca35-9d344dfbf8e8}')
我收到一个奇怪的错误:
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}')
为什么会这样?我怎样才能使准备好的声明有效?
答案 0 :(得分:0)
尝试投射参数:
PREPARE pstmt(int, int, uuid) AS
SELECT substring(indhold from $1 for $2) FROM mediefil WHERE id = $3