I'm trying to use the trigger_start_time variable in the query as the 2nd parameter to a function of lookup activity.
How can I do this ? Can anyone please help me out ?
Please try #concat('select schema.fn_up_watermark(',Parameter_name,',',variable_name, ') from dual') in add dynamic content.
I just make this example with the query you provide me. You could test that not use the parameter and variable to check where missing the right parentheses.
Now, I'm glad to hear the issue is resolved now.
You can do away with the variable and simply write:
select schema.fn_up_watermark('#{item().table_name}','#{pipeline().TriggerTime}') from dual
assuming both parameters are string.
You could still do SQL injection if you can affect the outer lookup that feeds this ForEach block - you could sanitise the table_names on entering this loop possibly.
Related
Is it possible to pass table as input parameter in Monetdb function/procedure?
I tried prepare statement but was not able to get it working.
Also it would be nice to get statementid returned directly by 'prepare' statement rather then query sys.prepared_statements
No, you cannot pass (table) identifiers to functions/procedures.
You could use this trick, but I wouldn't recommend it for production use.
So I am trying to add top posts functionality for my Sinatra project using postgresql with the following statement Like.group(:exercise_id).order('COUNT(exercise_id) DESC').each do |like|
But when I try this I get an error saying column "likes.id" must appear in the GROUP BY clause or be used in an aggregate function
And when I add this
Like.group(:exercise_id, :id).order('COUNT(exercise_id) DESC')
It gives me the whole table when all I want is to group by likes. Is there a workaround for this?
What the error is telling you, is that you're selecting for "likes.id", but there is no single likes.id that the database can give you.
This is because by default when you don't tell Rails what you need, Rails will select EVERYTHING.
Think, do you actually need "likes.id"? Looks to me that you're grouping by exercise_id so what you're trying to get is exercises and their like counts. (correct me if I'm wrong.) You don't actually need specific like id-s.
If that's so, we need to tell rails about our intention.
Like.group(:exercise_id).order('COUNT(exercise_id) DESC').select(:exercise_id)
If you also need the count itself, just add it to the select.
Something else you might want to try is just .count. It's pretty smart and will respect your grouping. See if this helps.
Like.group(:exercise_id).count
Is that possible to get multiple parameter values based on another parameter value. For example if I select facility id ,then it should populate below region and FQA parameters.
I think you want to use cascading parameters. Check out this URL to see if it is close to what you are aiming for... https://www.eclipse.org/forums/index.php/t/503715/
What you need is a cascading parameter group. Here is an example video on how to use it.
I have a (semi) basic data cube set up with a cascading parameters of State and Area. The state select box is straight forward as is the Area; when a user selects a State, the Area options are set accordingly. However, the value for Area is a long list of strings that will be sent to the mysql select statement which will use both params (State & the list of strings from Area) several time. Its a big ugly collection of UNIONS. My problem is somewhere between the before Start and query time.
//beforeOpen script...LState & LAreas the name of the report param
this.queryText = this.queryText.replace('stateList', params["LStates"].value);
this.queryText = this.queryText.replace('areaList', params["LAreas"].value);
In my mysql statement I use them in the following way:
SELECT ..XXX..
FROM ..XXX..
WHERE ..XXX..
State.State_Location in ('stateList')
AND Range_Locator.Range in ('areaList')
UNION ALL
SELECT ..XXX..
FROM ..XXX..
WHERE ..XXX..
State.State_Location in ('stateList')
AND Range_Locator.Range in ('areaList')
The two errors I get from BIRT are:
(Pretty obvious)
Cannot get the result set. org.eclipse....SQL statement doesn ot return a ResultSet object.
(Not so obvious to me)
A BIRT exception occured. Error evaluating Javascript expression. Script engine error: Can't find method java.lang.String.replace(string.java.lang.Object[]).
There are error evaluating script "this.queryText = this.queryText.replace('stateList', params["LStates"].value);this.queryText = this.queryText.replace('areaList', params["LAreas"].value);"
Any ideas? Any help would be greatly appreciated.
It seems LStates is defined as a "multi-value" parameter, therefore params["LStates"].value returns an array of values: this is why this replace method does not work.
You should try like this:
this.queryText = this.queryText.replace('stateList', params["LStates"].value.join("','"));
I am not exactly sure what you are doing in beforeOpen script, but your SQL is looking for the string values 'stateList' & 'areaList' and is probably not happy about the (). You need to use question marks to call the parameters you define in the 'parameters' you set up in the data set design.
SELECT ..XXX..
FROM ..XXX..
WHERE ..XXX..
State.State_Location in ?
AND Range_Locator.Range in ?
UNION ALL
SELECT ..XXX..
FROM ..XXX..
WHERE ..XXX..
State.State_Location in ?
AND Range_Locator.Range in ?
I don't recall using
in ?
In any queries, I usually try and set it to use
like ?
There are number of issues in sending multiple choice parameters to SQL via BIRT. you might want to look at How do I set a parameter to a list of values in a BIRT report? There are also some security concerns. When I have to filter on multiples, I usually do it in a filter (data set design option) after the SQL has run. Thought this can be a resource problem if your SQL returns lots of values.
Thanks for the replies but since I was unable to get these options to work, I wound up restructuring the database & sql statements to run better. To address some previous suggestions:
#dom the states parameter has only one value and while using "IN ('stateList')" is not efficient (disclaimer, not my code) adding the .join(',') did throw an error specific to that; I tried and mysql/BIRT seemed to be expecting a comma separated list but got a string with a trailing comma.
#James I tried using the question mark (?) instead of the 'stateList' & 'areaList' but I think mysql/BIRT was not able to recognize which value went with which question mark...not too sure though since I was not able to debug well enough and find out exactly why. Could be a form to param mapping issue that I didn't notice. Thanks for the help.
I am looking for a function (or a group of functions) in HSQLDB that does something similar to Oracle's LISTAGG.
I have this as part of a larger select and would like to keep the syntax as similar as possible in HSQLDB:
SELECT LISTAGG(owner_nm, ', ') WITHIN GROUP (ORDER BY owner_nm)
FROM OWNERSHIP WHERE FK_BIZ_ID = BIZ.BIZ_DATA_ID) AS CURRENT_OWNER
The point of this is that we're trying to use HSQLDB for remote work and Oracle for working on site, prod, etc so I want to change the DDLs as little as possible to achieve that.
Looking at ARRAY_AGG, it doesn't seem like it does anything similar (as far as being able to pull from a separate table like we're doing above with OWNERSHIP). Any suggestions for how I may accomplish this?
group_concat is probably what you are looking for:
http://www.hsqldb.org/doc/2.0/guide/dataaccess-chapt.html#dac_aggregate_funcs
Quote from the manual:
GROUP_CONCAT is a specialised function derived from ARRAY_AGG. This function computes the array in the same way as ARRAY_AGG, removes all the NULL elements, then returns a string that is a concatenation of the elements of the array