Re: simple test code
| От | Tom Lane |
|---|---|
| Тема | Re: simple test code |
| Дата | |
| Msg-id | 3247.1298396557@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | simple test code (java4dev <java4dev@gmail.com>) |
| Список | pgsql-novice |
java4dev <java4dev@gmail.com> writes:
> I have opened a SQL console from the pgAdmin tool and tried to run the
> following
> DECLARE
> time1 TIMESTAMP (3);
> time2 TIMESTAMP(3);
> diff INTERVAL;
> BEGIN
> time1 := now();
> diff := INTERVAL '30' second;
> time2 := time1 + diff;
> SELECT time1, time2;
> END;
> I guess I am doing something wrong but what?
It looks like you're trying to run pl/pgsql code directly as SQL.
Postgres draws a distinction between those things, much more sharply
than Oracle does. You need to create a function to run pl/pgsql
code in. See the examples in the pl/pgsql part of the manual.
(If you're using PG 9.0, you only need a DO block, so the notational
overhead for a throwaway piece of code is a lot less ... but it's
still a distinct environment.)
regards, tom lane
В списке pgsql-novice по дате отправления: