PostgreSQL Insert
Use this activity to execute an SQL Insert to insert the records into the database and return the information based on the returning clause specified in the insert query.
Input Settings
The Input Settings tab has the following fields:
Field | Description |
---|---|
Insert | An SQL statement used to insert a record in the table. You can construct prepared SQL queries by using substitution variables (or parameters) of the form
?<fieldname> in the query statement.
Each substitution variable identifies an input parameter whose mapped value is substituted into the substitution variable at run time. If the query contains parameters then only parameter metadata is populated. End the query with semicolon (;) to fetch the metadata in the table at the bottom of the query. When substitution variables used in the VALUES clause are identical to the column names in the table, those variables are displayed under the Values array and otherwise displayed under Parameters on the Input tab. Use Values to insert multiple records at once and use Parameters to insert only one record at a time. Map JSON data from previous activity for insert when you use:
For more details about Data Mappings, see "Mapping JSON Data with the json.path() Function" section in TIBCO Flogo Enterprise User's Guide. The following examples represent insert queries: INSERT INTO products (product_no, name, price) VALUES (1, 'Cheese', ?price), (2, 'Juice', ?price), (3, 'Milk', ?price ) returning (select name from instructor where name = ?name);For the above insert query, output field is generated for name and input field is generated for price (NUMERIC) under Values[] node as its part of values clause, and name(VARCHAR) under parameters node as it is part of the parameter select sub-query . Also, the mapped value for the field price and name is substituted into the substitution variable ?price and ?name. INSERT INTO products (product_no, name, price) VALUES (?product_no, ?name, ?price) returning price;For the above insert query, output field is generated for price and input fields are generated for product_no (INTEGER), name(TEXT), and price(NUMERIC). Also, the mapped value for the field product_no, name, price is substituted into the substitution variables ?product_no, ?name, ?price. The parameters node on the Input tab will not have mappings as there is no parameter in the insert query statement. |
Manually Configure Metadata | Set the Manually Configure Metadata field to True to fetch table metadata manually. For more information, see Manually Configure Metadata. |
Fields | The grid is provided for informational purposes only. |
Input
This tab displays the input schema of the activity as a tree structure. The information in the schema varies based on the insert query provided. The fields that are selected on the Input Settings tab are available in the schema. You can either hard code the values or map them to a field from the output of a preceding activity in the flow using the Mapper.
Fields from RETURNING clause are displayed under Parameters node and fields from VALUES clause are displayed under VALUES node in input schema.
Output
This tab displays the output schema of the activity as a tree structure. The output is read-only. The information in the schema varies based on the fields selected on the Input Settings tab. The properties that are displayed in the schema correspond to the output of this activity and can be used as input by subsequent activities in the flow.