Query using Order By in JDBC request - sql

I have a jdbc request in jmeter where i am searching user data from the table.But data shows multiple records so i need to use order by latest updated date.
SQL is working fine but display multiple record,how can i use
SELECT CREATION_DATE,PROCESS_FLAG FROM
CUST where ORDER_NUMBER =? order by
LAST_UPDATE_DATE desc;
because it is giving me error invalid character while trying using jmeter

JMeter doesn't allow to use ; sign at the end of JDBC Request select statement.
Do not enter a trailing semi-colon.
Just remove last character and SQL will be executed wìthout error.

It is hard to guess what's wrong without seeing request and response details and knowing what database and which JDBC driver you're using.
Try the next tips:
Check your ${OrderID} variable value using Debug Sampler
Check generated query and parameter substitution using "Request" tab of the View Results Tree listener
Check that you are using appropriate JDBC Driver for your database (not too old, not too new)
Check if you can run the same query using plain Java code

Related

ALTER SESSION over Ms Access Passtrough for Oracle

i need to execute this command, which works perfectly if I execute it via ADODB
ADOConn.Execute ("ALTER session set NLS_DATE_FORMAT=""DD.MM.YYYY"" ")
Since I need to join multiple databases from different systems, I switched to passtrough queries to join them later. Now I need to change the date format via my passtrough query, but this just does not want to work.
ALTER session set NLS_DATE_FORMAT="DD.MM.YYYY"
I execute this command before my select command.
I get this error:
ODBC--call failed.
[ORACLE][ODBC][ORA]ORA-00922: missing or invalid option (#922)
What am I missing? I tried to mess around with the quotation marks but could not success.
Well, such commands are only going to apply to the given connection.
So you have this:
ALTER session set NLS_DATE_FORMAT="DD.MM.YYYY";
SELECT * from tblHotels;
Note how we have two command statments in the one Pass-though query. I am assuming that you are doing the same thing? And test + try using the Oracle console, since if the raw sql you are sending does not work on/from the oracle console, then it certainly will not work as per above. So, you can (and should) include the multiple commands in the ONE pt query - I used ";" as the command delimiter - but use what ever works for oracle. So, you MUST get your command(s) working in via the oracle console, and then put them all together one after another into the PT query.
If you going to execute the command separate, then as noted then you have to set returns records = false. But as ntoed, setting the session is ONLY going to apply to the one PT query, not every query sent, since you using a new connection and session for each time you execute a PT query. So, you likly have to include the date format command right BEFORE the select command. As noted, you can stack up and include as many commands in the SINGLE PT query. So, simply stack up the "no count" and the severl other commands, and then include your alter sessio, and then finally at the at of the single PT query, include your select command.

Call a SQL function in Nifi using ExecuteSQL or another processor

I am currently using a function in SQL Server to get the max-value of a certain column. I Need this value to generate a specific number of dummy files to insert flowfiles that are created later on.
Is there a way of calling this function via a nifi-processor?
By using ExecuteSQL I Always get error like unable to execute SQL select query or the column "ab" was not found, when using select ab.functionname() (ab is the loginname of the db)
In SQL Server I can just use select ab.functionname() and get the desired results.
If there is no possible way of calling this function, is there another way to create #flowfiles dummyfiles to reserve this place for them in the DB so that no one else could insert or use this ids (not autoincremt, because it is not possible) while the flowfiles are getting processed?
I tried using $flowfile.count and the Counterprocessor, but this did not solve the Problem.
It should look like: INSERT INTO table (id,nr) values (max(id)+1,anynumber) for every flowfiles, unfortunately the ExecuteSQL is not able to do this.
Think this conversation can help you:
https://community.hortonworks.com/questions/26170/does-executesql-processor-allow-to-execute-stored.html
Gist:
You can use ExecuteScript or ExecuteProcess to call appropriate script. For example for ExecuteProcess just call sqlplus command. Choose type of command "sqlplus". In command arguments set something like: user_id/password#dbname #"script_path/someScript.sql". In someScript.sql you put something like:
execute spname(param)
You can write your own processor :) Of course it's more difficulty and often unnecessary

Parameterize a JDBC SQL Query in SOAP UI from a Custom Property

To proceed with a Database validation, I am having a need of comparing a record in the DB along with a data which is dynamically generated in the previous REST response, using SoapUI.
I have already captured the property value using a Property Transfer step and stored the required value in a custom property in Test-Case successfully i.e., using property expansion, say ${TestCase#customerId}
My intention is to use that particular value stored in the custom properties to query the result I am expecting, in the JDBC Request test step.
The query which I have drafted with the parameter is as below :
Select *
From ABC.SEC_CUST
Where ABC.SEC_CUST.CUSTOMER_ID = ${TestCase#customerId}
The response I receive after executing is as below.
Error getting response; java.sql.SQLSyntaxErrorException : ORA-00911: Invalid character.
But, when I run the query without the parameterized value it executes perfectly. Where, I tend the conclusion as there is a syntax issue in the way I have mentioned the parameter in the query.
But, I am unable to find the correct way to mention the parameter in the query in SoapUI.
Can anyone with experience in SoapUI, please assist me on this?
That is not working because of the use of property expansion which is only known to SoapUI, but not for the SQL query.
In order to get it work for the same, you need to define the variables in the top for all the parameters that are going to be used in the sql query.
Here the screen shot which explains how to use the same:
You forgot a '#'
Select *
From ABC.SEC_CUST
Where ABC.SEC_CUST.CUSTOMER_ID = ${#TestCase#customerId}
Try this.
Select * From ABC.SEC_CUST
Where ABC.SEC_CUST.CUSTOMER_ID = :customerId

Prepared Statement support in Apache Ignite Cache API

Is any facility like Prepared statement supported in IgniteCache API to avoid query parsing each time? I saw that a Jira issue has been raised for this , and it says its resolved in version 1.5.0.final,
https://issues.apache.org/jira/browse/IGNITE-1856 , but i could not find any documentation for this in Apache Ignite site. I know that we can use prepared statement by connecting via JDBC Connection but that does not suit my use case.
My Code looks like below ,this query will be called again and again with different parameters,
IgniteCache<Integer,Subscriber> subscriberCache= rocCachemanager.getCache("subscriberCache");
SqlQuery<Integer, Subscriber> sql = new SqlQuery(Subscriber.class,
"from Subscriber where Subscriber.MSISDNNo=? and Subscriber.status='Active'");
sql.setArgs("SomeNumber");
QueryCursor<Entry<Integer,Subscriber>> cursor =ss.query(sql);
Statements are cached automatically, no action required. If your query text does not change, only parameters do, Ignite will not parse the query again.

SQL Permission Problem

I have having an issue with a SQL execution where I am getting an error message
-2147217843 Login Failed for user.
I am able to successfully open the connection to the database and execute select count(*) queries.
I am getting this error when I include fields.
In a separate application that uses the same fields I am able to retrieve the same data so seems to rule out column permissions.
The query coming back with no error is:-
SELECT tbl_PersonalDetails.SystemID
FROM tbl_PersonalDetails
WHERE tbl_PersonalDetails.Title IS NOT NULL
And tbl_PersonalDetails.HospitalNumber IS NOT NULL
AND tbl_PersonalDetails.SiteID = 1
The query coming back with the error is:-
SELECT DISTINCT tbl_PersonalDetails.Title,tbl_PersonalDetails.HospitalNumber
FROM tbl_PersonalDetails
WHERE tbl_PersonalDetails.SiteID = 1
ORDER BY tbl_PersonalDetails.Title,tbl_PersonalDetails.HospitalNumber ASC
This is not specific to these particular queries, in the first query where we are just doing a count I always get a count back with no issue, when I try to request fields such as in the second I always get the Login Error.
Your problem isn't in the SQL queries you've posted. They would either all fail or all succeed based on the information given.
Your problem is your calling/client code. Sounds like you're using Classic ASP ("recordset....adodb connection").
Double check that your ASP code is using the proper connection strings.
To prove this, run any of these queries in SQL Server Management Studio. Connect using the credentials that your connection string contains.