Finding the "last node" in a hierarchical query?
I'm presented with an issue - find all parent records for which the "last node" in a hierarchy is not set to some value.
Table structure:
child_id number
parent_id number
type_id number
So, I need to find all parents whose eventual last "children" (could be several levels deep, it varies) do not have a type_id of 29.
I can find the hierarchy easily using connect by prior but I'm stuck on that "last node" bit. Any help out there?
user9937402 wrote:
I'm finding that the CONNECT_BY_ISLEAF is showing all leaves set to 0, even if they themselves are parents (i.e. not the last node in the tree).
Post your code.
I'm not following the 2nd example. Where are you getting those values? This is a really large table, so if that is actual data ... that won't work.Since you did not post data sample, SBH cooked up one on-the-fly using subquery factoring clause - WITH. Below is example on existing table, so I don't need to use WITH:
SQL> select lpad(' ',level*2) || ename ename,
2 connect_by_isleaf
3 from emp
4 start with mgr is null
5 connect by mgr = prior empno
6 /
ENAME CONNECT_BY_ISLEAF
KING 0
JONES 0
SCOTT 0
ADAMS 1
FORD 0
SMITH 1
BLAKE 0
ALLEN 1
ENAME CONNECT_BY_ISLEAF
WARD 1
MARTIN 1
TURNER 1
JAMES 1
CLARK 0
MILLER 1
14 rows selected.
SQL> As you can see CONNECT_BY_ISLEAF works as expected.
SY.
Similar Messages
-
How to find the last execute query
Hi, Is there a way to find the last executed query of report?
Thanks
Aali
Edited by: aali on 22-Feb-2010 06:39Hi,
if you hold the necessary privileges, you might find the SQL in the shared pool:
select last_active_time, parse_calls, disk_reads, buffer_gets, cpu_time, end_of_fetch_count, executions, plsql_exec_time, sql_text
from V$SQLSTATS
where sql_text like '% some distinctive string %'
order by last_active_time desc;if you insert some meaningful string in form of comment inside the query itself, say /* report #1 on page 3 */
you may be able to track it down more easily.
select last_active_time, parse_calls, disk_reads, buffer_gets, cpu_time, end_of_fetch_count, executions, plsql_exec_time, sql_text
from V$SQLSTATS
where sql_text like '% report #1 on page 3 %'
order by last_active_time desc;Bye
Flavio
http://oraclequirks.blogspot.com -
Function module to find the top node in the Profit Center standard hierarch
Hi,
Please let me know the function modules/Tables to do the following.
1. To find the Top node in the Profit center standard hierarchy which is displayed via KCH6N Transaction.
2. To read/retrieve standard hierarchy displayed in KCH6N Transaction.
Thanks in Advance,
Madhuri.Hi Madhuri ,
have a look @<b>SETLEAF</b> or SET* in se11 , u can get the Top Node by putting the Logic like this
ex: i am searching for Top Node of A3
<b>select setname from setleaf where valfrom eq 'A3'.</b>and for that selected setname u have to do one more
loop.
<b>select setname from setleaf where valfrom eq 'A2'.</b>
then only u will net Node A1.
this is a sample code only , dont check F2.
let me know if u want more inputs of Set Ids.
regards
prabhu
[email protected]
NjoySAP -
Function to find the Last Date of Month One Year Ago - RETURNS ERROR
I've written sql code which takes a date and finds the Last Day of the Month one year ago. For example, it takes the date '2015-04-17' and returns the date '2014-04-30'. The code works fine in a query. Now I'm trying to turn this into a function. However,
when I try to create the function I get the error:
Operand type clash: date is incompatible with int
Why is this error being returned?
Here is my function:
CREATE FUNCTION dbo.zEOM_LY_D(@Input Date)
RETURNS date
AS
BEGIN;
DECLARE @Result date;
SET @Result = convert(DATE, DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
RETURN @Result;
END;
Thanks for any help you can give.
Stan,
Thanks very much- that does the trick. I should have said I am using SQL 2008 so EOMONTH is not available to me. I still don't get why I got an error though, since I was treating a date like a date and not like an int.
Thanks, John
I think i found the issue but i do not know why it is causing the issue. i think may be the way dates are treated/stored internally..i think dates are stored as no of days after 0001/01/01 but cannot see how this cwould effect..may be somebody else can through
some light.....
if you make it as datetime it will work,
if you leave it as date - eliminate adding 1... you should prefer to use dateadd to add/substract dates.
try this to understand..
--removed the +1 in the code
declare @input date
set @input ='20150503'
select
convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)),0)),101)
go
--made the datatype as datetime
declare @input datetime
set @input ='20150503'
select
convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
Hope it Helps!! -
Query on 0TCT_MC01 to get the last used date of a query
Dear All,
I tried to create a query on 0TCT_MC01 to get the last used date of a query.
Since we do not have readily available key figure for Last used date, could any one help me out to achieve this result?
I am interested to find the old queries which are not being used anymore.
Thanks in advance.You can get the info from the below tables
if you are working with BW 3.5 you can look in table RSDDSTAT in BI 7.0 it is RSDDSTAT_OLAP.
Make a selction on the infocube and the OLAP Statistic Object which is the query ID and execute. Then you should see how often the query was executed, by whom and which date/time.
in field Statistics Object Name Query ID you type in the tech name of the query
from the Counter for statistics event calls -- will give the count... no of times the query used least the count lesser the query is used.
Regards
KP
Edited by: Konduru Prashanth. on Dec 22, 2011 2:44 PM -
How to find the last update date time and user of record field peoplecode
how to find the last update date time record field peoplecode?
Thank you.One can check the last update date time using the following query
SELECT LASTUPDDTTM FROM PSPCMPROG WHERE OBJECTVALUE1 LIKE 'RECNAME' AND OBJECTVALUE2 LIKE 'FIELDNAME' -
Finding the last valid value in a date range
The data I am working with represent readings from different instruments. One field keeps track of a running summation so this number is steadily increasing. I need to look at the data for a given date, however the problem is that sometimes the instrument is turned off. In this case there would be no data for that date, however since all I am interested is the sum total for the signal on that instrument, I need to keep going back until I find the last valid data in the database which would represent the sum up to this point. How can I design a query or procedure that would handle this contingency? Here is some sample data:
PV_ID SMPL_DTE INTEG_SINCE_VAL
271 20-JUL-08 12.05.00 AM 6172.0387459767
271 20-JUL-08 12.06.00 AM 6172.0387459767
271 21-JUL-08 12.05.00 AM 6172.0387459767
271 21-JUL-08 12.06.00 AM 6172.0387459767
271 21-JUL-08 08.43.00 AM 6172.0387459767
271 21-JUL-08 08.45.00 AM 6172.0387459767
271 22-JUL-08 12.05.00 AM 6172.0387459767
271 12-AUG-08 04.45.00 PM 6172.0387459767
271 12-AUG-08 04.50.00 PM 6172.038748687284 So if for instance I ran a query for July 30th, I'd need to actually get the result from July 22nd since it is the last valid number. PV_ID represents the instrument ID and INTEG_SINCE_VAL is the accumulated total for signal readings on that instrument.
Edited by: Solerous on Mar 16, 2009 7:23 AM
Edited by: Solerous on Mar 16, 2009 7:25 AMHi,
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as hr
SQL>
SQL> SELECT *
2 FROM (WITH data AS (SELECT 271 AS PV_ID,
3 (SYSDATE - 5) AS SMPL_DTE,
4 23 AS INTEG_SINCE_VAL
5 FROM dual
6 UNION ALL
7 SELECT 271 AS PV_ID,
8 (SYSDATE - 4) AS SMPL_DTE,
9 40 AS INTEG_SINCE_VAL
10 FROM dual
11 UNION ALL
12 SELECT 271 AS PV_ID,
13 (SYSDATE - 1) AS SMPL_DTE,
14 50 AS INTEG_SINCE_VAL
15 FROM dual)
16 SELECT data.*,
17 rownum
18 FROM data
19 WHERE PV_ID = 271
20 AND SMPL_DTE <= SYSDATE -- your date goes here
21 ORDER BY smpl_dte DESC)
22 WHERE rownum = 1;
PV_ID SMPL_DTE INTEG_SINCE_VAL ROWNUM
271 3/15/2009 1 50 3
SQL> Regards, -
Validation to find the Root Node !!!!
Hi All,
Is it possible to write a Validation to find the Root Node of the Hierarchy,
For E.g. If we have a three level hierarchy
Printer
Dot Matrix
T123
So is there a way I can check if my Root node value is Printer or not, because in Data Manager the value that is selected from the hierarchy drop down is the leaf node.
Regards,
ParulHi Jitesh,
The solution is as follows:
MDM does not give us the option to traverse to the grandparent of the leaf node..
In the example that we have taken :
Printer
- Dot Matrix
- Laser
--Laser1
--Laser2
Here if we want to check if the Grandparent of Laser1 is Printer, this cannot be done using the simple Validation, because through validation also we can at max find the parent of the current node i.e. we can traverse till Laser (for Laser 1 leaf node).
Further we cannot use Laser as the node because in MDM we have to traverse completely through the last node and select it in Data Manager. So again we cannot search for Laser -> Parent.
The Work Around that I have used is :
I have created a new field and every time I import data I have mapped this field with the first Level Node and have put the Validation on this field.
Eg: The field name is Root Node, so everytime the data is imported, Level 1 is mapped to Root Node and so all the Root node values are imported in the Root Node field that we have created and everytime the Validation Runs on this Root Node field and accordingly the process follows.
Hope that would be helpful to you all!!!!
Regards,
Parul Malhotra -
How to re-add the iPhone into the Find My iPhone and than to find the last known possition?
Hello,
I've got my iPhone stolen yesterday in the bar.
In the morning I tried find it by Find My iPhone app but I hit the "remove" button by mistake. Is it possible to reverse this acction even without the iPhone in the hand?
I need to re-add the iPhone into the iCloud (Find My iPhone) and than to find the last known possition. It's serial number is C3******39D
Thank you
Libor
<Edited bu Host>Ringtones are a one-time only download from the store. You will need to connect the device that you downloaded it on to your computer's iTunes and do File > Devices > Transfer Purchases to copy it over to the Tones part of your computer's iTunes library and you can then sync it to your other device(s).
-
'Could not find the requested node error' when guests join the meeting room
I am working on a program where the owner would allow guests after they knock to enter the meeting room. Upon acceptance, they would also be permitted to publish/subscribe audio.
My ' meeting owner' application code is an adaptation of the Knocking Queue example. The 'owner app' code has the following settings in its creation complete.
// Require that guests must knock.Note that this line changes the setting of your room so that in future anyone guest coming in
// has to knock.
cSession.roomManager.guestsHaveToKnock = true;
//Enable autopromote
cSession.roomManager.autoPromote =
true;
I get an error when the owner logins in first and accepts the guest into the meeting room.
// Event handler function for displaying the selected Alert button.
private function alertClickHandler(event:CloseEvent):void {
var queue:Array = pendingArray;
if ( cSession.userManager.myUserRole == UserRoles.OWNER ) {
var item:Object = pendingArray.shift();
trace (item["label"]);
trace (item["descriptor"].userID);
if (event.detail==Alert.OK)
//Admit user for chatting
cSession.roomManager.knockingQueue.acceptUser(item["descriptor"].userID);
//Allow user to publish audio - supposed to be promoted through room setting
//audioPub.setUserRole(item.descriptor.userID, UserRoles.PUBLISHER);
else //if (event.detail==Alert.CANCEL)
cSession.roomManager.knockingQueue.denyUser(item["descriptor"].userID);
The 'client' application throws the following error.
SWF] C:\Documents and Settings\a246216\My Documents\Flex Builder 3\Client Chat Tool\bin-debug\ClientChatTool.swf - 1,572,471 bytes after decompression
AFCS Beta Build # : 0.92
requestInfo http://connectnow.acrobat.com/fidelity2/ramr?guk=ZzprOg==&mode=xml&x=0.011843591462820768
Getting FMS at https://na2.connectnow.acrobat.com/fms?ticket=1468amkp7k35g, attempt #1/3
result: <fms>
<origin>fms2.acrobat.com</origin>
<proto_ports>rtmps:443</proto_ports>
<retry_attempts>2</retry_attempts>
</fms>
#FMSConnector# Tue May 12 11:26:50 GMT-0400 2009 protocols: [object ProtocolPortPair]
#FMSConnector# Tue May 12 11:26:50 GMT-0400 2009 [attempt 1 of 2] Connecting to 0/0: rtmps://fms2.acrobat.com/cocomo/na2-sdk-825d634c-46ed-4ed3-aa58-7450f0f7e36a/ramr #startProtosConnect#
#FMSConnector# Tue May 12 11:26:50 GMT-0400 2009 tempNetStatusHandler 0/1,NetConnection.Connect.Success
#FMSConnector# Tue May 12 11:26:50 GMT-0400 2009 isTunneling? false
#FMSConnector# Tue May 12 11:26:50 GMT-0400 2009 is using RTMPS? true
RECEIVED LOGIN AT SESSION
.user descriptor from server [object]
.displayName [string]= k
.userID [string]= GUEST-110858C2-4F16-4FE8-BF2C-D572F915FEC5
.affiliation [number]= 5
.role [number]= 5
RECEIVENODES UserManager
receiveAllSynchData UserManager
checkManagerSync:[object UserManager]
RECEIVENODES FileManager
receiveAllSynchData FileManager
checkManagerSync:[object FileManager]
RECEIVENODES AVManager
receiveAllSynchData AVManager
checkManagerSync:[object StreamManager]
RECEIVENODES RoomManager
receiveAllSynchData RoomManager
checkManagerSync:[object RoomManager]
RECEIVENODES Chat
receiveAllSynchData Chat
Error: Could not find the requested node.
at com.adobe.rtc.sharedModel::CollectionNode/getNodeConfiguration()[C:\work\main\connect\coc omoPlayer10\src\com\adobe\rtc\sharedModel\CollectionNode.as:394]
at com.adobe.rtc.sharedManagers::StreamManager/getNodeConfiguration()[C:\work\main\connect\c ocomoPlayer10\src\com\adobe\rtc\sharedManagers\StreamManager.as:577]
at com.adobe.rtc.collaboration::AudioPublisher/onUserRoleChange()[C:\work\main\connect\cocom oPlayer10\src\com\adobe\rtc\collaboration\AudioPublisher.as:1009]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.adobe.rtc.sharedManagers::StreamManager/onUserRoleChange()[C:\work\main\connect\cocom oPlayer10\src\com\adobe\rtc\sharedManagers\StreamManager.as:1410]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.adobe.rtc.sharedModel::CollectionNode/http://www.adobe.com/2006/connect/cocomo/messaging/internal::receiveCascadingUserRole()[C: \work\main\connect\cocomoPlayer10\src\com\adobe\rtc\sharedModel\CollectionNode.as:813]
at com.adobe.rtc.messaging.manager::MessageManager/http://www.adobe.com/2006/connect/cocomo/messaging/internal::receiveUserRole()[C:\work\mai n\connect\cocomoPlayer10\src\com\adobe\rtc\messaging\manager\MessageManager.as:715]
at com.adobe.rtc.session.managers::SessionManagerBase/receiveUserRole()[C:\work\main\connect \cocomoPlayer10\src\com\adobe\rtc\session\managers\SessionManagerBase.as:352]
The above error is thrown just when the 'guest' is accepted into the meeting room. The guest has not published anything at this point.
The chat part is working fine.
I have tried different ways to resolve this issue but I am not getting anywhere. I have tried different things. Your help is appreciated.
RamIt is win 7 64 bit system and same error on Illustrator x86 and x64.
-
Value of the start in the Select with in a Hierarchical Query
Exist any way for put in the select the value of the start with in a Hierarchical Query?
An example:
I'll need sth like
CTH@> select n code, level, np code_parent, 1 code_first_parent
2 from demo
3 start with n=1
4 connect by np = prior n
5 ;
CODE LEVEL CODE_PARENT CODE_FIRST_PARENT
1 1 1
2 2 1 1
3 3 2 1
4 4 3 1
5 5 4 1
6 6 5 1
7 7 6 1
8 8 7 1
9 9 8 1
10 10 9 1
-- Naturally it couldn´t be a constant value
The query
select n,d, level nivel
, np, prior n
from demo
start with n=1
connect by np = prior n
--Table and inserts
create table demo
( n number,
d varchar2(5),
np number);
insert into demo values (1,'A', null);
insert into demo values (2,'B',1);
insert into demo values (3,'C',2);
insert into demo values (4,'D',3);
insert into demo values (5,'E',4);
insert into demo values (6,'F',5);
insert into demo values (7,'G',6);
insert into demo values (8,'H',7);
insert into demo values (9,'I',8);
insert into demo values (10,'J',9);
insert into demo values (11,'K', null);
insert into demo values (12,'L',11);
insert into demo values (13,'M',12);
insert into demo values (14,'N',13);
insert into demo values (15,'O',14);
insert into demo values (16,'P',15);
Message was edited by:
cthOn 10g
connect_by_root(n)Best regards
Maxim -
How to find the last login details of a Sharepoint SSRS user
How to /where to find the last login details of SSRS sharepoint user. Is there any table where we can check the last login details of user. This is because we are facing an issue of Subscription failure due to Sharepoint token expiration. If user logs in
before 24 hours of his last login time, he is able to get his report subscription. If not, below error is thrown.
The permission granted to user 'domainname\username' are insufficient to perform this operation.Hi,
According to your post, my understanding is that you want to monitor the last login user’s details.
There is no out of the box way to achieve it in SharePoint.
We can use cookie to be a flag for checking whether there is an user just log in. After the page loaded, if the cookie is null, it suggests that there is an user just log in our site, then we
can get this user’s information using JavaScript Object Model and add the information into a custom list. With this list, we can monitor user’s login details.
Refer to the following link:
https://social.technet.microsoft.com/Forums/en-US/0cd4d531-cb61-4d90-aa70-413267f4a735/how-to-know-login-and-logout-details-of-a-user-in-sharepoint-online-2013?forum=sharepointdevelopment
Besides, here are two similar posts for your reference:
https://social.technet.microsoft.com/Forums/sharepoint/en-US/1a35283e-0f2a-49b8-b330-801a3cfcd890/programatically-get-all-current-logged-in-users-list-for-a-sharepoint-site?forum=sharepointdevelopmentprevious
https://social.technet.microsoft.com/Forums/en-US/10953be3-cb1c-40c7-9454-545c8338b551/how-to-know-login-users-count-and-their-details-in-sharepoint-2010-web-application?forum=sharepointgeneralprevious
Best Regards,
Lisa Chen
Lisa Chen
TechNet Community Support -
Hi,
How to find the last execution time of a program.
I do not find in ST03.
Can you please suggest me.
Thanks
HemaHI Hema,
Kindly donot open multiple threads on the same question the solution is already provided in this thread. Please close the thread if answered ..
Re: Find the last run of program
Regards<
Santosh -
Sir,how to find the last DML operations
Hi,
Please tell me how to find the last DML Operations at least minimum 30 queries.
Thanks in advance,Shared Pool is a memory location in SGA that contains SQL Statement that are submitted to Oracle for execution. This area is common to the entire database. Its not specific to user.
So what ever Unique SQL statement that is submitted to the SQL Engine will be available here. Shared Pool has a size limit. That is defined by the parameters SHARED_POOL_SIZE and SHARED_POOL_RESERVED_SIZE. So when the Shared pool becomes full the data needs to be removed from it. That is done in FIFO basis.
Oracle provides a visibility to this area through dictionary view V$SQLAREA. So this view will not only contain the SQL executed by you but also by every one. Even the one executed by oracle itself.
So in my opinion what you are asking is not possible to get. You must have some logging mechanism in your application to get this information. -
How to find the Last modified date and time of a package
Hi,
We need a clarification on how to find the Last modified date and time of a package in Oracle. We used the example below to explain our scenario,
Lets consider the following example
Let A, B be two packages.
Package A calls the package B. So A is dependent on B.
When A is compiled the TIMESTAMP,LAST_DDL_TIME in USER_OBJECTS gets updated.
Now there a modification in package B so it is compiled. There is no modification in package A.
Now when the package A is executed the TIMESTAMP,LAST_DDL_TIME in USER_OBJECTS gets updated but we did not make any change in Package A. Now we need to find last modified date and time of the package A . So we can not rely on the TIMESTAMP,LAST_DDL_TIME in USER_OBJECTS . Can u please tell us any other solution to get last modified date and time of the package A .
Regards,
Vijayanand.CHere is an example:
SQL> SELECT OBJECT_NAME,CREATED,LAST_DDL_TIME,TIMESTAMP,STATUS FROM USER_OBJECTS
2 WHERE OBJECT_NAME = ANY('A','B');
OBJECT_NAM CREATED LAST_DDL_TIME TIMESTAMP STATUS
A 20-MAY-2004 10:57:32 20-MAY-2004 10:57:32 2004-05-20:10:57:32 VALID
B 20-MAY-2004 10:58:22 20-MAY-2004 10:59:04 2004-05-20:10:59:04 VALID
SQL> CREATE OR REPLACE PROCEDURE A AS
2 BEGIN
3 NULL;
4 NULL;
5 END;
6 /
Procedure created.
SQL> SELECT OBJECT_NAME,CREATED,LAST_DDL_TIME,TIMESTAMP,STATUS FROM USER_OBJECTS
2 WHERE OBJECT_NAME = ANY('A','B');
OBJECT_NAM CREATED LAST_DDL_TIME TIMESTAMP STATUS
A 20-MAY-2004 10:57:32 20-MAY-2004 11:01:28 2004-05-20:11:01:28 VALID
B 20-MAY-2004 10:58:22 20-MAY-2004 10:59:04 2004-05-20:10:59:04 INVALID
SQL> EXEC B
PL/SQL procedure successfully completed.
SQL> SELECT OBJECT_NAME,CREATED,LAST_DDL_TIME,TIMESTAMP,STATUS FROM USER_OBJECTS
2 WHERE OBJECT_NAME = ANY('A','B');
OBJECT_NAM CREATED LAST_DDL_TIME TIMESTAMP STATUS
A 20-MAY-2004 10:57:32 20-MAY-2004 11:01:28 2004-05-20:11:01:28 VALID
B 20-MAY-2004 10:58:22 20-MAY-2004 11:01:53 2004-05-20:11:01:53 VALID
Note that the date under the column 'created' only changes when you really create or replace the procedure.
Hence you can use the column 'created' of 'user_objects'.
Maybe you are looking for
-
FLV content embedded in SWF not exporting correctly in In-Design CS6
Hi, I have an FLV video embedded within a SWF file. The FLV video plays correctly in the SWF file when exported or previewed. When the SWF is placed into In-Design CS6 and then exported as an interactive PDF, the SWF operates normally (buttons and pa
-
G/L account issue when goods issue against reservation
Genius, I manually created a reservation with movement type 201 and a G/L account which is difference from one defined in OBYC GBB-VBR. When I post goods issue by MB1A, I got the account from OBYC; But when I post it by MB26, I got another account ma
-
Firmware - Commonly Asked Questions
When Spiderman 3 was released on Blu-ray disc, a fairly large stir was created when it was discovered that the movie would not work correctly in all Blu-ray players. In most cases, players simply weren’t able to access many of the additional feature
-
hai friends, send me the coding for va01 in bdc using paging concept (multiple line items, using P+). thanks rahul
-
Class-maps used for load balancing on ACE
I am from CCS background and am trying to understand how the VIPs could be configured on an ACE module (using class maps). I am looking for specific information for the following : 1. Will each VIP have a corresponding Service-policy on the VLAN Inte