DB2 AS/400 jtopen-7.1 DatabaseMetaData changes - db2-400

I am connecting to DB2 AS 400 V6R1m0 using jt400 7.1 driver. In 7.1 driver IBM have made changes in Database metadata methods.
One such change is allowing user to get table-names on the current schema using the ‘*USRLIBL’ keyword . The documentation for the same can be found at : http://sourceforge.net/projects/jt400/files/ which says
By default, the "metadata source" connection property is set to 1, and
in that case, information from all schemas is returned if null is
passed for the schema pattern. You can however pass in the special
value of *USRLIBL yourself and get the desired results
So fetching table names using the keyword ‘*USRLIBL’ goes like this.
ResultSet rs = mtdt.getTables("S063AAD5",”*USRLIBL”, null, null);
SYNTAX : getTables(String catalog,
String schemaPattern,
String tablePattern,
String[] tableTypes)
This is working fine.
If we use the same pattern to get the procedure names an empty set is returned .
ResultSet rs = mtdt.getProcedures("S063AAD5","*USRLIBL", null);
SYNTAX : getProcedures(String catalog,
String schemaPattern,
String procedurePattern)
Can we use the keyword “*USRLIBL” in getProcedures call ? Whether the usage of “*USRLIBL” is supported in getProcedures() call.
Or should we continue using null for schema pattern while making use of getProcedures call().

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

OLE DB connection in SSRS doesn't like when parameters are repeated

I'm changing an Oracle based SSRS report and I'm having all sorts of issues with parameters.
The connection to Oracle is OLE DB.
My code is not doing anything complicated. I've only added in a new parameter. When I only have one instance of said parameter, it runs without any issues. As soon as I add it again, it bombs.
What I'm trying to do is show records if a parameter has a match. If no match, show all records.
I can run both queries in DBVisualizer without any issues.
This is what I've done
WHERE FieldName = nvl(:parameter, FieldName)
This one doesn't return the same results as this below
WHERE FieldName = :parameter
OR :parameter IS NULL
Problem is the second WHERE clause will not run in SSRS with an OLE DB connection. We cannot use another connection manager, unfortunately.
EDIT: Thanks to Hannover Fist, I was able to get this to work by doing this
I changed my WHERE clause to
WHERE FieldName = :parameter
OR :parameter2 IS NULL
Then mapped parameter2 to pull from the same SSRS parameter as the original parameter
I haven't found a good solution to this problem but I have worked around it by declaring the parameter in the Oracle SQL and mapping it to the SSRS parameter.
Then use the parameter created in the Oracle SQL in the rest of the query. This way you'll only use each SSRS parameter once.

ServiceNow Encoded Query validation

I intend to let users specify encoded query in ServiceNow SOAP requests.
The problem is that if user specifies invalid query string (e.g. "?##" or "sometext"), ServiceNow do not return any exception, but every row or no rows at all.
Is there a way to check validity of encoded query via webservice?
Fandic,
If you know ahead of time which table the SOAP query will be running against (or can get that information from the user when they submit the query) you can set up your own web service exclusively for checking the validity of a query string.
GlideRecord has the "addedEncodedQuery" method for putting in encoded queries, and it has a getEncodedQuery for turning the current query into an encoded string. If you instantiate a GlideRecord object, and pass it an invalid query string like this:
var myGR = new GlideRecord('incident');
myGr.addEncodedQuery('invalid_field_foo=BAR');
You can then call getEncodedQuery out to see if it is valid:
var actual_query = myGR.getEncodedQuery(); //sys_idNotValidnull
You shouldn't do simple comparison between the input and the output, as the API doesn't guarantee that a valid query will be returned as the exact same string as entered. It's better to simply validate that the actual_query does not equal 'sys_idNotValidnull'.
I always recommend enabling the system property 'glide.invalid_query.returns_no_rows' to avoid this effect. The property does just what it says. I never understood why you'd ever want to return all rows for an invalid query. I've seen a number of cases where developers had a query defect and never knew it since rows were coming back.
You can use the below code so that query will return the result only when it correct.
gs.getSession().setStrictQuery(boolean);
This overrides the value of system property :
glide.invalid_query.returns_no_rows
Reference : https://docs.servicenow.com/bundle/istanbul-platform-administration/page/administer/reference-pages/reference/r_AvailableSystemProperties.html
Check the property value glide.invalid_query.returns_no_rows. If it's true, the invalid query returns no rows. If false (or not available) it is ignored.
This can be overridden with gs.getSession().setStrictQuery(boolean); on a script-by-script basis.

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