Questions tagged [dynamic-queries]
120 questions
260
votes
27 answers
Is there a query language for JSON?
Is there a (roughly) SQL or XQuery-like language for querying JSON?
I'm thinking of very small datasets that map nicely to JSON where it would be nice to easily answer queries such as "what are all the values of X where Y > 3" or to do the usual SUM…

allclaws
- 5,575
- 8
- 30
- 27
17
votes
2 answers
Spring Data MongoDB Repository - JPA Specifications like
Is there something like JPA Specifications for Spring Data MongoDB Repositories?
If not, how can I make dynamic queries with repositories?
A classic scenario could be a search form with optional fields that the user will fill.

s1moner3d
- 1,141
- 2
- 16
- 35
12
votes
2 answers
My SQL Dynamic query execute and get ouput into a variable in stored procedure
I generate a dynamic query in My sql Stored procedure. I wanna get the result of this query into a out parameter. How to do this ?
CREATE PROCEDURE 'searchInvoice'
(
OUT numOfRecords INT
)
BEGIN
DECLARE query1 TEXT;
DECLARE query2 TEXT;
…

Sency
- 2,818
- 8
- 42
- 59
5
votes
2 answers
LINQ - dynamic orderby clause does not work
I have code like this:
//build query
var shops = (from p in dataContext.shops
let distance = dataContext.GetDistance(p.lat, p.lon, nearlat,nearlon)
join c in dataContext.shops_category on p.id equals c.poi_id
…

itdeveloper
- 339
- 2
- 3
- 14
3
votes
2 answers
Run MySQL queries on different databases
We have a system where we have for each division a database , currently we have 20+ divisions.
So when we have to update / delete / alter / new table we have to go threw all of those database and run the queries .
Sometime people don't follow…

Tarek
- 3,810
- 3
- 36
- 62
3
votes
1 answer
Optimal way to index a large flat table in view of dynamic querying
I have a relatively wide table (50 columns). Of those, the first 5 represent the scope of a certain subset of data and the last 45 represent properties (mapped at deployment time, so static). The users have the possibility (through a query builder)…

Andrea
- 884
- 1
- 10
- 23
3
votes
1 answer
Why is this package leaking open cursors?
In our application, we call various stored procedures that return reference cursors in the following fashion:
SELECT foo_package.sp_Bar('arg1', 'arg2', 'arg3', 'arg4') FROM dual;
What the wrap_xml function does is to convert the cursor result to an…

Stephan B
- 837
- 1
- 16
- 41
2
votes
1 answer
Setting the FROM clause via parameter in MyBatis
I haven't been able to see anything in the documentation which speaks to my question, and upon deploying it, my app does not quite work right (more on that in a sec). I am trying to do something like
2
votes
2 answers
Dynamic query to select column based on the condition
Is it possible to select column based on the condition for dynamic queries. If condition is false, then it should not select that column. I want to write below as a dynamic query.
DECLARE @param varchar(10),
SELECT A,
IF (@param = 'U')
B = A-2,…

S M
- 159
- 2
- 13
2
votes
3 answers
Assign function result to a table variable
The SQL Server (2000/2005) function gets the table name and the field name as parameters and returns results from a dynamic query within the function. The results should be assigned to a Table variable which will be used further in a stored…

Dhanapal
- 14,239
- 35
- 115
- 142
2
votes
1 answer
Remove objects from query if None or Null
I am trying to build a query that takes form data and removes any None or " " submissions but I'm not sure how to approach the logic. Here is the code;
@app.route('/filterassets', methods=['GET', 'POST'])
def searchassets():
form =…

xGlorify
- 119
- 1
- 12
2
votes
2 answers
How to pass dynamic View name in SQL stored procedure without using a dynamic query?
Here is my stored procedure below. I am concatenating @CultureCode paramter along with view name which is [_0002HR_EmployeeNames_en-US_View]. The part en-US will be passed through a parameter named as @CultureCode. Is there any way to do so…

Muhammad Bilal
- 125
- 1
- 9
2
votes
1 answer
how to pass variables this in dynamic query in sql
i using the dynamic query to pass the variables
select a.TableName, COUNT(a.columnvalue) as '+'count'+' from Settings a
where a.ColumnValue in ('+ @columnvalue +') and a.Value in (' + @value +')
the @columnvalues = 'a','b','c'
@value…

Innova
- 4,831
- 21
- 76
- 107
2
votes
2 answers
Executing queries dynamically in PL/pgSQL
I have found solutions (I think) to the problem I'm about to ask for on Oracle and SQL Server, but can't seem to translate this into a Postgres solution. I am using Postgres 9.3.6.
The idea is to be able to generate "metadata" about the table…

EJB
- 23
- 1
- 1
- 4
2
votes
1 answer
How to organize and implement Separation of Concern and good OOP with a growing list of queries throughout my app?
Where to put a growing list of queries (mostly all "SELECT" queries) and how to properly access them throughout my app?
I'm looking to re-factor my app which currently has queries sprinkled all throughout services in my app. I'm starting to…

prograhammer
- 20,132
- 13
- 91
- 118