How can I use an OVER statement in spotfire when connected to an external database? - oracle

Usually, I have been using the following calculated column when importing the data from an excel file:
(Sum([Units]) - Sum([Units]) OVER (PreviousPeriod([Axis.Columns]))) / Sum([Units]) OVER (PreviousPeriod([Axis.Columns])) * 100 as [% Difference]
In this scenario, however, the data is coming directly from an Oracle database.
When I try to create the calculated column, I get the error message:
"Could not find function: 'PreviousPeriod' "
I have done some research and found that I should be using the THEN keyword, but I have the same problem when I try to insert it after the aggregated expression.

You need to import that date via an INFORMATION LINK or EMBED the data in your analysis in order to use the majority of the functions in SPOTFIRE. If you must keep your data EXTERNAL, that is not connected via in Information Link or Embedded, you will not be able to use all the functions within SPOTFIRE.

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.

Can I use expression builder to return a SQL query result to a variable?

I am using a software, pc/mrp, which appears to have a built-in Visual Fox Pro editor for FRX files. It also has an external usage of an ef file. Based on some usage of Google, the report designer seems standard, not custom. The ef file usage may be a custom thing. Now, I need to find a way to get access to a value from a SQL statement inside the report. The statement needs to run per-line in the report.
EF:
This file has sections:
~in~
~out~
In these sections, I can run code, but if there is a ~perline~ type section, I don't know how to access it. I can use the ~in~ to try to create a relationship between the databases, as shown in the following example:
~IN~
THISAREA = SELECT()
USE PARTMAST ORDER BYPARTNO IN 0
SELECT (THISAREA)
SET RELATION TO PARTNO INTO PARTMAST ADDITIVE
GO TOP
~OUT~
USE IN SELECT("SALES")
But, for this I don't know how to join the databases. I have two databases (A,B) I need to connect them based on two fields (pono,line). If (A.pono and a.line) = (B.pono and B.line) then they would be linked. Is this possible?
Report Designer:
The other way I see this working is to do the query inside the report designer. Inside report properties is a variable tab. I can use this to assign to variables using expressions. I need:
SELECT field from B where B.pono = pono and B.line = line; INTO ARRAY varArray;
But, it gives me an error, likely because this is trying to create a new variable as opposed to actually assigning to the variable in the report. I tried editing a field inside the designer to use the preceeding code as well, but that also failed.
Is there a way using the report designer or the ef file to grab the data I need per line?
The sample code you show is doing something like a join with the SET RELATION command. To use SET RELATION, there has to be an index on the relevant field (expression) in the child table. So, if your table B has an index on PONO + LINE (or, if those are numeric, STR(PONO, length) + STR(LINE, length)), you can SET RELATION TO PONO + LINE INTO B, again, using the more complicated expression if necessary.

How can I add static values in a column in grafana/influxdb

I'm using grafana, influxdb and jmeter. I have this table.
I need to add a column that says "Base Line" with a value different for each request name. I have tried the following:
- Grafana does not seem to have a way to add static values for columns, or a query equivalent of sql for "select 'value' as 'columnName'"
- I tried creating a new time series for static data (base lines) and do a join of the results from jmeter with the series I created, but I get this error:
error parsing query: found AS, expected ;
I'm having a hard time trying to create an extra column with fixed data for each request... my last resort is to modify or create a jmeter plugin for that matter, but before going for that, there might be something I could be missing.
The easiest solution I can think of is adding a Dummy Sampler which will be doing nothing but "sleeping" for specified amount of time which is your "baseline".
JMeter's Backend Listener will collect this sampler metrics and you will either see a straight horizontal line identifying your baseline in the chart or the baseline value in the table or will be able to aggregate as a vertical column.
You can install Dummy Sampler using JMeter Plugins Manager

UFT-API: How to write the output of a select data action to the test's data source

In a uft-api test I have a select data component that returns the query results. The results comeback in an array and I'm trying to figure out how to write the results back to the test's data pane, either excel or local table.
You can use GetDataSource Class of UFT API ,
it will work like this lets say you imported excel from FlightSampleData.xls, and named it as FlightSampleData, you have <input> sheet, accessing the sheet will be like below:
GetDataSource("FlightSampleData!input).Set(ROW,ColumnName,yourValue);
GetDataSource("FlightSampleData!input).Get(ROW,ColumnName);
I recommend you go to help section of UFT , there are many valuable documents that we thought we never had. all the object reference is out there .
this.Dbfetch10.OutputProperties.GetElementsByTagName("EMP_NAME").item(0).InnerText;
Note :-
EMP_NAME - exact field name in database
Dbfetch10- appropriate stepname of the SelectData

magmi - generic sql datasource 1.0.2 usage

Some questions arises when using MAGMI generic SQL datasource. Magmi 0.7.18 displays the following input information when using that plugin:
I tried several times with two approaches.
-the first one as described on the image was a direct query to the mysql database containing all rows to feed magento database using magmi. (no files on genericsql/requests)
-the second one using .sql file exported from my database and placing that file into (genericsql/requests).
in both cases I received the following statement: 1 warning(s) found Hide Details -> "No Records returned by datasource"
I read that some folks suggest to use input DB Initial Statement: SELECT COUNT(*) AS cnt FROM tablename but in my case it was the same.
question one: using mysql I can query mysql databse directy using the input db information (type, host, name, user, password) or I have to place the sql file in genericsql/requests too? is that my error?
question two: based on the fact that mysql cannot attach files - as MS sql can - which information do I have to place when magmi request user- pass for that sql file?
any help appreciated, I´m stuck with this issue and CSV is not suitable for my needs. brgds
by dweeves:
Your SELECT has to be put in a .sql file in the directory listed in red. (name it as you want as long as it ends with .sql extension)
The "Initial Statements" is a field that is meant to hold the "connection" time statements (like SET NAMES 'UTF8').
For the "quick count" , you might also add a .sql.count file in the same dir with the same name that the request you want to achieve.
By default magmi will find the count using a
SELECT COUNT(*) FROM (your request here)
see Generic SQL Datasource plugin documentation.

Resources