createTRIGGER {pgTools}R Documentation

Generate a PostgreSQL CREATE TRIGGER statement, optionally execute the statement if con is not NULL.

Description

Generate a PostgreSQL CREATE TRIGGER statement, optionally execute the statement if con is not NULL.

Usage

createTRIGGER(name, when, event, on, for_each_row = FALSE, func, con = NULL)

Arguments

name

A string, the "name" parameter for PostgreSQL CREATE TRIGGER.

when

A string, the "when" parameter (BEFORE, AFTER, INSTEAD OF) for PostgreSQL CREATE TRIGGER.

event

A string, the "event" parameter (INSERT/UPDATE/DELETE/TRUNCATE) for PostgreSQL CREATE TRIGGER.

on

A string, the "table_name" parameter for PostgreSQL CREATE TRIGGER.

for_each_row

TRUE/FALSE, if TRUE, adds "FOR EACH ROW" to PostgreSQL CREATE TRIGGER statement.

func

A string, the function call to be executed by the PostgreSQL CREATE TRIGGER.

con

A database connection that can be passed to DBI::dbSendQuery/DBI::dbGetQuery.

Value

A string, PostgreSQL CREATE TRIGGER statement; or the results retrieved by DBI::dbSendQuery after executing the statement.

Examples

createTRIGGER(
name = "sample_trigger",
when = "AFTER",
event = "INSERT",
on = "sample_table",
for_each_row = TRUE,
func = "function_sample()"
)

[Package pgTools version 1.0.2 Index]