Select root hierarchical self-referential table record
Hellois there a quick way to select the folder in root of any given ID?
with t as (
select 1 as PID, null as PARENTID, 'Root 1' as DESCRIPTION from dual union all
select 2,1,'Sub 1.1' from dual union all
select 3,1,'Sub 1.2' from dual union all
select 4,null,'Root 2' from dual union all
select 5,4,'Sub 2.1' from dual union all
select 6,5,'Sub 2.11' from dual
)
select
???
from
t
where
t.PID = 6;
SQL> with t as (
2 select 1 as PID, null as PARENTID, 'Root 1' as DESCRIPTION from dual union all
3 select 2,1,'Sub 1.1' from dual union all
4 select 3,1,'Sub 1.2' from dual union all
5 select 4,null,'Root 2' from dual union all
6 select 5,4,'Sub 2.1' from dual union all
7 select 6,5,'Sub 2.11' from dual
8 )
9 select pid , CONNECT_BY_ROOT pid root_node
10 from t
11 where pid = &a
12 start with parentid is null
13 connect by prior pid = parentid
14 /
Enter value for a: 6
old 11: where pid = &a
new 11: where pid = 6
PID ROOT_NODE
---------- ----------
6 4
SQL> /
Enter value for a: 5
old 11: where pid = &a
new 11: where pid = 5
PID ROOT_NODE
---------- ----------
5 4
SQL> /
Enter value for a: 3
old 11: where pid = &a
new 11: where pid = 3
PID ROOT_NODE
---------- ----------
3 1
SQL> /
Enter value for a: 2
old 11: where pid = &a
new 11: where pid = 2
PID ROOT_NODE
---------- ----------
2 1
SQL> /
Enter value for a: 1
old 11: where pid = &a
new 11: where pid = 1
PID ROOT_NODE
---------- ----------
1 1
Published by: Karthick_Arp on January 20, 2009 04:39
Tags: Database
Similar Questions
-
Help of query output: display self-referential table
Hello
I'm trying to display a table referring to itself in a cfoutput. I'll start by showing some of the data in the table.
There are only 3 columns, pl_id (auto increment id pri - keys), pl_name and pl_parent_id (0 if it is a parent, otherwise it is the value of pl_id for the parent).
pl_id pl_name pl_parent_id
1 country 0
Food 2 0
3. WE 1
4 Japan 1
5 Burger 2
6 Idaho 3
Florida 7 3
8 cheese 2
What I am trying to output is something like this:
Country - United States - Idaho (3 levels here) or
Country - United States - Florida (or if there are only 2 levels as the following line)
Food - cheese
I tried using a cfoutput with a cfloop as well as grouping but does not have a chance. Could someone clear my head on this one?
Thank you very much
Joe
PS. Adobe should really use a police fixed-width for these forums, it is impossible to align the table info!Well Yes, who do. After you have changed a little this puppy will be completed. Thanks to the people who reduced to chips in this thread.
-
Firefox fails to submit form self-referential unless I wait 20-30 seconds.
EDIT: (the solution ended up being, against all odds, that everything was actually perfectly fine. He has been the host - which was ruin it. Note to everyone who comes through this: GoDaddy is terrible for hosting. The same files, downloaded to real Web host like SourceForge, work perfectly well. What GoDaddy can possibly fail, I can't even imagine.)
I have created a self-referential form (POST method) in PHP for lead a user through the complicated branching calculation process. I load the PHP in Firefox 3.6 and it is indeed and I do the first communication and which works very well. But if I do another presentation quickly (within seconds), instead of working, he submits to itself with no field, so I will be the first return page once again, and no matter what I do, he keeps submitting with no field. If I can not recharge the original PHP file by POST and redo the first presentation, the first communication works again and the second fails again.
However, if I do the first presentation and then sit there doing absolutely nothing for maybe 20-30 seconds and then do the second presentation, this works perfectly well. If I wait one more time, the third presentation works; otherwise, he says as the first, with no field and messes.
I tried with and without the HTTP headers to prevent caching, without effect.
Any ideas what's happening?
Edit: (And, to be clear, if I change my POST GET method method, it works perfectly every time. But given the data appear in the URL is confusing and problematic for users, but also seriously complicate the process of bookmarking if the user decides to the computing environment to make a bookmark. The bookmark must be at the beginning of the calculation, not in the Middle, because the calculation is sensitive to time, so the old data are useless and should not be replicated.)
A good place to ask questions and advice on web development is the Forum MozillaZine Web Standards Development/evangelism.
Aid to this forum are better informed on issues related to web development.
You must register on MozillaZine forum site to post in this forum. -
Select the data in a table and update in another table
Dear experts,
create the table TB_ENCRYPT
(
Identification number,
Varchar2 (200) KEY
);
INSERT INTO TB_ENCRYPT VALUES(1,'HJUVHDUIFBSDGVU');
SELECT * FROM TB_ENCRYPT;
1 HJUVHDUIFBSDGVU
create TABLE users)
username, NUMBER of
password VARCHAR2 (200)
);
Insert users
values (1, 123 # "")
Insert users
values (2, 456 #')
Select * from users;
1 123 #.
# 2 456
I want to select the data KEY for table TB_ENCRYPT column and update in the column of tables for the respective key user password
TB_ENCRYPT table contains only a single key value. Comparing this key, I want to update the old value of the key to the new value.
For encryption and decryption I followed the java class method.no is worried about that.
create or replace
PACKAGE PCK_ENC AUTHID CURRENT_USER AS
FUNCTION DECRYPT (VARCHAR arg0, arg1 VARCHAR) AS VARCHAR BACK LANGUAGE JAVA NAME 'Encrclass.decrypt (java.lang.String, java.lang.String) return java.lang.String ';
FUNCTION ENCRYPT (VARCHAR arg0, arg1 VARCHAR) AS VARCHAR BACK LANGUAGE JAVA NAME 'Encrclass.encrypt (java.lang.String, java.lang.String) return java.lang.String ';
END;
SELECT PCK_ENC. ENCRYPT('1234','HJUVHDUIFBSDGVU') FROM DUAL;
HERE,
1234 - is the password of the users table column data
HJUVHDUIFBSDGVU - represents the key of table TB_ENCRYPT column data.
Comparing this key, I want to update the old value of the key to the new value.
I tried with this method
declare
cursor c1 is
Select the key
of TB_ENCRYPT
where id = 1
update the id;
Start
for c1_rec looping c1
update users
password is PCK_ENC. Encrypt (Password, Key)
the location being c1;
commit;
end loop;
end;
/
Help, please
You can use the MERGE statement.
merge into users using tb_encrypt on (id = userid) when matched then update set password = PCK_ENC.ENCRYPT(password,key);
And why you encrypt your password. This isn't a good idea. Just password hash.
-
How to select all text in a table with a single click cell?
How to select all text in a table with a single click cell? I use TextField.selectAll () when you implement a table cell factory. But when I select a line with a single click, then a click on a table cell again: see the result image
The text in the table cell is not all selected. What I simply selects all the text in a table cell when there is a click on it. How to realize that? Thank you
Thanks for help ~.
-
self-referential attribute: how to set the value if it is /inconnu
Hello
I get the following error while checking the logic loop:
self-referential attribute: b5@Rules_test_doc
number of rules in this loop: 3
number of attributes in the string in loop: 3
number of links in the chain loop: 0
The rules engine will begin with information from a database.
My requirement is to define a value for the attribute (X) = 'ABC' if (X) is null and (Y) 0
(10.4 null is represented by unknown)You will need to have an intermediate field here to achieve. It's certainly a logic in terms of the OPA loop, as you try to use X to prove the X.
You need to do to resolve the issue:attribute (X) = 'ABC' if (X_input) is null and (Y) 0
Or for an example of "true":
Office of the person:
------------------------------------
"london" | Office provided the person is currently unknown
the person is provided to the office. in the opposite caseSo if no office treatment was provided by the database (i.e. ' null') it is by default effectively in London.
You can then use "Office of transformation of the person" as normal during menstruation, confident that he should never be unknown.See you soon,.
BenPublished by: Ben Rogers on 8 January 2013 13:28
-
cannot select data in a nested table?
why we cannot select data in a nested table?
DECLARE TYPE MY_ARR IS TABLE OF VARCHAR2(15); IDArr MY_ARR; BEGIN IDArr := MY_ARR(); select ename into IDArr from emp; END; /
806540 wrote:
why we cannot select data in a nested table?DECLARE TYPE MY_ARR IS TABLE OF VARCHAR2(15); IDArr MY_ARR; BEGIN IDArr := MY_ARR(); select ename into IDArr from emp; END; /
It also isn't a such thing as a ' + nested table + "-despite what the documentation calls them. The CORRECT term is the table. Since the dawn of programming. And called 'paintings' in many languages of programming and data structure theory ever since.
In Oracle, the term "table" has a very precise meaning. A table in PL/SQL language nothing BUT a table at all. A completely different data structure that does not have the characteristics of an Oracle table.
The code you wrote is also dangerous. If there are 100,000 rows in this table, you will copy all 100,000 rows in a PL/SQL table - that resides in the memory of the very expensive server called the PGA (process private memory). You can cause a serious impact on the memory of the server with this approach of poor quality - I saw such a code crashing the production servers.
So let's not terminology. Is the wrong approach. Code is wrong.
So why not rather tell us what you're doing, or trying to understand, instead?
-
Several feature selection to row in the table
Hello
I have a group with the style of layout table and I want to set the the "multiple" generated table rowSelection property but it seems there is no way to do unless you are using the group as LOV, which is not desirable for me to JHs. The following code shows how to set this property in tableGroup.vm:
#if (! ($JHS.current.group.useAsLov & & $JHS.current.group.multiSelect))
selectionListener = "#{#BINDINGS_TABLE (). collectionModel.makeCurrent}.
rowSelection = 'single '.
#if (! $JHS.current.group.useAsLov)
selectedRowKeys = ' #{#TABLE_BEAN () .selectedRow} ".
#end
#else
rowSelection = "multiple".
selectedRowKeys = ' #{#LOV_PAGE_BEAN () .selectedRowKeySet} ".
selectionListener = "#{#LOV_PAGE_BEAN () .selectionListener}".
#end
Is there a reason for not allowing to have several feature selection of line in the table when it is not in mode LOV?
Thank you
Will doWill do,
No, but if you want to have multiple selection, there is typically a custom action that you want to apply to selected lines, which cannot be defined in the Jheadstart Application definition editor.
However, it is perfectly well use a custom template tableGroup.vm and allow multiple selection.Steven Davelaar,
JHeadstart team. -
Select the row in the table to change
I added this line on my table view
< af:commandLink text = "#{viewcontrollerBundle.CONTINUE}" id = "cl1" action = 'download-plan' > "
"< f: param value =" "name =" "id ="p1"/ >
< / af:commandLink >
so when I clicked another page opens to display the selected line
My question is how can I get the value of the selected line in the edit pageCheck this box
[url http://blogs.oracle.com/shay/entry/selecting_a_row_in_a_table_to] Select a field in a Table to move to another Page -
Selection of data in the table in a table
I use apex 3.2
I have a report where he returnts say 3 rows.
I need to select data from a table in and table and then use the data in this table in a body of email
or select the data in the table and use the data in the body of the sub form of e-mail
How can I do this. ?
something like below
Empno name e-mail address
1 XX [email protected]
2 bb [email protected]
3 [email protected] aaHello
You can take the values in the table in the cursor and use it in the part of the email.
It will be like,Cursor c1 is
Select Empno, emp email;In the part of the body
Hardcode the values of the columns inside html tags
l_body: = '
'; ';EmpNo I'm in c1
loop
l_body: = l_body | » ';i.EmpNo i.Name i.email
end loop;
l_body: = l_body | »then use the variable 'l_body' inside your share email.
I hope this helps.
Kind regards
LIBERATOR -
Highlight on the selected line disappear when af:table lose focus?
Hello
I have a strange problem:
I have an af:table select single line based on the VO and an af:inputText in a jsf page.
When I select a row in the table, then click on in the inputText at the entrance, the highlight on the selected line in the table disappear!
The currently selected line is always a controlled beans, but it seems that it is not that any line is selected in the user interface.
Is this a bug of af: table?
My test page:
< af:form id = "f1" >
< af:panelGroupLayout id = "pgl1" layout = "scroll" >
< af:table value = "#{bindings." Var ViewObj1.collectionModel}"="row ".
lines = ' #{bindings. " ViewObj1.rangeSize}.
emptyText = "#{bindings." ViewObj1.viewable? "{'No data to display.': 'Access Denied.'}".
fetchSize = "#{bindings." ViewObj1.rangeSize}.
rowBandingInterval = '0 '.
selectedRowKeys = ' #{bindings. " ViewObj1.collectionModel.selectedRow}.
selectionListener = "#{bindings." ViewObj1.collectionModel.makeCurrent}.
rowSelection = "single" id = "t1" >
< af:column sortProperty = "EmpDeptid" sortable = "false".
headerText = "#{bindings." ViewObj1.hints.EmpDeptid.label}.
ID = "c8" >
< af:outputText value = "#{rank." EmpDeptid}"id ="ot3">
< af:convertNumber groupingUsed = "false".
model = ' #{bindings. " ViewObj1.hints.EmpDeptid.format}"/ >
< / af:outputText >
< / af:column >
< af:column sortProperty = "EmpHireDate" sortable = "false".
headerText = "#{bindings." ViewObj1.hints.EmpHireDate.label}.
ID = 'c4' >
< af:outputText value = "#{rank." EmpHireDate}"id ="ot7">
< af:convertDateTime pattern = "#{bindings." ViewObj1.hints.EmpHireDate.format}"/ >
< / af:outputText >
< / af:column >
< af:column sortProperty = "EmpId" sortable = "false".
headerText = "#{bindings." ViewObj1.hints.EmpId.label}.
ID = "c7" >
< af:outputText value = "#{rank." EmpId}"id ="ot6"/ >
< / af:column >
< af:column sortProperty = "EmpJob" sortable = "false".
headerText = "#{bindings." ViewObj1.hints.EmpJob.label}.
ID = "c1" >
< af:outputText value = "#{rank." EmpJob}"id ="ot1"/ >
< / af:column >
< af:column sortProperty = "EmpLineid" sortable = "false".
headerText = "#{bindings." ViewObj1.hints.EmpLineid.label}.
ID = "c5" >
< af:outputText value = "#{rank." EmpLineid}"id ="ot4">
< af:convertNumber groupingUsed = "false".
model = ' #{bindings. " ViewObj1.hints.EmpLineid.format}"/ >
< / af:outputText >
< / af:column >
< af:column sortProperty = "EmpSex" sortable = "false".
headerText = "#{bindings." ViewObj1.hints.EmpSex.label}.
ID = "c6" >
< af:outputText value = "#{rank." EmpSex}"id ="ot2"/ >
< / af:column >
< / af:table >
< af:panelFormLayout id = "pfl1" >
< f: facet = 'footer' name / >
< af:inputText label = "Label 1" id = "it1" / >
< / af:panelFormLayout >
< / af:panelGroupLayout >
< / af:form >
Thank you
660Hello
This seems an expected behavior of the skin of the merger.
The selected line inactive thoroughly clear yellow that is hard to recognize on some screens.solution:
create a custom look (extend the skin of 'fusion') and create css, like this:
AF | : the table-row data: selected: inactive af | : given the column cell.
AF | : the table-row data: selected: inactive af | column: banded-data-cell
{
background-color: blue;
}concerning
PeterPublished by: hofespet on November 6, 2010 12:45
-
How to use the checkbox to select several lines of af: table
Hi all
I want to use the checkbox to select several lines of af: table
Kind regards
TomHello
look at this link
http://Sameh-Nassar.blogspot.com/2009/12/use-checkbox-for-selecting-multiple.htmlKind regards
Felix -
[JS] select multiple rows in a table
Hi guys,.
Is it possible to select several lines in a table? If I pass a reference table of the lines to the app.select () method, it fails.
For that which is ok, but not for two or more. The lines are next to that them not chnge a thing.
var t = ....tables[0] //a given reference to a table app.select([t.rows[1], t.rows[2], t.rows[3]]) //Error > Expected array of objects but received (Row,Row,Row)
App.Select(t.Rows[1]) works very well. But when I want to select multiple lines, that is not.
Any advice?
TIA Loïc
Hey!
Try selecting each line separately:
var myT = app.selection[0].tables[0]; myT.rows[0].select(); myT.rows[1].select(SelectionOptions.ADD_TO);
tomaxxi
-
We had some mistakes the last few nights in our test database, during our DataPump to export every night. One by evening, different tables, but the two errors like:
I've never seen something like this before, and a Google search was not terribly useful. Any ideas what's happening?select * from relational(<schema>.<table>)
Thank you
-= Chuckchuckers wrote:
DB version: 10.1.0.4
OS: Red Hat Enterprise Linux AS release 4 (Nahant Update 8) 2.6.9 89.0.16.ELsmp (64-bit)The error was an ORA-01555 snapshot too old.
You hit 3654707 Bug ? Please check.
-
This seems to be a simple problem, but I think that I have enough intelligence SQL to solve.
I have a table called DE_DOMAIN. The columns of interest are:
DOMAIN_ID - PK
NAME
PARENT_ID - FK (can be NULL), poining to CF of the parent
What I want is: Returns a hierarchical list, containing: column 3 above as well as the NAME of the parent.
Regardless of the name of the parent, it works fine:
SELECT DOMAIN_ID, PARENT_ID, level
OF DE_DOMAIN
WHERE SUPERDOMAINE = 2673
Start by PARENT_ID IS NULL
Connect DOMAIN_ID PARENT_ID = prior
BROTHERS AND SŒURS ORDER BY NAME ASC
and I get:
11 rec_11 1 Null
15 rec_15 1 Null
16 1 Null rec_16
17 1 Null rec_17
22 17 2 rec_22
1 2 17 rec_1
rec_25 25 17 2
2 2 17 rec_2
i.e. records with PK = 1, 22, 25, 2 have all like parent record with PK = 17, then the new column name, they must bear the name of the parent (i.e. rec_17).
A simple idea?
Thank you very much.Hello
You can use the FIRST operator in the SELECT clause.
I don't have a version of your table, so I'll use scott.emp to illustrate:SELECT empno , ename , mgr , PRIOR ename AS mgr_name FROM scott.emp START WITH mgr IS NULL CONNECT BY mgr = PRIOR empno ORDER SIBLINGS BY ename ;
Output:
. EMPNO ENAME MGR MGR_NAME ---------- ---------- ---------- ---------- 7839 KING 7698 BLAKE 7839 KING 7499 ALLEN 7698 BLAKE 7900 JAMES 7698 BLAKE 7654 MARTIN 7698 BLAKE 7844 TURNER 7698 BLAKE 7521 WARD 7698 BLAKE 7782 CLARK 7839 KING 7934 MILLER 7782 CLARK 7566 JONES 7839 KING 7902 FORD 7566 JONES 7369 SMITH 7902 FORD 7788 SCOTT 7566 JONES 7876 ADAMS 7788 SCOTT
Maybe you are looking for
-
laptop suddenly stops when some startup programs.
When I run certain Adobe programs like photoshop (illustrator and indesign works fine however) and competitor Autodesks Revit, software Archicad and Artlantis 3D works great. My Pavilion m6-1040eo turns suddenly, the screen becomes dark powerbutton g
-
MAX: Fehler bei der zur data base connection
Hallo, ICH habe ein problem mit NI MAX. Es scheint die nimxs.exe zu breast beschadigt. Nach dieser Fehlermeldung NI MAX nicht mehr gestartet werden kann. ES geht nicht mehr über die Initialisierung headed. Die Fehlermeldung participations beim der na
-
Is it possible to have full control for all users in the directory/files/registry?
Can I have a lot of control (read, write, change) my specific file / registry for all users, you have any program or script for this reason? as 'cacls '. Because I can't use cacls. is it wrong? C:\>Cacls "program * Files\NETAS" / c/r users: «F»»» Dis
-
Upgrading a HDD in Touchsmart 300
Can I replace the original (ST31000528AS) with a hybrid of Seagate (ST1000DX001) hard disk. I have to replace the original failed disk and want to update, if possible.
-
Photosmart 6525: HP Solution Center does not work in Win 10
I hava 6525 Photosmart all-in-One printer. I just updated my OMNI from Windows 7 to Windows 10 desktop all-in-one computer and and now the HP Solution Center will not work. I get 'HP Solution Center cannot work because your installation of the devi