简体   繁体   中英

Call a SQL function in Nifi using ExecuteSQL or another processor

I am currently using a function in SQL Server to get the max-value of a certain column. I Need this value to generate a specific number of dummy files to insert flowfiles that are created later on. Is there a way of calling this function via a nifi-processor?

By using ExecuteSQL I Always get error like unable to execute SQL select query or the column "ab" was not found, when using select ab.functionname() (ab is the loginname of the db)

In SQL Server I can just use select ab.functionname() and get the desired results.

If there is no possible way of calling this function, is there another way to create #flowfiles dummyfiles to reserve this place for them in the DB so that no one else could insert or use this ids (not autoincremt, because it is not possible) while the flowfiles are getting processed?

I tried using $flowfile.count and the Counterprocessor, but this did not solve the Problem. It should look like: INSERT INTO table (id,nr) values (max(id)+1,anynumber) for every flowfiles, unfortunately the ExecuteSQL is not able to do this.

Think this conversation can help you: https://community.hortonworks.com/questions/26170/does-executesql-processor-allow-to-execute-stored.html

Gist:

  • You can use ExecuteScript or ExecuteProcess to call appropriate script. For example for ExecuteProcess just call sqlplus command. Choose type of command "sqlplus". In command arguments set something like: user_id/password@dbname @"script_path/someScript.sql". In someScript.sql you put something like:

execute spname(param)

  • You can write your own processor :) Of course it's more difficulty and often unnecessary

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM