dynamicquery

Spring Data dynamic query

耗尽温柔 提交于 2019-12-04 01:28:00
I'm trying to set up a dynamic query using spring data, basically I have an array with a bunch of characteristics and I need to assemble the query based on those characteristics, pretty much something like "WHERE characteristic = A AND characteristic = B AND characteristic = C" but the amount of characteristics may vary. I noticed that I can use the @Query annotation but is it possible to make the result of the @Query pageable ? Is there any other way to accomplish this? Page<Recipe>

How Can I Make Oracle Query Sort Order Dynamic?

最后都变了- 提交于 2019-12-02 09:21:58
问题 I have a Oracle procedure inside a package like this PROCEDURE getEmployee ( pinLanguage IN VARCHAR2, pinPage IN NUMBER, pinPageSize IN NUMBER, pinSortColumn IN VARCHAR2, pinSortOrder IN VARCHAR2, poutEmployeeCursor OUT SYS_REFCURSOR ) AS BEGIN OPEN poutEmployeeCursor FOR SELECT * FROM ( SELECT EMPLOYEE_ID, USERNAME, FULL_NAME, DATE_OF_BIRTH, EMP.GENDER_ID, GEN_TR.GENDER, EMP.WORK_TYPE_ID, WT_TR.WORK_TYPE, SALARY, EMAIL, PROFILE_IMAGE, ROW_NUMBER() OVER (ORDER BY EMPLOYEE_ID ASC) RN FROM

Dynamic query with HibernateCritera API & Oracle - performance

匆匆过客 提交于 2019-12-02 07:29:20
I have to use Hibernate and retrieve data from Oracle but the problem is, that the number of parameters passed to the query is not always the same. For the sake of simplicity let's consider the following query: select COL_1, COL_2, ..., COL_N from TAB_1 where COL_1 in (?, ?, ... ?) The number of parameters passed to in clause is between 1 and 500. If the number is about 1-50 it works quite fast, but for 200 it takes a few seconds to execute the query (parsing, creating explain plan, executing the query). Indexes are created and used - it was checked. The query is created dynamicly so I use

How Can I Make Oracle Query Sort Order Dynamic?

六眼飞鱼酱① 提交于 2019-12-02 06:51:44
I have a Oracle procedure inside a package like this PROCEDURE getEmployee ( pinLanguage IN VARCHAR2, pinPage IN NUMBER, pinPageSize IN NUMBER, pinSortColumn IN VARCHAR2, pinSortOrder IN VARCHAR2, poutEmployeeCursor OUT SYS_REFCURSOR ) AS BEGIN OPEN poutEmployeeCursor FOR SELECT * FROM ( SELECT EMPLOYEE_ID, USERNAME, FULL_NAME, DATE_OF_BIRTH, EMP.GENDER_ID, GEN_TR.GENDER, EMP.WORK_TYPE_ID, WT_TR.WORK_TYPE, SALARY, EMAIL, PROFILE_IMAGE, ROW_NUMBER() OVER (ORDER BY EMPLOYEE_ID ASC) RN FROM EMPLOYEES EMP INNER JOIN GENDERS GEN ON EMP.GENDER_ID = GEN.GENDER_ID LEFT JOIN GENDERS_MLD GEN_TR ON GEN

Incorrect Syntax Near GO, T-SQL EXEC()

独自空忆成欢 提交于 2019-12-02 06:12:38
问题 I am using the following script: DECLARE @dbName NVARCHAR(20) = 'ABC'; EXEC ( N' USE ' + @dbName + ' GO -- Create Schema CREATE SCHEMA meta GO -- Create Log Table CREATE TABLE meta.LogAudit( [EventDate] [datetime] NOT NULL DEFAULT (getdate()), [EventType] [nvarchar](64) NULL ) GO ' ); but it throws me the following error. Msg 111, Level 15, State 1, Line 5 'CREATE SCHEMA' must be the first statement in a query batch. Msg 102, Level 15, State 1, Line 22 Incorrect syntax near 'GO'. Why is that?

Incorrect Syntax Near GO, T-SQL EXEC()

你离开我真会死。 提交于 2019-12-02 01:12:11
I am using the following script: DECLARE @dbName NVARCHAR(20) = 'ABC'; EXEC ( N' USE ' + @dbName + ' GO -- Create Schema CREATE SCHEMA meta GO -- Create Log Table CREATE TABLE meta.LogAudit( [EventDate] [datetime] NOT NULL DEFAULT (getdate()), [EventType] [nvarchar](64) NULL ) GO ' ); but it throws me the following error. Msg 111, Level 15, State 1, Line 5 'CREATE SCHEMA' must be the first statement in a query batch. Msg 102, Level 15, State 1, Line 22 Incorrect syntax near 'GO'. Why is that? -- Edit: This answer seems to be answering my question: dynamic sql error: 'CREATE TRIGGER' must be

Adding Where Condition to All Requests EF6

人盡茶涼 提交于 2019-12-01 20:33:45
问题 Most of my entities (not all) have two properties called CompanyId and Deleted . How would be possible to auto insert these two properties for all select requests instead of setting manually on every single query I have along the whole app. Example: db.MyEntity.Where(me => me.Id == 1).Select(me => me.Description) Check dynamically it the entity has the props CompanyId and Deleted . Case affirmative, transform it like this db.MyEntity.Where(me => me.Id == 1 && Deleted == false && CompanyId ==

Manupilating previous month data according to current month

南笙酒味 提交于 2019-12-01 14:41:36
I have one table name Prv_Data which contain previous month of report, having Report_Id and Timeline column. Prv_Data --> Report_ID | Timeline ---------------|-------------- 01 | Weekly @Mon 01 | Weekly @Mon 01 | Weekly @Mon 01 | Weekly @Mon 02 | Weekly @Thru 02 | Weekly @Thru 02 | Weekly @Thru 02 | Weekly @Thru 02 | Weekly @Thru I have another table name as Cur_Month which contain current month details. Cur_Month--> Details | Count --------------|-------- First Date | 05/01/2017 Last Date | 05/31/2017 Friday | 4 Monday | 5 Saturday | 4 Sunday | 4 Thursday | 4 Tuesday | 5 Wednesday | 5 Now I

Import Excel .xslx file into sql server : difficulty in updating table

泄露秘密 提交于 2019-11-30 21:04:11
问题 I am importing excel file into sql server datatbase. The code works fine but the way I am doing currently is deleting (clear the table) the table data. string ssqltable = "tStudent"; string myexceldataquery = "select id,student,rollno,course from [sheet1$]"; try { string sexcelconnectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" + excelfilepath + "; Extended Properties=\"Excel 12.0; HDR=Yes; IMEX=2\""; string ssqlconnectionstring = "Data Source=DELL\\SQLSERVER1;Trusted

How to write this Linq SQL as a Dynamic Query (using strings)?

。_饼干妹妹 提交于 2019-11-30 14:37:47
Skip to the "specific question" as needed. Some background: The scenario: I have a set of products with a "drill down" filter (Query Object) populated with DDLs. Each progressive DDL selection will further limit the product list as well as what options are left for the DDLs. For example, selecting a hammer out of tools limits the Product Sizes to only show hammer sizes. Current setup: I created a query object, sent it to a repository, and fed each option to a SQL "table valued function" where null values represent "get all products". I consider this a good effort, but far from DDD acceptable.