Created
April 12, 2013 07:44
-
-
Save tfoldi/5370272 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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