powered by
Generate a PostgreSQL CREATE FUNCTION statement, optionally execute the statement if con is not NULL.
createFUNCTION( name, args = NULL, or_replace = FALSE, returns = NULL, returns_table = NULL, language = "SQL", definition, con = NULL )
A string, PostgreSQL CREATE PROCEDURE statement; or the results retrieved by DBI::dbSendQuery after executing the statement.
A string, the "name" parameter for PostgreSQL CREATE FUNCTION.
A named list, names are the argument names, values are strings with the argument data types.
TRUE/FALSE, if TRUE, adds "OR REPLACE" to PostgreSQL CREATE FUNCTION statement.
A string, the "returns" parameter for PostgreSQL CREATE FUNCTION.
A named list, names are the return table column names, values are strings with the return table data types.
A string, the "language" parameter for PostgreSQL CREATE FUNCTION.
A string, the "definition" parameter for PostgreSQL CREATE FUNCTION.
A database connection that can be passed to DBI::dbSendQuery/DBI::dbGetQuery.
createFUNCTION( name = "sample_add", args = list(a = "INTEGER", b = "INTEGER"), returns = "INT", language = "plpgsql", definition = "BEGIN RETURN sample_add.a + sample_add.b; END;" )
Run the code above in your browser using DataLab