I work on APEX 5 application and want to have link to modal page in IR. When I put in select select '' || col1 || '' col1, ... get an error ORA-00911: invalid character, but if I change page 2 from Modal to Normal everything is fine. Where do I make mistake?
Implement links to modal page using declarative approach rather than deriving it using query. This can be done by changing the column type to Link and then mention link target and link text, screenshot below:
If this does not work for you and you want to do it through query then use APEX_UTIL.PREPARE_URL function is your query like this,
SELECT
COL1,
COL2,
'' || COL1 || '' LINK
FROM
TABLE1
More Information on PREPARE_URL function can be found here --> link
Related
I am using the query function to generate content in Sheet 1 pulled from sheets 2-6. I've used this function in past, and its worked quite well – but only when I am pulling from 5 sheets. No more, no less. I do not understand this function as it was taken from an old template. I am interested in creating a new function to serve my purpose and learn how to decipher the meaning of the clauses. Please help.
This is the old function:
=query(query({Sheet2!A1:L;Sheet3!A1:L;Sheet4!A1:L;'Sheet5'!A1:L;Sheet6!A1:L},"select Col1, count(Col1), max(Col4) where Col1 <> 'Testing' group by Col1 order by max(Col4) desc",0), "select * where Col2 > 1",0)
What does each clause mean?
How can I alter it for greater/lesser number of sheets?
make sure this part is correct in your new attempt:
{Sheet2!A1:L; Sheet3!A1:L; Sheet4!A1:L; Sheet5!A1:L; Sheet6!A1:L}
all sheets need to be separated with ; and all ranges needs to have the same number of columns
The task is as follows. I have a code that has a huge number of attributes. And to one of the attributes, let's say this is the card type card_type='universal', you need to add the following condition:
case when card>='129897' and card<='293965'then 'unnamed' and card>='093750' and card <='903750' then 'personal' end as parameter
The attribute itself is as follows :select case when card_sybtype in ('VISA','MS') then 'universal'
At the same time, I do not need to output this to the final script, but I need this feature to be present in the script. That is, I need it to be linked only to the card type.
I think you can use a nested case when.
And if you dont want to select parameter column, you can use a subquery to hide the columns. So, in case you want it, just add it to the outside select list.
SELECT col1, col2
FROM
(SELECT
col1, col2,
case when card_sybtype in ('VISA','MS') THEN -- universal case
case when card>='129897' and card <='293965' then 'unnamed'
when card>='093750' and card <='903750' then 'personal' end
else null
end as param_adhoc
FROM tab
) rs
I have an SSRS report that the user wants to be able to search upon multiple sites as supposed to just the one site that the report usually accepts.
If they don't enter a site in the parameter text box then the report searches for all sites.
I've handled this successfully within my SQL query in the where clause as shown below
WHERE
( ( LEN(#ProjectId) > 0 AND p.ProjectId = #ProjectId ) OR ( LEN(#ProjectId) =
0 ) )
This worked fine for searching just the one site or all sites if they didn't enter a value.
They want to be able to enter multiple sites and split them with a comma.
I handled this within my SSRS report as defining the parameter in my data set to be
=JOIN(Parameters!ProjectId.Value, ",")
However this doesn't work for blank values or null values as expected.
I've done some fancy expressions to try and get round this like
=IIF(ISNothing(Parameters!ProjectId.Value), "", JOIN(Parameters!ProjectId.Value))
To set the parameter passed to the SQL query to be blank and not to do the join if there isn't a value encountered.
Basically I want to know if there is a way I can have a multi set parameter split by commas but passed as a blank if a value is not chosen.
at the moment I've tried setting the parameter to allow multivalues which hasn't worked either I get the error message as shown below
First set up your multivalue parameter:
Then within your Dataset define a new parameter, in this instance I have called it #PCount:
#PCount is defined with the expression:
=IIF(Parameters!P1.Count=0 Or
(Parameters!P1.Count = 1 And Parameters!P1.Value(0) = ""),
0,
Parameters!P1.Count)
This will return 0 if no values are entered, or a blank value is entered. Then your query becomes something like:
SELECT Col1, Col2, Col3
FROM YourTable
WHERE ProjectID IN (#P1)
UNION ALL
SELECT Col1, Col2, Col3
FROM YourTable
WHERE #PCount = 0
You could do this with OR, as follows:
SELECT Col1, Col2, Col3
FROM YourTable
WHERE ProjectID IN (#P1)
OR #PCount = 0
But I think this is more likely to encounter performance issues.
In my report query I have a where clause that needs to be replaced dynamically based on the data chosen in the front end.
The query is something like :
where ?=?
I already have a code to replace the value - I created report parameter and linked to the value ? in the query.
Example:
where name=?
Any value of name that comes from front end replaces the ? in the where clause - this works fine.
But now I need to replace the entire clause (where ?=?). Should I create two parameters and link them to both the '?' ?
No, unfortunately most database engines do not allow to use a query parameter for handling a dynamic column name. This is for security considerations.
So you need to keep an arbitrary column name in the query:
where name=?
And then in "beforeOpen" script of the dataset replace 'name' with a report parameter value:
this.queryText=this.queryText.replace("name",params["myparameter"].value);
To prevent SQLIA i recommend to test the value of the parameter in this script. There are many ways to do this but a white list is the strongest test, for example:
var column=params["myparameter"].value;
if (column=="name" || column=="id" || column=="account" || column=="mycolumnname"){
this.queryText=this.queryText.replace("name",column);
}
In addition to Dominique's answer and your comment, then you'll just need a slightly more advanced logic.
For example, you could name your dynamic column-name-value pairs (column1, value1), (column2, value2) and so on. In the static text of the query, make sure to have bind variables for value1, value2 and so on (for example, with Oracle SQL, using the syntax
with params as (
select :value1 as value1,
:value2 as value2 ...
from dual
)
select ...
from params, my_table
where 1=1
and ... static conditions....
Then, in the beforeOpen script, append conditions to the query text in a loop as needed (the loop left as an exercise to the reader, and don't forget checking the column names for security reasons!):
this.queryText += " and " + column_name[i] + "= params.value" + i;
This way you can still use bind variables for the comparison values.
i have a dataset, dataset1:
i am trying to do:
select col1+col2, col3 from mytable
this does not work; however this is no problem:
select col1, col2, col3 from mytable
how can i concatenate fields inside of my dataset?
please note that col1, col2, col3 are all VARCHARS. i've tried the & operator as well.
please see the image below. i get the DEFINE QUERY PARAMETERS dialogue when it doesnt like my query:
Double quotes are not appropriate string delimiters in MS SQL. Try:
SELECT ppl.FirstName + ' ' + ppl.LastName AS ReferredBy
Putting your actual query in the question may help you get a faster response next time, since the concatenation is actually a red herring here.