Unable to call Talend Open Studio tContextLoad in query - etl

I'm trying to a variable I created from the tContextLoad_1 to perform a query. I've successfully loaded the data into the context using tContextLoad_1. For the key I used date and for the value I used the max date returned from the query.
However when I try and use the context in the query I get an error message that date cannot be resolved (see error below). I'm calling the context value as context.date, not sure if this is how context should be used in the query. Any points will help.
Thanks.
WorkFlow
Context Query
Error Message

Make sure that your context variable "date" is declared in your "context" view for this job (careful, it is case sensitive). This error usually means that the variable is not declared in the job.

Related

User-Defined Function Nested in Macro - Framework Manager

We are trying to create a dynamic query subject filter. To do this, we are trying to nest an Oracle user-defined function inside of a macro.
Example query subject filter:
#strip(ORACLE_USER_DEFINED_FUNCTION())#
We have imported the oracle function ORACLE_USER_DEFINED_FUNCTION into Framework Manager. The function returns a VARCHAR2 of the desired expression. For testing purposes, this function is simply returning VARCHAR2 value of '1=1' (the single quotes are not part of the VARCHAR2 return value).
The idea being that we want the query subject filter expression to be dynamically generated at run-time so the resulting query contains '...WHERE 1=1'. The strip macro is the mechanism to pre-process and invoke the user-defined function before the query is sent to the database.
However, when attempting to verify/check the query subject filter we receive the following error.
XQE-GEN-0018 Query Service internal error has occurred, please see the log for details.
I'm trying to get a hold of the query service log, but don't yet have it.
Perhaps there is some casting needed to convert the oracle VARCHAR2 output from the function to an IBM/Cognos string that is acceptable input for the IBM/Cognos macro.
Your assistance is appreciated. Thanks in advance.
Using Oracle 12c and Cognos 11.1.
With the exception of the queryValue macro function, macros are evaluated prior to accessing the database. This means the macro does not know what the Oracle UDF is or what its supposed to do. If you are able to call the UDF via a FM query subject you maybe able to get away with something similar to the queryValue answer found here:
Cognos 11.1.7 Framework manager change the table for the query subject, type data

How do I set an SSRS Parameter that doesn't have a value to something else?

I have an SSRs Report with a parameter that gets information from SQL. If it hasn't found anything, at the moment it is just empty. Is there anyway to set it such that if it's empty it will return a different value, say "Please Extend Date Ranges" and disable the parameter?
If you using it to fill it using the SQL and using it for only internal purposes then there is option to make the parameter internal and it will be hidden and it will does not prompt the user.
Make a change to the stored procedure or query that populates the parameter. Include some logic so that if no results are returned by the query you are using now, it adds a row with the default label you want.
But no, you can't disable the parameter dynamically, I don't believe.

SSIS For Loop Container equivalent in Talend Open Studio

I have a talend mapping which needs to be executed based on a ID. I want to pass the ID as a parameter. The mapping should execute for one ID at an time. I want to loop the execution for each ID one after the other. This can be achieved in SSIS using the For Loop Container. Can anyone help me finding out the equivalent for the same in Talend Open Studio.
Thanks in advance.
If you take just the Id part of your input and then link that to the main part of your current job with an Iterate link via a tFlowToIterate component it should automatically do this. You can access the value from the GlobalMap using something along the lines of ((String) GlobalMap.get("row1.Id")).
You can use the analogue tForeach component, and set the ID's values inside it. After that, you should connect the iterate output and reference the current value with the variable ((String)globalMap.get("tForeach_1_CURRENT_VALUE")) where the tForeach_1 is the name of your tForeach component.
And set the Query to something like:
"select id, name from employee
where id="+((String)globalMap.get("tForeach_1_CURRENT_VALUE"))

Execute Store Command Entity Framewrok

Hello I am using Entity Framework and I am using the ExecuteStoreCommand to do a query against the database. well I am basically calling a user defined function.
This is the call:
string result = m.ExecuteStoreQuery (SQL).FirstOrDefault();
I query the User Defined Function and I get the following result.
2.09,2.06,2.06,2.0098,2.04,2.04,2.04,2.04,2.04,2,2.1,2.04,2.04,2.04
The return type for the user defined function is
RETURNS Varchar(200). The result above is from the same cell.
When I execute the code from MVC controller I get the following error.The data reader has more than one field. Multiple fields are not valid for EDM primitive types.
What datatype I should be using instead of string.
Any ideas and suggestions.
Apparently, the return type is not only a string.
On the SQL Server side, try to surround the code of your query with:
SET NOCOUNT ON
<your current sql code>
SET NOCOUNT OFF
Maybe EF is getting the rows affected in the result and gets messed up.

Setting LINQ transaction a specified query (without SqlCommand)

I was having difficulty specifying the title for the question properly - essentially I am getting an error saying "ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized." for a situation similar to this:
using (db = getDbContext())
{
var results = (from t in db.table
select t.column).SingleOrDefault();
}
As the error says, all this is already wrapped in another transaction, which I am trying to use for this query as well.
How can I specify the transaction using this query format?
I've tried creating an SqlCommand("select column from table", myconnection, mytransaction),
which works, but I'd much rather use the LINQ syntax for the intellisense (amongst other) benefits, as the actual query is rather more complex
Many thanks, this has been annoying me for hours.
Alex
You can set the transaction into the context itself:
db.Transaction = theTransaction;

Resources