Pass parameter with Heroku dataclips json url - heroku

Issue-1
select statement - "Select field1,field2 from table1 "
Requirement -This statement return 10 rows but i need only rows which have value 300 on field1. but this value 300 get changed time to time.Therefor i can not put where condition and mention value 300.
Is there a way to pass parameter with Json url and filter only the required row base on the value on parameter?
Regards
Chamika Perera

Related

How do I get N rows in Oracle SQL SELECT statement given number by variable?

In Oracle SQL, I have a variable that is the number of rows to fetch, I can only use SQL SELECT statement, so no PL/SQL block.
If the variable has a value set I must fetch the number of rows in the variable, if not then fetch as many rows as possible (infinite).
I tried:
select * from system_options
THEN FETCH FIRST
CASE :lim
THEN :lim
ELSE 9999
END
ROWS ONLY
This gives me a ORA-00933: SQL command not properly ended.
Another option would be by not having the variable set then not having the THEN FETCH statement.
You have several syntax errors:
You do not need the THEN before the FETCH FIRST; and
The CASE expression is missing a WHEN clause.
I don't have SQL/Plus to hand to test using a bind variable but something like this:
select * from system_options
FETCH FIRST CASE WHEN :lim IS NOT NULL THEN :lim ELSE 9999 END ROWS ONLY
Or, you can use COALESCE:
select * from system_options
FETCH FIRST COALESCE( :lim, 9999 ) ROWS ONLY
db<>fiddle here

influxdb count distinct field

My table is a follow;
names
1.name
1.name
1.name
2.name
2.name
3.name
The result I want to get is as follows;
name count
1.name 3
2.name 2
3.name 1
My request is
select distinct(name) from names where name=! /.*name*/ group by name
or
select count(distinct(name)) from names where name=! /.*name*/ group by name
My response
1.name
2.name
3.name
or
count 3
Thank for help
You will need to select a field in the query and count the field names in the query
Assuming that there is a field called field is available in the measurement,
select count(field1) from names where group by name should work.
I'm not sure why name=! /.*name*/ where clause is added to the query.

Using Nifi ExecuteSQLRecord with parameterized SQL statements?

Can someone explain or show how Nifi's ExecuteSQLRecord would work with parameters? The documentation says:
If it is triggered by an incoming FlowFile, then attributes of that FlowFile will be available when evaluating the select query, and the query may use the ? to escape parameters. In this case, the parameters to use must exist as FlowFile attributes with the naming convention sql.args.N.type and sql.args.N.value,
where N is a positive integer. The sql.args.N.type is expected to be a number indicating the JDBC Type.
I've been able to use the HandleHttpRequest, ExtractText, to make this query work. curl -d "select * from MY_TABLE WHERE NAME = '1234'" http://localhost:5555
I'm unsure how I would update the ExecuteSQLRecord to make it work with parameters to avoid a sql injections.
Would I replace the 'test' with a ? and extract the attributes with another processor? I wish there was an example.
The query should be select * from MY_TABLE where NAME = '?', and then incoming flowfiles will need to have the following attributes (from your example):
sql.args.1.type: varchar
sql.args.1.value: 1234
For multiple parameters, it would follow this general pattern:
Query: select * from MY_TABLE where NAME = '?' and OTHER_COL = '?' ...
Flowfile attributes:
sql.args.1.type: varchar
sql.args.1.value: First Last
sql.args.2.type: integer
sql.args.2.value: 1234
...

How can I determine the records with the top N values of a column?

I have a table with a numeric column called "Count" and I want to determine the records with the top 10 values in that column. I tried using List.MaxN([Count],10) but it throws an error:
Expression.Error: We cannot convert the value 0 to type list.
Details:
Value = 0
Type = Type
I also tried Table.MaxN(_,[Count],10) and got an error.
What am I doing wrong and how can I get the top 10 values of the column?
You need to include the table name, like
= List.MaxN(MyTable[Count],10)

get result from select statement put into header

I have problem:
- I have select statement
Select name from org where id = 123
I can get value from statement that puting into header
ex: result is "aread" then header column is "aread"
Thanks!
Possible duplicate:
Oracle - dynamic column name in select statement

Resources