Questions tagged [dynamicquery]

Use this tag for questions related to dynamic queries; queries that are built dynamically rather than provided as an explicit query string.

is usually found in questions related to SQL, C#, Drupal, Java, etc., so if you are about to use this, make sure you accompany it by the corresponding tag of your programming environment.

344 questions
0
votes
1 answer

SQL Server 2014 - sp_describe_cursor_column for dynamic queries issue

Basically I want to know columns/aliases of result set from dynamic query. I tried to use sp_describe_cursor_column but without success. It returns me that cursor does not exits. But I can fetch values from such cursor... The code is : ALTER PROC…
dcieslak
  • 2,697
  • 1
  • 12
  • 19
0
votes
1 answer

#Temporary table ,#Dynamic Query

This is my query: DECLARE @DB_NAME VARCHAR(50) SET @DB_NAME='CC_GET' DECLARE @CMD_BUSID VARCHAR(300) SET @CMD_BUSID='(SELECT DISTINCT A.BUSID FROM LTBAUDITTYPE A WHERE BUSINESS IN ( SELECT DISTINCT CONTACT_BUSINESS FROM…
Anoop Nair
  • 35
  • 7
0
votes
1 answer

Concatinate Variable define in Dynamic Query

I'm building a dynamic query. Inside it, I have declare variables. Now I want to concatenate this variable in my insert query declare @qry nvarchar(MAX) select @qry='Declare @var1 nvarchar(10); set @var1 =''abcd'' insert into mytable (col1) values…
Muhammad Taqi
  • 305
  • 2
  • 6
  • 19
0
votes
1 answer

Dynamic column name in Cursor PLSQL-Oracle

I am working on a query in pl/sql. I've almost same named columns like column1, column2, column3. In Cursor, how can i get value of these columns using dynamically name. My query: FOR Cursor_r IN Cursor_c LOOP BEGIN IF Cursor_r.column1…
junior
  • 1
  • 1
0
votes
1 answer

How to make a dynamic query for MySQL

I used Spring MVC, how can I made a dynamic query for Mysql? I have in my controller something like that: public String getNewsByDateAndAuthor(Model model, HttpServletRequest request) {} How can I used all my parameters from URL with…
Dumitru Vlad
  • 109
  • 1
  • 2
  • 13
0
votes
3 answers

Dynamic Query in Ibatis

Is it possible to pass dynamic query to Ibatis and get the record from it? E.g. I built my query using StringBuilder and at last, I got the following query "select emp_id, emp_name from employee where emp_id==1" . Now i need to pass this complete…
Gopi
  • 5,656
  • 22
  • 80
  • 146
0
votes
2 answers

Transpose unknown number of columns with single row result using dynamic PL/SQL

I believe there must be a simple way to achieve this, I just haven't been to figure it out. I've search for a ways but I can't find anything that doesn't invlovle aggregates, I have a dynamic query (Oracle) that I build in a loop using…
Saieden
  • 45
  • 5
0
votes
2 answers

dynamic search with django form

Using django, I want to dynamically search for text across multiple fields. I have a list of fields to search across as well as the text to search against. I also have an initial queryset to query against. Something along these lines: def…
Atul Bhatia
  • 1,633
  • 5
  • 25
  • 50
0
votes
1 answer

How to use an IN operator in a dynamic query

I would like to use the in operator in a dynamic query . At the moment I need someone to point in in the right direction as to how to structure the apostrophes for separating values so that they don't interfere with the apostrophes for the dynamic…
anchor
  • 1,685
  • 2
  • 11
  • 11
0
votes
2 answers

Executing set of queries using JDBC Statement or PreparedStatement

I need to execute a set of statements which uses user-defined variables using JDBC. Below is my query: SET @sql = NULL; SELECT GROUP_CONCAT(DISTINCT CONCAT( 'MAX(IF(pa.fieldname = ''', fieldname, ''', pa.fieldvalue, NULL)) AS…
xxxxx
  • 1,918
  • 2
  • 17
  • 22
0
votes
3 answers

Conversion failed when converting the varchar value '"' to datatype int in dynamic query

I am receiving the above error when I try to execute a query on MS SQL Server 2005. It is a dynamic query built up in multiple parts. Here is the simplified structure and data: CREATE TABLE [record_fields]( [field_id] [int] NOT NULL, [campaign_id]…
Yetiish
  • 703
  • 1
  • 8
  • 19
0
votes
1 answer

Problem with Namespaces? Trouble When Using DynamicQuery Sample

DynamicQuery is a sample project that allows 'Dynamic' LINQ strings to be executed at run-time. I want to use this in a project of mine. I've created a new Window Forms Application in VB.Net; and add the existing item - 'Dynamic.vb' (taken from the…
Rob P.
  • 14,921
  • 14
  • 73
  • 109
0
votes
0 answers

SQL Server return table-valued variable from sp_executesql

I need to INSERT into a table-valued variable several rows that come from a dynamically generated SELECT statement, that is INSERT INTO ... SELECT ... I'm trying to do it via sp_executesql. How to return this filled table-valued variable from the…
0
votes
1 answer

Build query from list of table names with unknown length using SQLAlchemy and Postgresql

I'm dealing with timeseries data, and I'm trying to avoid having a many-to-one-relashionship on every row of a single record table where all records are mixed together (since the series all have different number of columns). Instead I want to split…
pjgb
  • 15
  • 4
0
votes
2 answers

Dynamic query in EF

I have already searched in other questions for a solution, but didn't find it. So, my problem is the following: I have a page where the user can mount an expression. For example, if they want some professors with course 1 and course 2 then, they…