From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Alexander Farber <alexander(dot)farber(at)gmail(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Passing varchar parameter to INTERVAL |
Date: | 2016-09-07 13:52:28 |
Message-ID: | 1444.1473256348@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Alexander Farber <alexander(dot)farber(at)gmail(dot)com> writes:
> unfortunately, I can not call INTERVAL 'in_until', that wouldn't work.
No, because the syntax TYPENAME 'LITERAL' only works for simple string
literals. What you want here is a run-time cast, either
CAST(in_until AS interval) or in_until::interval.
> I would prefer to call my custom function as
> select words_ban_user(1, '1 day', 'attacking other users');
That is not a reason not to declare the argument as interval.
> and not as
> select words_ban_user(1, CURRENT_TIMESTAMP + '1 day', 'attacking other
> users');
Hm? That would be passing a timestamp not an interval.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Sándor Daku | 2016-09-07 14:22:23 | Re: Passing varchar parameter to INTERVAL |
Previous Message | Adrian Klaver | 2016-09-07 13:51:51 | Re: Passing varchar parameter to INTERVAL |