Kind people,

This patch shows how to change UNIX timestamps into PostgreSQL
timestamps, and clarifies how PERFORM works in PL/PgSQL. :)

Cheers,
D
-- 
David Fetter [EMAIL PROTECTED] http://fetter.org/
phone: +1 510 893 6100    cell: +1 415 235 3778
Index: func.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/func.sgml,v
retrieving revision 1.180
diff -2 -c -r1.180 func.sgml
*** func.sgml   29 Nov 2003 19:51:37 -0000      1.180
--- func.sgml   3 Dec 2003 06:17:20 -0000
***************
*** 5006,5009 ****
--- 5006,5018 ----
  SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
  <lineannotation>Result: </lineannotation><computeroutput>442800</computeroutput>
+ 
+        <para>
+         To convert a UNIX timestamp (number of seconds since
+         1970-01-01 00:00:00-00) into a <type>timestamp</type>, you can
+         write:
+        </para>
+ 
+ SELECT 'epoch'::timestamp + '1070430858 seconds'::interval;
+ <lineannotation>Result: </lineannotation><computeroutput>2003-12-03 
05:54:18</computeroutput>
  </screen>
        </listitem>
Index: plpgsql.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/plpgsql.sgml,v
retrieving revision 1.32
diff -2 -c -r1.32 plpgsql.sgml
*** plpgsql.sgml        30 Nov 2003 05:45:22 -0000      1.32
--- plpgsql.sgml        3 Dec 2003 06:17:22 -0000
***************
*** 1033,1036 ****
--- 1033,1050 ----
  </programlisting>
      </para>
+ 
+     <para>
+      Another example, which returns true if user foo is in group bar:
+ <programlisting>
+ PERFORM *
+ FROM 
+   pg_catalog.pg_user u
+ , pg_catalog.pg_group g
+ WHERE u.usesysid = ANY(g.grolist)
+ AND u.usename='foo'
+ AND g.groname='bar';
+ </programlisting>
+     </para>
+ 
     </sect2>
     
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to