Skip site navigation (1) Skip section navigation (2)

Meaning of "$$"

From: David Saracini <dsaracini(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Meaning of "$$"
Date: 2009-03-27 18:51:07
Message-ID: 358518.3746.qm@web82901.mail.mud.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hello All,

I can't seem to find any documentation on what the "$$" at the beginning and end of a function.  Obviously, it seems like a delimiter, but I have seen examples such as where it has a string value between the $.  Why? What does this do?  I've done some searching and reading and can't quit figure it out.  

thanks,

Please see the following for the 8.3 online documentation:

CREATE FUNCTION emp_stamp() RETURNS trigger AS $emp_stamp$ <----note!
    BEGIN
        -- Check that empname and salary are given
        IF NEW.empname IS NULL THEN
            RAISE EXCEPTION 'empname cannot be null';
        END IF;
        IF NEW.salary IS NULL THEN
            RAISE EXCEPTION '% cannot have null salary', NEW.empname;
        END IF;

        -- Who works for us when she must pay for it?
        IF NEW.salary < 0 THEN
            RAISE EXCEPTION '% cannot have a negative salary', NEW.empname;
        END IF;

        -- Remember who changed the payroll when
        NEW.last_date := current_timestamp;
        NEW.last_user := current_user;
        RETURN NEW;
    END;
$emp_stamp$ LANGUAGE plpgsql;

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2009-03-27 19:15:07
Subject: Re: Meaning of "$$"
Previous:From: David SaraciniDate: 2009-03-27 18:21:10
Subject: Re: prevent an update from occurring under certain conditions

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group