Re: simple test code
От
Vibhor Kumar
Тема
Re: simple test code
Дата
Msg-id
6369AD15-3FD9-4C72-AB47-D39C19C2D51A@enterprisedb.com
Ответ на
simple test code (java4dev)
Список
Дерево обсуждения
simple test code java4dev <java4dev@gmail.com>
Re: simple test code Tom Lane <tgl@sss.pgh.pa.us>
Re: simple test code Vibhor Kumar <vibhor.kumar@enterprisedb.com>
Re: simple test code java4dev <java4dev@gmail.com>
> > DECLARE > time1 TIMESTAMP (3); > time2 TIMESTAMP(3); > diff INTERVAL; > BEGIN > time1 := now(); > diff := INTERVAL '30' second; > time2 := time1 + diff; > SELECT time1, time2; > END; > > but I get an error that I cannot interpret > > ERROR: syntax error at or near "TIMESTAMP" > LINE 3: time1 TIMESTAMP (3); > ^ > > ********** Error ********** > > ERROR: syntax error at or near "TIMESTAMP" > SQL state: 42601 > Character: 17 > > I also tryed to add a label in the beginning > > <> > DECLARE > time1 TIMESTAMP (3); > time2 TIMESTAMP(3); > diff INTERVAL; > BEGIN > time1 := now(); > diff := INTERVAL '30' second; > time2 := time1 + diff; > SELECT time1, time2; > END; > > but then I get > > ERROR: syntax error at or near "<<" > LINE 1: <> > ^ > > > ********** Error ********** > > ERROR: syntax error at or near "<<" > SQL state: 42601 > Character: 1 > This kind of anonymous blocks are not supported in PostgreSQL. If you are using PG 9.0 then you can try following: do $$ DECLARE time1 TIMESTAMP (3); time2 TIMESTAMP(3); diff INTERVAL; BEGIN time1 := now(); diff := INTERVAL '30' second; time2 := time1 + diff; RAISE NOTICE '% %', time1, time2; END;$$ language plpgsql; Thanks & Regards, Vibhor Kumar
В списке pgsql-novice по дате отправления