Hi,
I have a query which is written in Oracle. I am wondering if someone can convert it to SQL Server?
select count(*) from dtree connect by prior dataid = parentid start with dataid=%1;
Thanks in advance.
SQL Server doesn't have a Connect By Prior function. You can code around it but I am not sure how. I think there are people in this forum that will be able to help you though. Are your trying to get a total count of all items under the %1 parent? Or are you trying to get totals for each container under the %1 parent?
Try this:
select count(*) as count from DTree INNER JOIN DTreeAncestors at ON DTree.DataID = at.DataID AND at.AncestorID = %1
Hi Greg,I am trying to get total number of objects under %1.
Hi Chris,Thanks very much your query worked. I was just wondering if this "DTreeAncestors" table new in CS10? May be I am wrong I don't remember anything like that in 9.7.1.
Thanks,
Baber.
Object Count query conversion from Oracle to SQL Server Posted byAmin, BaberOn 09/29/2016 11:57 AM Hi Greg,I am trying to get total number of objects under %1.Hi Chris,Thanks very much your query worked. I was just wondering if this "DTreeAncestors" table new in CS10? May be I am wrong I don't remember anything like that in 9.7.1.Thanks,Baber.[To post a comment, use the normal reply function]Topic:Object Count query conversion from Oracle to SQL ServerForum:Content Server LiveReports ForumContent Server:Knowledge Center CS16
Thanks very much for this valuable information. I'll have a look on the CTE and let you know for help.
Can someone convert this to CTE?
select count(*) from tree connect by prior dataid = parentid start with dataid=%1
On which CS version are you?
In general you can better use a query on DTreeAncesstors for the same result.
Hans
From: eLink Entry: Content Server LiveReports Forum [mailto:livereportsdiscussion@elinkkc.opentext.com]Sent: Mittwoch, 7. Dezember 2016 19:15To: eLink RecipientSubject: Re Object Count query conversion from Oracle to SQL Server
Re Object Count query conversion from Oracle to SQL Server
Posted by Amin, Baber On 12/07/2016 01:09 PM
[To post a comment, use the normal reply function]
Topic:
Object Count query conversion from Oracle to SQL Server
Forum:
Content Server LiveReports Forum
Content Server:
Knowledge Center CS16
I am on CS10.
Someone help me in building with dtreeancestors as below:
select name, dtc.DataID, parentid from DTreecore dtc, DTreeAncestors at where dtc.DataID = at.DataID AND at.AncestorID = %1;
But I want to see same with CTE. If someone can help that will be great.
Thanks.
It is the same query, you probably only need to get the case of the column name correctly,
I think it is
selectdt.Name, dt.DataID, dt.ParentIDfrom DTreedt, DTreeAncestors at wheredt.DataID= at.DataIDAND at.AncestorID= %1;
You should not use DTreeCore in queries, because it will also return deleted items.
From: eLink Entry: Content Server LiveReports Forum [mailto:livereportsdiscussion@elinkkc.opentext.com]Sent: Donnerstag, 8. Dezember 2016 17:55To: eLink RecipientSubject: RE Re Object Count query conversion from Oracle to SQL Server
RE Re Object Count query conversion from Oracle to SQL Server
Posted by Amin, Baber On 12/08/2016 11:49 AM
selectname, dtc.DataID,parentid from DTreecore dtc,DTreeAncestors at where dtc.DataID= at.DataIDAND at.AncestorID= %1;
If it’s not working, it may be the “at” can not be used.
selectdt.Name, dt.DataID, dt.ParentID
fromDTreeAncestors dtan
join DTreedt on dtan.DataID= dt.DataID
wheredtan.AncestorID= %1
Colin J. Schmidt
Knowledgelink Support
CapitalOne | Collaboration Technology
Knowledgelink@capitalone.com
Internal: 433-8910
External: 804-284-8910
Cell: 918-904-9223
Don’t waste space with attachments – follow thesestepsto e-mail links to documents stored in Knowledgelink
From: eLink Entry: Content Server LiveReports Forum [mailto:livereportsdiscussion@elinkkc.opentext.com]Sent: Thursday, December 08, 2016 1:23 PMTo: eLink Recipient <devnull@elinkkc.opentext.com>Subject: RE RE Re Object Count query conversion from Oracle to SQL Server
RE RE Re Object Count query conversion from Oracle to SQL Server
Posted by Stoop, Hans On 12/08/2016 01:22 PM
The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates and may only be used solely in performance of work or services for Capital One. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.