Entries for archive: 2010

Found 3 entries.

Vi

Some vi things I keep forgetting:

Syntax

:syntax on
:set syntax=mason
:colorscheme elflord

Moving Around

(Ends)

Labels: vi

Inserted: 2010-02-01 21:32 (2 years ago)

PostgreSQL Aggregates

first() and last()

From: http://archives.postgresql.org/pgsql-hackers/2006-03/msg01324.php

-- Create a function that always returns the first non-NULL item
CREATE OR REPLACE FUNCTION public.first_agg ( anyelement, anyelement )
RETURNS anyelement AS $$
        SELECT CASE WHEN $1 IS NULL THEN $2 ELSE $1 END;
$$ LANGUAGE SQL STABLE;
--
-- And then wrap an aggreagate around it
CREATE AGGREGATE public.first (
        sfunc    = public.first_agg,
        basetype = anyelement,
        stype    = anyelement
);
--
-- Create a function that always returns the last non-NULL item
CREATE OR REPLACE FUNCTION public.last_agg ( anyelement, anyelement )
RETURNS anyelement AS $$
        SELECT $2;
$$ LANGUAGE SQL STABLE;
--
-- And then wrap an aggreagate around it
CREATE AGGREGATE public.last (
        sfunc    = public.last_agg,
        basetype = anyelement,
        stype    = anyelement
);

(Ends)

Labels: postgresql

Inserted: 2010-01-29 03:36 (2 years ago)

PostgeSQL

Some useful PostgreSQL things I have come across:

(Ends)

Labels: postgresql

Inserted: 2010-01-29 03:33 (2 years ago)