Eric,

On Jan 6, 2005, at 2:51 PM, Eric Brown wrote:

Great! Well, I had to move to 8.0 anyway to get better support for passing around composite types. So where is the $$ quoting stuff documented? How do I use it?

In the 8.0 beta html documentation you can find at this path html/sql-syntax.html#SQL-SYNTAX-DOLLAR-QUOTING (or just look in the index under "dollar quoting")

I thought there was another section some where, but I'm not seeing it at the moment. Basically, you can replace the function start and end single quote with $$ and then not worry about doubling or escaping single quotes in between. For example:

-- trigger to fold all domain names to lowercase, ensure both columns are not null
create or replace function tg_address_biu() returns trigger as $$
begin
if new.domain_name is null and new.ip is null then
raise exception 'Both the domain_name and ip columns cannot be null.';
end if;
if new.domain_name is not null then
new.domain_name = lower(new.domain_name);
end if;
return new;
end;
$$ language plpgsql;


The previous quoting method still works, so there is no requirement to update everything.

If you are using Mac or Windows, pgEdit supports function syntax coloring with both quoting methods and has support for Emacs key bindings.


Best,

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend

Reply via email to