Can H2 database support queries that use structured parameters (sometimes called Table Value Parameters or User Defined Table Types ) - h2

In MS SQL Server there is something called User Defined Table Types where you can basically create a parameter that is a table. This allows people in queries to pass a table as an input. This is commonly used to get around limitations with the maximum number of input parameters (such as in JDBC which limits the number of input parameters to something like 2000).
If I have queries that take in user defined data table types can H2 database support this?

JDBC doesn't impose any limitations for numbers of JDBC parameters. JDBC drivers may have own limits and JDBC driver of H2 allows up to 100,000 parameters.
H2 supports standard array and row value data types and you can pass these complex values as JDBC parameters too, but it isn't reasonable to use them to group unrelated parameters together to reduce their count.
H2 doesn't support any other complex data types and you cannot use MS SQL-style user-defined table types in H2.

Related

Getting schema information from JDBC in batch

Is there a way of retrieving the schema of a database via JDBC in a batch, without having to make to make a .getTableNames call followed by a series of .getColumnNames / .getColumnTypes calls? I would like to be able to issue a single call (that resulted in a single or small number of queries to the database) that returned all the tables in a schema, along with their columns and column type info. For large schemas, the separate method calls can take a long time.
Of course, it can be done with a database-system-specific query against the database's information schema, but I'm looking for a way that is generic to JDBC.

Return from query that refers tables in two different db

I have a goal where I need to write a query in JDBC postprocessor of JMeter but the tables used in query are in different databases. Some tables are in Db2 and others are in PostgreSQL.
I can connect and get response from two databases i.e. Db2 and PostgreSQL separately. However when I write query, that refer to tables in different db, I see relationship doesn't exist error.
I understand, I can use bound pool variables in JMeter for different db connections.
My question:
How can I use these bound pool variables, which are referring to different db (Db2 and PostgreSQL) connection in JMeter, in a single query, if that is possible. Maybe an example will help here, please?
If what I mention in 1 is not possible in JMeter, then how can I achieve above mentioned overall goal through JMeter?
It is not possible either "through jmeter" or "through" any other database client.
If you need to execute 2 separate queries at the same time - you can add 2 JDBC Connection Configuration elements for 2 databases, 2 JDBC Request samplers and a Synchronizing Timer.

Can JMeter JDBC pre-processor accept multiple Insert/delete/update queries?

Can JMeter JDBC pre-processor accept multiple Insert/delete/update queries?
I have added two queries:
JMeter can do whatever underlying JDBC driver can do, for example for MySQL you can specify allowMultiQueries JDBC URL parameter and you will be able to separate statements by semicolon.
Looking into oracle pool variable name my expectation is that you're trying to test an Oracle database and its JDBC driver doesn't support this feature.
The options are in:
Create a stored procedure which will delete multiple records
Parameterize existing JDBC PreProcessor using i.e. __StringFromFile() function, in this case you will not have to copy and paste the preprocessors
Use JSR223 PreProcessor instead of the JDBC PreProcessor and implement your records deletion logic there, take a look at Statement.addBatch() function, you can combine multiple queries into one statement with it. Check out Using Statement Objects for Batch Updates chapter of the Retrieving and Modifying Values from Result Sets article for more details.
You can submit multiple queries as is, because you can't use ; in JDBC request
But you can use other techniques to insert/delete multiple records, for example using IN
delete from CPAY where bnf_nic_name in ('BillerBBJ929' ,'BillerOFV864')

Oracle explain plan differs when using bind variables

When generating an explain plan for a query my system executes, I notice that if I leave filters in their parameterized form (e.g. "somecolumn=:param1") the explain plan is different when I replace the parameter with a real value (e.g. "somecolumn='real_value'). In my case, the explain plan with the database parameters ends up ignoring indexes and does full table scans on massive tables leading to high cost, bytes and estimated rows.
Why do the plans differ? Is Oracle using the less than desirable plan because the system uses bind parameters?

DDD specification pattern with stored procedure

I am going to write a stored procedure which will pull back X number of records based on a query. This SP may need to lock the records while it does the search. I am also using EF which I know can't use pessimistic locking.
Instead of having the filtering logic in the query itself I was thinking of using the specification pattern so the business logic will dictate the query. If I use this pattern and pass through the specification into my repository which in turn calls the SP how will the SP know what to do with the specification?
The specification can consist of criteria spanning multiple tables and sorting on different columns.
Would it make sense to use the specification pattern in this scenario or should I just create the SP with the query and filtering defined in there?
Specification pattern is for defining and executing query in your application - Linq is kind of specification. Stored procedure is for defining and executing query in database server directly. Those two are mostly contrary approaches.
There is possibility to create dynamic SQL inside stored procedure but that moves your logic to database which has nothing to do with DDD. Moreover it would be quite complex to allow such solution for arbitrary filter where you need to join additional tables.
There is currently no way to translate a specification from a C# lambda expression into a structure that you can pass into a stored procedure in order to query the database. Specification pattern is usefull only if you intend to make full usage of ORM (not Store Procedures).

Resources