Skip to content

Instantly share code, notes, and snippets.

@tfoldi
Created April 12, 2013 07:44
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 tfoldi/5370272 to your computer and use it in GitHub Desktop.
Save tfoldi/5370272 to your computer and use it in GitHub Desktop.
CREATE TABLE emp (
name text,
age integer,
salary numeric(10,2)
);
CREATE OR REPLACE FUNCTION get_emps(float8) RETURNS SETOF emp AS '
names <- c("Joe","Jim","Jon")
ages <- c(41,25,35)
salaries <- c(250000,120000,50000)
salaries <- salaries * arg1
df <- data.frame(name = names, age = ages, salary = salaries)
return(df)
' LANGUAGE 'plr';
CREATE OR REPLACE FUNCTION r_max (integer, integer) RETURNS integer AS '
if (arg1 > arg2)
return(arg1)
else
return(arg2)
' LANGUAGE 'plr' STRICT;
COPY emp (name, age, salary) FROM stdin;
Joe 41 250000.00
Jim 25 120000.00
Jon 35 50000.00
\.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment