Showing posts with label PostgreSQL. Show all posts
Showing posts with label PostgreSQL. Show all posts

Wednesday, September 29, 2010

SUM(A + B) vs SUM(A) + SUM(B)

In PostgreSQL, a integer plus a null get null, so these two expressions is different not only in result but also in logic:

SELECT SUM(A + B) FROM youtable;
SELECT SUM(A) + SUM(B) FROM youtable;

You can verify this if your A or B has null value.

Wednesday, September 15, 2010

COPY support of PostgreSQL

For details refer to DBD::Pg document and

http://www.postgresql.org/docs/current/static/sql-copy.html


$dbh->do("COPY mytable FROM STDIN");
$dbh->pg_putline("123\tPepperoni\t3\n");
$dbh->pg_putline("314\tMushroom\t8\n");
$dbh->pg_putline("6\tAnchovies\t100\n");
$dbh->pg_endcopy;