dynamicquery

Using a dictionary to pass parameters to postgresql statement in python

扶醉桌前 提交于 2019-12-11 18:31:27
问题 I have defined a dictionary which contains several parameters and their values which will ultimately be used to build a SQL Query query_params = collections.OrderedDict( {'table_name':'publilc.churn_data', 'date_from':'201712', 'date_to':'201805', 'class_target':'NPA' }) The parameters are to be used in the below query: sql_data_sample = str("""select * from %s # get value of table_name where dt = %s #get value of date_from and target in ('ACTIVE') --------------------------------------------

Dynamic linq-to-nhibernate query problem

六月ゝ 毕业季﹏ 提交于 2019-12-11 10:23:19
问题 Suppose I have classes Foo and Bar as follow: public class Foo { public string F1 {set; get;} public string F2 {set; get;} public Bar ContainerBar {set; get;} } public class Bar { public string B1 {set; get;} public string B2 {set; get;} public List<Foo> Foos {set; get;} } Following linq query has errors saying that foo does not contain a property named F1 . var query = from foo in session.Linq<Foo>() select foo.ContainerBar; query = query.Where(foo => foo.F1 == "abcdef"); I know foo in

How can I emulate WHERE 1 in a dynamic query?

淺唱寂寞╮ 提交于 2019-12-11 07:08:46
问题 I'm making a query dynamically like this: $query = "SELECT u.* FROM users u WHERE date_time > unix_timestamp(DATE_SUB(now(), INTERVAL 1 $range))"; Also $range contains a word like this: switch ($_GET['range']){ case "week": $range = "WEEK"; case "month": $range = "MONTH"; case "year": $range = "YEAR"; case "ALL": $range = <I don't know what should I put here to get the expected result>; } As I've said above, I want to set something as $range value to make the WHERE clause something like WHERE

Dynamic WHERE clauses in a SqlDataSource

坚强是说给别人听的谎言 提交于 2019-12-10 09:43:20
问题 I'm using a SqlDataSource in a very simple application. I'm allowing the user to set several search parameters for the SDS's select command via TextBoxes, one TextBox per parameter (think txtFirstName, txtLastName, etc). I'm planning on using a button click event handler to set the SqlDataSource's SelectCommand property which by default will return all records (for my purposes here). I want to refine this select command to possibly add one or more WHERE clauses depending on if the user enters

How to create temp table from a dynamic query?

元气小坏坏 提交于 2019-12-06 16:57:15
问题 I want to create dynamic query for paging [ Main Motive ], here is my code: Alter proc proc_GetData ( @TableName varchar(500)='tblPropertyType', @PrimaryKey varchar(500)='Id', @Columns varchar(max)='PropertyType', @WhereCondition varchar(max)='', @RecsPerPage int =3, @Page int=1, @SortColumn varchar(500)='Id', @SortDirection Varchar(56)='asc' ) as DECLARE @SQL VARCHAR(MAX) DECLARE @DSQL VARCHAR(MAX) DECLARE @FirstRec int, @LastRec int SET @FirstRec = (@Page - 1) * @RecsPerPage SET @LastRec =

dynamically Search Query in HQL with optional Parameter?

♀尐吖头ヾ 提交于 2019-12-06 06:27:10
问题 i am developing an application in which i need search functionality, i want to write HQL query that dynamically create according to parameters. Currently i have 4 parameters, while searching all parameters are required or 1 or 2 or 3 parameters required according to how user want to searchs. public List<Plot> fetchSearchedPlots(int plotType, String plotSize, String min, String max) { Session session = sessionFactory.getCurrentSession(); List<Plot> searchedLists = new ArrayList<Plot>(); String

Spring Data dynamic query

做~自己de王妃 提交于 2019-12-05 15:35:16
问题 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>

Dynamic WHERE clauses in a SqlDataSource

非 Y 不嫁゛ 提交于 2019-12-05 14:04:16
I'm using a SqlDataSource in a very simple application. I'm allowing the user to set several search parameters for the SDS's select command via TextBoxes, one TextBox per parameter (think txtFirstName, txtLastName, etc). I'm planning on using a button click event handler to set the SqlDataSource's SelectCommand property which by default will return all records (for my purposes here). I want to refine this select command to possibly add one or more WHERE clauses depending on if the user enters search criteria in any of my TextBoxes. Example in case I'm not being clear: By default, my

To call SelectMany dynamically in the way of System.Linq.Dynamic

天大地大妈咪最大 提交于 2019-12-04 14:16:11
In System.Linq.Dynamic, there are a few methods to form Select, Where and other Linq statements dynamically. But there is no for SelectMany. The method for Select is as the following: public static IQueryable Select(this IQueryable source, string selector, params object[] values) { if (source == null) throw new ArgumentNullException("source"); if (selector == null) throw new ArgumentNullException("selector"); LambdaExpression lambda = DynamicExpression.ParseLambda(source.ElementType, null, selector, values); IQueryable result = source.Provider.CreateQuery( Expression.Call( typeof(Queryable),

dynamically Search Query in HQL with optional Parameter?

自古美人都是妖i 提交于 2019-12-04 14:02:02
i am developing an application in which i need search functionality, i want to write HQL query that dynamically create according to parameters. Currently i have 4 parameters, while searching all parameters are required or 1 or 2 or 3 parameters required according to how user want to searchs. public List<Plot> fetchSearchedPlots(int plotType, String plotSize, String min, String max) { Session session = sessionFactory.getCurrentSession(); List<Plot> searchedLists = new ArrayList<Plot>(); String query = "FROM Plot where type = ? and size = ? and price >= ? and price <= ?"; searchedLists = (List