Re: Calculation error
От | Tom Lane |
---|---|
Тема | Re: Calculation error |
Дата | |
Msg-id | 29118.1054783045@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Calculation error (chestie <mcit@argus.net.au>) |
Список | pgsql-novice |
chestie <mcit@argus.net.au> writes: > I kept getting this same error, heres what I was trying to do. > it := select int4(extract(epoch from timestamp $1 - > extract(epoch from timestamp $2)); You should just write it := select int4(extract(epoch from $1) - extract(epoch from $2)); You are confusing the syntax timestamp 'string literal' (or more generally, any type name followed by a string literal) with something that you should apply to a non-constant value. That syntax works *only* for literal constants. In your example, $1 and $2 are already of type timestamp and require no further conversion, so the extract()s will work fine as I show above. If you did need a run-time type conversion, you'd have to write "CAST($1 AS timestamp)" (the SQL-spec-approved syntax) or "$1::timestamp" (Postgres' traditional notation). regards, tom lane
В списке pgsql-novice по дате отправления: