Maximo: Save a dynamic query? - select

In Maximo 7.6.1.1, I can run a query on work orders with this WHERE clause: reportedby = :user:
When I hit Find the query runs successfully; it filters the records using the currently logged in user.
However, when I go back and look at the WHERE clause, I see that the dynamic variable (:user) has been replaced with a static value (JSMITH).
And when I look at the query table in Toad, I see that the clause has been saved as reportedby = 'JSMITH'.
This is not what I want.
How can I save a query with a dynamic variable?
(Oracle 12c)

You can use the View/Manage Queries dialog to change it back. When you first run it Maximo replaces the bind variables.

Related

Call item() from within query of a lookup on a dataset within a for each loop

I'm creating a pipeline in Azure Data Factory and I'm trying to use a lookup activity to query an Azure SQL dataset as so:
The lookup activity is inside a for each loop. My hope is to get a value from the source dataset being queried in the lookup for every item in the for each loop. However, when I preview the data to test this, it does not work and I get this message:
Does anyone have any ideas as to how to call a for each loop item in a query on a dataset in a lookup in ADF?
Thanks,
Carolina
EDIT:
I've changed tact and tried to use a stored procedure but I'm still having the exact same issue. It seems like I can't call the for loop item with a query of stored procedure. Does anyone know a way around this or how to call the item properly?
Data preview in ADF is used for checking the inserting data is correct or not. So, when we use preview which involves dynamic expressions, it does not take those expressions from the pipeline run and it asks us to manually enter the value for it.
So, that's why in the above it is asking a sample item() expression value to give the data preview in the lookup.
When I gave my item() value in that I got correct preview as below:
Preview of lookup that I got for that particular item():
Your approach is fine and when you debug the pipeline with required query in lookup, you can get the desired result.
please go through my sample demonstration:
Array variable for ForEach:
look up inside ForEach with query:
Result after debug pipeline:
You can see that I got the same result in the first iteration of ForEach, which is in look up preview above.
So, for preview, we have to give a sample value to check our result.

Query script not run in suggest box

In AppMaker, one my datasources has a simple query script associated with, because I need a filter everytime the datasource is requested. I'm talking about a normal SQL based datasource (not calculated).
Is it normal than this query script is not used when the datasource is used in a Suggest box ? Because it breaks my app (the user is able via the suggest box to select items he's not even supposed to see).
Thanks for your help
The options for a suggest field text box can either be provided explicitly, by binding to the options property, or by specifying a database query on a model using a startsWith filter on a field. You can set the model and field for the latter option below.
So you can try to create calculated model with server script starts with
var name = query.filters.name.startsWith;
name is field of model

Using LIKE with parameter expression in query

I was trying to using the like function in iReport 4.0.1. Checked online but none seem to work.
Currently trying to use:
where name LIKE'%$P!{px_name}%'
also tried
'%$P{px_name}%'
but when running the report it comes up saying 'No document'.
But when using where name =$P{px_name} it works perfectly fine.
Where clause will be same as you have used in first step which is :-
where name LIKE '%$P!{px_name}%'
But as you said report says 'The document has no pages' means the query is returning 0 row so just use the same string in LIKE and run the same query in database. Simplest solution is first run the query in database with LIKE operator , if it returns the rows in database then that should also work in iReport.

Linq To Entities - How to create a query where the table name is a parameter

Dynamic queries are not dynamic enough. I have seen solutions like this but still I have to indicate which table to use as the basis:
var query = db.Customers.Where("...").OrderBy("...").Select("...");
I want to create a simple query tool where the user will select from available tables using a drop-down list. As the result, I want to show first few records. Therefore, I need to change the table too! That is, I need something like this:
string selectedTable = "Customers";
var [tableName] = SomeTypecastingOperations(selectedTable);
var query = db.[tableName].Where("...").OrderBy("...").Select("...");
Is EF dynamic enough to handle this?
Linq-to-entities doesn't support that. You can achieve that with Entity SQL or some ugly code which will have conditional logic for every set you want to query (like a big switch for table names).

Selection Formula Pass-through not working with SQL Command Object

I'm using Crystal Reports XI. We use Crystal Reports embedded into a share point site written in C#/ASP.net. Our web developers instatiate a report in code and pass the selection criteria by appending to the Select Formula object.
The problem I'm running in to is that when I use a SQL Command Object, the selection formula is not being passed to the sql server as a where clause. This causes the entire result set to be queried and then limited on the server. For very large tables, this is causing a significant performance hit.
Here's an example:
SELECT foo.id, foo.code, foo.name
FROM foo foo
Select criteria is shown as:
{Command.name} like "someName"
If I then run the report the entire foo table is queried and then crystal reports limits from the entire set.
If instead I do it based on the table without a command object, the WHERE clause is appended to the sql query and all the limiting is done at the db level.
I'm assuming this occurs because a SQL command could potentially be very complex and adding a WHERE clause to the bottom isn't always possible. My question then, is there any good way to force some sort of pass through. Should I be talking to the C# devs and asking them to rework the way we pass parameters?
Thanks for any help and discussions.
A record-selection formula is never added to the Command-object's query.
I'm not certain if the CR SDK supports Command object modification (I know it supports read-only access, however).
The Command object does support parameters (in 2008, they can be multi-valued parameters) which can be accessed programmatically (they are converted to Parameter Fields in the report).
I'm assuming that you are using a Command object because of the query's complexity. If you can push the complexity to a SQL view, then use the 'visual linking' expert to create your query, you'll have more flexibility.