recursive-query

How can I paginate with Spring Security, Hibernate and row level ACL

纵饮孤独 提交于 2019-12-05 01:38:15
问题 I'm reading about Spring Security and wonder whether it's possible to use Spring ACL together with hibernate and pagination. The resulting SQL is surely scary but possible to be auto-generated. It's even possible to use hierarchical ACL if the database supports recursive query evaluation. Using a post filter is no solution since it breaks pagination and is an unnecessary overhead compared to ACL filtering inside the database. So I actually have the pieces to build a solution. I want to know

How to write a recursive query in SQL Server 2000

柔情痞子 提交于 2019-12-04 23:17:58
I have a table which has a list which looks like this References R. Name LineNo. References A 1.1 (B,24.1) A 6.3 (A, 1.3), (D, 22.1) B 23.1 (A. 1.2) B 24.1 (B,23.1) C 2 (A, 1.1) D 3.12 (A, 6.3) The query should go one by one in the records and generate a value based on the references, pick first one lets say, which is Report Name A, Line No. 1.1, Now the reference is (B, 24.1), which means we need to find Report Name B, line no 24.1 and pick its value. In the same table R.Name B and Line No B, 24.1 is referenced by (B, 23.1), So now we need to find Report name B, Line No 23.1, We go on through

How to grep a word inside xml files in a folder

我是研究僧i 提交于 2019-12-04 23:03:59
I know I can use grep to find a word in all the files present in a folder like this grep -rn core . But my current directory has many sub-directories and I just want to search in all xml files present in the current directory and its all sub directories . How can I do that ? I tried this grep -rn core *.xml // Does not work But it searches for xml files present in the current directory only. It does not do it recursively. Chris Maes Try the --include option grep -R --include="*.xml" "pattern" /path/to/dir Reference: Grep Include Only *.txt File Pattern When Running Recursive Mode Use find :

Recursive SQL statement (PostgreSQL 9.1.4)

半城伤御伤魂 提交于 2019-12-04 18:31:52
问题 PostgreSQL 9.1 Business situation Every month, there is a new batch of accounts given to a specific process. Every batch can be described by month, number of accounts and total balance of accounts. The goal of the process is to recover some of the balance back from customers. Each batch is than tracked separately on a monthly basis (amount recovered on each month since batch was transferred to the process). Goal My goal is to predict what amount will be recovered in the future. Data

PostgreSQL WITH RECURSIVE performance

大憨熊 提交于 2019-12-04 16:39:52
问题 I have a simple question. Somehow I was unable to find a definitive answer. How much is WITH RECURSIVE syntax optimized in PostgreSQL? By that I mean: is it merely a syntactic sugar for a series of non recursive queries, OR is it more of a single statement that despite its complicated semantics has been optimized as a whole. A follow-up question - just about how much is it possible to optimize this kind of syntax? Of course some concrete data on the matter is most welcome. 回答1: My experience

How can I traverse a tree bottom-up to calculate a (weighted) average of node values in PostgreSQL?

风格不统一 提交于 2019-12-04 12:04:17
The typical example for e.g. summing a whole tree in PostgreSQL is using WITH RECURSIVE (Common Table Expressions). However, these examples typically go from top to bottom, flatten the tree and perform an aggregate function on the whole result set. I have not found a suitable example (on StackOverflow, Google, etc.) for the problem I am trying to solve: Consider an unbalanced tree where each node can have an associated value. Most of the values are attached to leaf nodes, but the others may have values as well. If a node (leaf or not) has an explicitly attached value, this value can be

sql recursive function - to find managers

狂风中的少年 提交于 2019-12-04 10:11:34
Lets say I have the following table User_ID Manager_ID --------------------- Linda Jacob Mark Linda Kevin Linda Steve Mark John Kevin Basically the requirement is to pull all the managers under the user_id you are searching for. So for instance if I send in 'Linda' then it should return me: 'Mark', 'Kevin', 'Steve', 'John' or if I send in 'Mark' then it should return me: Steve I have heard of recursive function but I am unsure of how to do this. Any help would be appreciated. Use: WITH hieararchy AS ( SELECT t.user_id FROM YOUR_TABLE t WHERE t.manager_id = 'Linda' UNION ALL SELECT t.user_id

Tricky CTE - recursive sql (editing my query)

陌路散爱 提交于 2019-12-04 06:23:49
问题 I want to edit my query in order to get something a little more ticky. The goal is to obtain the approval workflow for every customer, displaying that information in this way: CLIENT | APPROVER1 | APPROVER2 | APPROVER3 | APPROVER4 Previously, i had a table called entities (12, 'Math Andrew', 308, 'CHAIN1-MathAndrew') (13, 'John Connor', 308, 'CHAIN2-JohnConnor') (18, 'ZATCH', 309, null), (19, 'MAX', 309, null), (20, 'Ger',310, null), (21, 'Mar',310, null), (22, 'Maxwell',311, null), (23,

Deleting rows recursively in a self-referencing table using a CTE. How does the process take place?

时间秒杀一切 提交于 2019-12-04 06:18:45
I'm working on a side project, and in order to delete a row and all its descendants in a self-referencing table, I'm using a recursive CTE like this inside a trigger: CREATE TRIGGER dbo.tr_Comment_Delete ON dbo.Comment INSTEAD OF DELETE AS ;WITH IDs AS ( SELECT id FROM DELETED UNION ALL SELECT c.id FROM Comment AS c INNER JOIN IDs AS i ON c.parent_comment_id = i.id ) DELETE FROM Comment WHERE id IN (SELECT id FROM IDs); GO This is the self-referencing table Although I have this code working as expected, it is one of those cases in which you do something, but you're not quite sure how it works.

Overlapping Date Ranges - Identifying Only the Overlap

心已入冬 提交于 2019-12-04 05:25:54
问题 I've seen a lot of solutions to identify records where date ranges overlap, and still other examples of merging overlapping ranges. However I am interested in results that show the range where ONLY the overlap occurs. In fact, I have 3 ProductIDs (and only 3 will ever exist) and I'm trying to find the date range for each customer of when they had ALL THREE. SET NOCOUNT ON; CREATE TABLE #tmp ( CustomerID integer ,ProductID varchar(12) ,Eff_Dt DATE ,End_Dt DATE ); -- Customer 1000: Expecting