I need to make the column values of a table case Insensitive while reading them in a Spotfire Prompt from a Oracle View - oracle

I am loading data into Spotfire report from Oracle using view. In the Spotfire Prompt when the text value is entered, whether it is Upper,lower or mixure of both the relative column values should be displayed. Since this is done at the data base level i need some way to make the column values case insensitive.
I know that column values can be converted to upper/lower case with upper()/lower() function but i need a way so that even a mixure of upper/lower cases will search the column values.
I found one more solution for session :
alter session set NLS_COMP=ANSI;
alter session set NLS_SORT=BINARY_CI;
After using the above code any SQL search for column will be case insensitive. but i need a solution where i can use it in the view of the column element.

Does the inputted value need to be a prompt? It would be possible to do this using a parameter (which could be set by a document property/ input field/ configuration block).
Within the SQL for your query, you could add a where clause something like
upper(A1."mycolumn")=upper(?myParameter)
After refreshing the parameters section of the information link ‘myParameter’ will appear. The information link can then be added as an on demand table, with myParameter being set via a document property.

Related

Adf column filter: which format does ADF use to generate the where clause in the VO's query?

TLDR; is there a way to understand at runtime which format is ADF using for dates behind the scenes? In particular the format used to render dates in dynamically generated sql code?
In the Oracle ADF Application I'm working on there are several table filters (by that I mean the field over the column in which I can write text/number/dates to query the table).
Filtering this way, the framework modifies the query of the View Object, adding the appropriate where clause. On the page there's also a button "Select all" that allows me to select all the data that's rendered in the table (there is a selection checkbox).
In the specific case, the query from the VO is used to aim two different goals:
update the rendered data in the table
if I press the "select all" button a function in the backend database is called (callable statement calling the function), passing as a parameter the query.
The first task is successfully reached (as the table is visually updated), but we had an issue with the second one.
The backend function uses the query to select all the extracted data (as iterating in ADF with java would be too slow).
The problem is that the where clause isn't correctly generated for the backend database (which is also oracle).
Basically the generated WHERE clause (which was added to VO's query automatically by the framework) was
WHERE record_date = '2020-10-12'
which I had to change to
WHERE record_date = to_date('2020-10-12', 'YYYY-MM-DD')
in order to have it correctly executed by the Oracle Db.
So now it's working (yay), but my concern is: isn't it dangerous to assume the date format will be 'YYYY-MM-DD' on every application's instance?
I think this 'YYYY-MM-DD' is the format in which ADF is managing dates (as the value is written as '2020-10-12' in the query).
But is there a way to understand at runtime which format is ADF using for dates behind the scenes? Or does it always use 'YYYY-MM-DD', or am I completely off-road and the storage format is another and I should ask which format does it use to render dates? But dates on page are visually rendered in another way :/
Sorry for my lack of expertise and have a nice day!
Update
The value of the query field, which I'm getting by calling
this.getNamedWhereClauseParams().getAttribute('vc_temp_1');
is of class
oracle.jbo.domain.Date
and by printing it I obtain the date in format YYYY-MM-DD.
Would it be possible that the framework was simply using Date.toString?
This would raise another question: how can I be sure of the pattern used by Date.toString? The documentation isn't clear about it (and it says that it should be used only in development, so this is quite a remote scenario).
What you named 'Filter' is called 'Query by Example' or QBE in short. See the doc for more info.
You can change the query passed to the server using a bean method. Look at e.g. JDev 12.2.1.3: Multi select component table filter for a sample.
Using dates in ADF is always dependent on the current user's settings. If the user don'T use a specific locale the default is 'yyyy-mm-dd'. This can be changed at different points, starting by the entity objects, view objects a,d finally in the UI by using converters.
The best way to use dates depends on the use case.

How to make a LOV in Oracle ADF that also returns a static value?

Say I want to have a lov of colors. Red , Blue Green. I want an LOV that retrieves those values from a database but on top of that I want to add one more value "All". So the LOV could be a list of someone's potential favorite color and by default the "All" option is displayed in the LOV. A user can choose any color or maybe decide to revert to the 'ALL" option.
Is it possible to add this static value to an LOV that retrieves values via a db? I know you can just create a static LOV but the point is we need to retrieve the latest colors or whatever value is in the db if it ever grows.
Edit: JDeveloper 12c (12.1.3.0.0)
If the 'all' option is valid, you should add it into the DB, like the other colors. If you don't want to put 'all' into the DB, you can use SQL and create the 'all' option as a static result before the actual query to the table using a union SQL statement.
One other way to archive this is to add the 'all' option to the items list in a bean, like it's shown here https://community.oracle.com/tech/developers/discussion/616712/adf-faces-how-to-add-static-option-to-dynamic-lov
You still have to think about what should happen if the user selects 'all' from the list. How does the UI handle this?
I think you should insert "All" value to table in database. The table should contain "ORDER_COLOR" column. We will prepare data some thing like:
("All", 999999)
("RED",1)
("BLUE, 2)
("GREEN",3)
("NEWEST_COLOR",4)
In ViewObject query. You can order by ORDER_COLUMN desc. The ALL will on the top and next one is NEWEST_COLOR

Question on changing the APEX data load wizard to give default target columns

Within the data load wizard that comes with APEX 18.1, after you choose your csv file to be uploaded you are offered a "TARGET COLUMN" drop down LOV which defaults to "DO NOT LOAD". It is possible to tell APEX which values you want in this LOV. I have done this.
My issue is, that this is quite laborious. Your users will not necessarily know which value you want them to pick from the LOV to map the related column when they are using a csv file with no header. As they are going to be doing.
Does anyone know how to change the "DO NOT LOAD" value in the LOV to another value? If I could get it to default to a column of my choosing, this would be great. Alternatively, there's a "SOURCE COLUMN" field in the wizard.
Getting the "SOURCE COLUMN" field to denote which column I wish users to map to the LOV value would be something also. Has anyone faced this before? Does anyone know if it is possible to do what I am suggesting as a work around? Thanks for looking and for your thoughts.
APEX does the column mapping automatically by checking the name of the column in the csv(the first row is names usually).
So if the names of the columns match in the table and the csv, it will connect them by itself. What you can also do is set column aliases.
If you want to edit the existing data load, you can go to Shared Components- Data Load definitions and pick the one you are using in there.
Then you can set column aliases there. But afaik you can only do one alias per column there.

Using variables in From part of a task flow source

Is there any way to use a variable in the from part (for example SELECT myColumn1 FROM ?) in a task flow - source without having to give the variable a valid default value first?
To be more exact in my situation it is so that I'm getting the tablenames out of a table and then use a control workflow to foreach over the list of tablenames and then call a workflow from within that then gets data from these tables each. In this workflow I have the before mentioned SELECT statement.
To get it to work properly I had to set the variable to a valid default value (on package level) as else I could not create the workflow itself (as the datasource couldn't be created as the select was invalid without the default value).
So my question here is: Is there any workaround possible in this case where I don't need a valid default value for the variable?
The datatables:
The different tables which are selected in the dataflow have the exact same tables in terms of columns (thus which columns, naming of columns and datatypes of columns). Only the data inside of them is different (thus its data for customer A, customer B,....).
You're in luck as this is a trivial thing to implement with SSIS.
The base problem for most people is that they come at SSIS like it's still DTS where you could do whatever you want inside a data flow. They threw out the extreme flexibility with DTS in favor of raw processing performance.
You cannot parameterize the table in a SQL statement. It's simply not allowed.
Instead, the approach that people take is to use Expressions. In your case, assuming you had two Variables of type String created, #[User::QualifiedTableName] and #[User::QuerySource]
Assume that [dbo].[spt_values] is assigned to QualifiedTableName. As you loop through the table names, you will assign the value into this variable.
The "trick" is to apply an expression to the #[User::QuerySource]. Make the expression
"SELECT T.* FROM " + #[User::QualifiedTableName] + " AS T;"
This allows you to change out your table name whenever the value of the other variable changes.
In your data flow, you will change your OLE DB Source to be driven by a query contained in a variable instead of the traditional table selection.
If you want an example of where I use QuerySource to drive a data flow, there's an example on mixing an integer and string in an ssis derived column
Create a second variable. Set its Expression to create the full
Select statement, using the value of the first variable.
In the Data Source, use "SQL command from variable" option for the
Data Access Mode property.
If you can, set a default value for the variable you created in step
That will make filling out the columns from your data source much easier.
If you can't use a default value for the variable, set the Data
Source's ValidateExternalMetadata property to False.
You may have to open the data source with the Advanced Editor and
create Output columns manually.

Generate reports in birt using user input. When input is null, everything should be fetched otherwise corresponding data should be shown

I have to create a birt report with user input parameters. It is something like when the para
meter is left blank it should fetch all values from a table otherwise when the user inputs the students roll no.,the corresponding data should be fetched. Can this be done through Birt report? If yes, then please suggest a way.
Thanks!
Yes, you can do that. If the parameter is optional you can't use the Dataset Parameter (with a ? in your query), because it will be null. Instead you have to modify your query using JavaScript.
Create a Report Parameter like usual, in this case 'stud_no'. Then add a comment in your SQL that you are reasonably sure is unique, I use something like --$stud_no$, wherever you want your clause inserted.
Then add a script like this to your Data Set, in beforeOpen:
if (params["stud_no"].value){
this.queryText = this.queryText.replace("--$stud_no$", "and stud_no = " + params["stud_no"]);
}
This replaces the comment with the clause when the parameter has a value. You can use regex in the search string, and then you can also insert it multiple places if you want.
Create your paremater using a like statement
where students_roll_no like ?
Create your report paramater using as a text box, with a defualt value of %
Because the percent '%' is the SQL wildcard, it returns all values. If the user enters a Student Roll number, it returns only that record. Additionally the user can enter 0500% and get all the records that begin 0500.

Resources