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
1
vote
2 answers

SQL pivot with unknown number of columns - not a valid identifier and showing minimum only

I am having an issue with a dynamic query to pivot on an unknown number of columns in MS SQL server 2014. I've based my query on the article SQL Server 2005 Pivot on Unknown Number of Columns and other similar articles. However, I am having two…
Dion
  • 21
  • 5
1
vote
0 answers

Is there a way to build Dynamic Mongo query in C#

Could we able to build a dynamic mongo query where mongo query should process WHERE condition dynamically and retrieve the data from Mongo DB. var query = from e in collection.AsQueryable() where e.FieldName1 == "XXX" …
Arunmani
  • 11
  • 1
1
vote
2 answers

Need all columns on one row

I wrote the following query: IF OBJECT_ID ('tempdb..#ColumnsType') IS NOT NULL DROP TABLE #ColumnsType DECLARE @vQuery NVARCHAR(MAX) ='' IF OBJECT_ID ('tempdb..#random') IS NOT NULL DROP TABLE #random CREATE TABLE #random ( ColumnID INT PRIMARY…
Yana
  • 785
  • 8
  • 23
1
vote
1 answer

How to do Merge operation from xml to dynamic tables and columns in MSSQL

I have a xml which provides me table name with there respective ID column and column to update or insert on basis of those IDs below is the xml: Table1 1
Daksh Dutta
  • 163
  • 1
  • 1
  • 12
1
vote
1 answer

How to return row from function cursor and loop in oracle

I want to run a dynamic query in oracle using a function/package that will return row/s which I can loop. I have the function create or replace FUNCTION FUNC_CHECK ( I_SERVICE_ID IN NUMBER, I_count_id IN NUMBER, I_SRC_S1 IN NUMBER, I_SRC_E1…
shorif2000
  • 2,582
  • 12
  • 65
  • 137
1
vote
1 answer

How to Create View or Table from Prepared Statement (Select Query)

I am trying to create View from the following prepared statement: CREATE VIEW myview AS -- this line is not working SELECT CONCAT(GROUP_CONCAT('SELECT ''', COLUMN_NAME,''' MyColumns, SUM(`', COLUMN_NAME,'`) Total FROM mydb.source_table' SEPARATOR…
1
vote
4 answers

C#-MongoDB: List inside the Where Clause with OR operator

I have a list of categories, and i am creating a dynamic query. var Categories = GetCategories(); //list of string query = query.Where(x => x.CategoryID == ?????); Now how can i make the categories list have an OR operator on each category inside…
zvikow
  • 21
  • 2
1
vote
3 answers

Use dynamic value to a variable which is being used in the subsequent dynamic query in my code

This code works when set @ToDate = '20200311' i.e. when I have hardcoded the specific date, but does not work when I want this to always execute till the current date The line set @ToDate = select .....getdate.. throws error, can you please help me…
Berry
  • 21
  • 2
1
vote
0 answers

dynamic select field in ecto query

I have a trouble with ecto query situation, that I Have a ORDER table with basic fields: current_status, picked_up_at, delivered_at, returned_at. where: picked_up_at, delivered_at, returned_at is Date type. and data struct i want to query back is:…
Lưu An
  • 13
  • 3
1
vote
0 answers

RestrictionsFactoryUtil.in() works with MySQL, fails with MS SQL Server. Need viable workaround

I'm having trouble making an API call:     RestrictionsFactoryUtil.in("columnName", ListofIDs); The function com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil.in() works properly when my app passes a list of more than 2100 records using…
kah
  • 71
  • 9
1
vote
3 answers

Only select from tables that are of interest

SQL Server 2016 I have a number of tables Table A Table B Table C Table D User | DataA User | DataB User | DataC User | DataD =========== =========== …
Peete
  • 125
  • 11
1
vote
0 answers

How do I query posts from post type taxonomy?

I use this code to match current default post title slugs with category term slugs if ( is_singular( 'post' ) ) { $current_post_slug = get_post_field( 'post_name' ); $args['category_name'] = $current_post_slug; $args['post_type'] =…
JimDixon
  • 11
  • 1
1
vote
0 answers

How can I use to_char function in the Liferay DynamicQuery API?

Platform is Liferay 7.0, Tomcat, Oracle 12c. We currently use dynamic query below. In order to tune it for better performance, we need to convert the data_ field which is a CLOB to character. DynamicQuery dynamicQuery =…
VC1
  • 1,660
  • 4
  • 25
  • 42
1
vote
1 answer

How to query last version of JournalArticle with DynamicQuery in Liferay 7.2

I have the following query in my code: DynamicQuery journalArticleDynamicQuery = JournalArticleLocalServiceUtil.dynamicQuery(); journalArticleDynamicQuery.add(PropertyFactoryUtil.forName("DDMStructureKey").eq("MY_STRUCTURE"));…
Ravers
  • 988
  • 2
  • 14
  • 45
1
vote
2 answers

Call Linq GroupBy with IEqualityComparer on dynamic type

I want to create a dynamic GroupBy implementation that ignores case. I am using Expression.Call, which allows me to pass Expressions as arguments. There are several answers on how to create a custom comparer, but this question is about how to pass…
Jaroslav K
  • 327
  • 1
  • 13