Skip to content

Instantly share code, notes, and snippets.

@samv
Created October 23, 2012 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samv/3941248 to your computer and use it in GitHub Desktop.
Save samv/3941248 to your computer and use it in GitHub Desktop.
functions and columns are equivalent
svilain=# create table f (foo int);
CREATE TABLE
svilain=# create or replace function bar(f) returns int language sql as $$ select $1.foo + 10 $$;
CREATE FUNCTION
svilain=# insert into f values (1), (2);
INSERT 0 2
svilain=# select f.foo, f.bar from f;
foo | bar
-----+-----
1 | 11
2 | 12
(2 rows)
svilain=#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment