Tina, What database are you using? Do you have the ability to call CREATE TABLE IF NOT EXISTS? If so, you could add those to your other sql statements and send them either to PutSQL individually (but you'll probably want a Prioritizer on the connection between ExecuteScript -> PutSQL or an EnforceOrder processor to make sure they arrive in the correct order), or lump them all together in one file (with the table create stuff at the top) and send it to PutDatabaseRecord instead of PutSQL. One way to do the latter (albeit a bit of a hack) is to create a CSV reader that ignores the header and uses a schema of a single String field called "sql", and a delimiter that will not show up in the input. Then you can set the "statement.type" attribute for the flow file to "sql", the "Statement Type" property to "Use statement.type attribute" in PutDatabaseRecord, and the "Field Containing SQL" property to "sql".
Regards, Matt On Mon, Dec 11, 2017 at 4:13 PM, tzhu <[email protected]> wrote: > Hi, > > I want to create a process to check if a table exist in the database, and if > the table does not exist, the table will be created. Then some values from > flowfile will be inserted into the table. > > I know I can get the available database names from ListDatabaseTables. Also, > I can use notify and wait to release the "insert" action when the check is > done. But I don't know how to complete the process. How should I check if > the table exists? And I use ExecuteScript to create a text file and putSQL > to create the table. Is there a better way to do this? > > Any suggestion is appreciated. > > Thanks, > Tina > > > > -- > Sent from: http://apache-nifi-users-list.2361937.n4.nabble.com/
