the list of columns separated by commas of a dictionary table table
I use the following question.CONNECT_BY_ROOT SELECT table_name TopLevel, level,
connect_by_isleaf IS_Node_leaf,
substr (SYS_CONNECT_BY_PATH (column_name, ','), 2) column_name
Of all_tab_cols
where connect_by_isleaf = 1
and column_id < (select max (column_id) + 1 all_tab_cols
where table_name = 'Table_test')
and column_id > (select min (column_id) - all_tab_cols 1
where table_name = 'Table_test')
START WITH table_name = "Table_test."
CONNECT BY PRIOR column_id = nocycle (column_id - 1).
AND table_name = "Table_test."
The only problem with this query is that it goes into infinite loop. Can someone suggest a better solution?
Why you ask all_tab_cols, I think will realize you that it will pull all tables in your database.
If you want to retrieve the name of the table and the columns (separated by commas) your schema, you must query user_tab_cols.
and here is the sql code
select table_name,ltrim(sys_Connect_by_path(column_name,','),',') column_names
from
(select table_name,column_name,row_number() over (partition by table_name order by column_id) rn
from user_tab_cols)
where connect_by_isleaf = 1
start with rn=1
connect by prior rn=rn-1 and prior table_name = table_name
/
Or, you can use all_tab_cols to query a specific table by passing the name of the table and the name of the owner
PRAZY@11gR1> desc test
Name
-------------------------------------------
NUM
NUM2
PRAZY@11gR1>
select table_name,ltrim(sys_Connect_by_path(column_name,','),',') column_names
from
(select table_name,column_name,row_number() over (partition by table_name order by column_id) rn
from all_tab_cols
where owner='PRAZY' and
table_name = 'TEST')
where connect_by_isleaf = 1
start with rn=1
connect by prior rn=rn-1 and prior table_name = table_name
/
PRAZY@11gR1> /
TABLE_NAME COLUMN_NAMES
------------------------------ ----------------------------------------
TEST NUM,NUM2
Elapsed: 00:00:00.01
HTH,
Prazy
Published by: Prazy on April 28, 2010 10:23
Tags: Database
Similar Questions
-
Display data in the form of values separated by commas - need help
Hi all
I have some data formatted in the way below. The ID of the drug are the primary keys of the table and the first 9 digits in the drug ID are the same. They can be separated based on the last two digits.
Type of drug drug ID
00603107554 respiratory
00603107556 cough and cold
Antitussive-00603107558
I want that data to be formatted as
Type of drug drug ID
006031075 respiratory, cough and colds, Antitussive
I want to cut the last two characters, and format data. And the types must be displayed in the form of values separated by commas. Can someone help me?
Thanks in advance
RambeauWITH t AS (SELECT '00603107554' Drug_ID, 'Respiratory' Drug_Type FROM DUAL UNION SELECT '00603107556', 'Cough and Cold' FROM DUAL UNION SELECT '00603107558', 'Antitussive' FROM DUAL) SELECT Drug_id, SUBSTR (SYS_CONNECT_BY_PATH (Drug_Type, ','), 2) Drug_Types FROM (SELECT SUBSTR (drug_id, 1, LENGTH (drug_id) - 2) drug_id, Drug_Type, ROW_NUMBER () OVER (PARTITION BY SUBSTR (drug_id, 1, LENGTH (drug_id) - 2) ORDER BY Drug_Type) rn FROM t) WHERE CONNECT_BY_ISLEAF = 1 START WITH rn = 1 CONNECT BY PRIOR rn = rn - 1 AND PRIOR drug_id = drug_id
DRUG_ID DRUG_TYPES 006031075 Antitussive,Cough and Cold,Respiratory
just a note, I wonder if blushadow could consider adding techniques agg string to its very useful faq section because it seems a good
request.Published by: pollywog on April 14, 2011 06:42
Published by: pollywog on April 14, 2011 06:43
-
Display values in the columns separated by commas.
Hello world
Table 1
col1 col2 ID1 Name1 ID2 name2 ID3 Name3 Table 2
col1 col2 RQ1 1 RQ2 3, 2 rQ3 2, 3 Result table
col1 col2 RQ1 Name1 RQ2 Name2, Name3 rQ3 name2, Name3 Based on table 1 and table 2 to create a view to produce a result array.
Ideas experts!
Little things...
First of all, given in TABLE1. Col1 stores values as ID1, ID2... But the associated column in TABLE2. Col2 stores the value in the form 1, 2... Is this correct? Then, the data into TABLE2. Col2 is not the right way to store your data. TABLE2 is not standardized. And it is a very bad way to design a database.
Says you can try this solution here I Unpivot firstly the list of values in TABLE2. Col2 in lines and then enclose it with TABLE1 and finally make an aggregation of chain. It is a solution prior 11g. If you are on 11g and above, you can use functions like UNPIVOT and LISTAGG wisely.
with table1
as
(
Select "id1" col1, col2 "Name1" Union double all the
Select "id2" col1, col2 "Name2" Union double all the
Select 'id3' col1, col2 "Name3" of the double
),
Table2
as
(
Select "rq1" col1, col2 '1' of any Union double
Select "rq2" col1, col2 '3.2' of any union double
Select "rq3" col1, col2 '2.3 ' double '.
)
table2_expand
as
(
Select col1
, regexp_substr (col2, ' [^,] +', 1, level) col2
level lvl
from table2 t2
connect
by level<= length(col2)="" -="" length(replace(col2,="" ','))="" +="">=>
and col1 = col1 prior
and prior sys_guid() is not null
)
Select col1, ltrim (sys_connect_by_path (col2, ',') ',') col2
BeO
Select t2.col1, t1.col2, row_number() over NWR (partition by order of t2.col1 of t2.lvl)
FROM table1 t1
Join the t2 table2_expand
on t1.col1 = 'id ' | T2.col2
)
where connect_by_isleaf = 1
beginning
with rno = 1
connect
by rno = prior rno + 1
and col1 = col1 prior
-
Hi, need help with the following:
CREATE TABLE tbl_1 ( rec_id NUMBER(9), col1 NUMBER(9), col2 NUMBER(9), col3 NUMBER(9), col4 NUMBER(9)) / CREATE TABLE tbl_2 ( rec_id NUMBER(9), col1 NUMBER(9), col2 NUMBER(9), col3 NUMBER(9), col4 NUMBER(9), col5 NUMBER(9), col6 NUMBER(9)) / INSERT INTO tbl_1 VALUES (101, 11, 21, 31, 41); INSERT INTO tbl_1 VALUES (102, 12, 22, 32, 42); INSERT INTO tbl_1 VALUES (103, 13, 23, 33, 43); INSERT INTO tbl_1 VALUES (104, 14, 24, 34, 44); INSERT INTO tbl_2 VALUES (101, 1, 1, 1, 1, 1, 1); INSERT INTO tbl_2 VALUES (102, 1, 1, 1, 1, 1, 1); INSERT INTO tbl_2 VALUES (103, 1, 1, 1, 1, 1, 1); INSERT INTO tbl_2 VALUES (104, 1, 1, 1, 1, 1, 1); INSERT INTO tbl_2 VALUES (105, 1, 1, 1, 1, 1, 1); COMMIT ; --Create procedure pr_upd(col_list) passing list of columns which has to be updated in TBL_2 with values from TBL_1 --for example if pr_upd ('col1,col3' ) called then only col1 and col3 updated in tbl_2 (with values from TBL_1) --After procedure pr_upd ('col1,col3' ) called: SELECT * FROM TBL_2 REC_ID COL1 COL2 COL3 COL4 COL5 COL6 101 11 1 31 1 1 1 102 12 1 32 1 1 1 103 13 1 33 1 1 1 104 14 1 34 1 1 1 105 1 1 1 1 1 1
You will need to use dynamic SQL statements. Something like
CREATE OR REPLACE PROCEDURE pr_upd( p_col_list in varchar2 ) AS l_sql varchar2(1000); BEGIN l_sql := 'UPDATE tbl_2 ' || ' SET (' || p_col_list || ') = ' || ' (SELECT ' || p_col_list || ' FROM tbl_1 ' || ' WHERE tbl_1.rec_id = tbl_2.rec_id )' || ' WHERE EXISTS ( ' || ' SELECT 1 ' || ' FROM tbl_1 ' || ' WHERE tbl_1.rec_id = tbl_2.rec_id )' ; EXECUTE IMMEDIATE l_sql; END;
which product
SQL> CREATE OR REPLACE PROCEDURE pr_upd( p_col_list in varchar2 ) 2 AS 3 l_sql varchar2(1000); 4 BEGIN 5 l_sql := 6 'UPDATE tbl_2 ' || 7 ' SET (' || p_col_list || ') = ' || 8 ' (SELECT ' || p_col_list || 9 ' FROM tbl_1 ' || 10 ' WHERE tbl_1.rec_id = tbl_2.rec_id )' || 11 ' WHERE EXISTS ( ' || 12 ' SELECT 1 ' || 13 ' FROM tbl_1 ' || 14 ' WHERE tbl_1.rec_id = tbl_2.rec_id )' ; 15 EXECUTE IMMEDIATE l_sql; 16 END; 17 / Procedure created. SQL> exec pr_upd ('col1,col3' ); PL/SQL procedure successfully completed. SQL> select * from tbl_2; REC_ID COL1 COL2 COL3 COL4 COL5 COL6 ---------- ---------- ---------- ---------- ---------- ---------- ---------- 101 11 1 31 1 1 1 102 12 1 32 1 1 1 103 13 1 33 1 1 1 104 14 1 34 1 1 1 105 1 1 1 1 1 1 SQL>
Justin
-
Result may contain the unique string or separated by commas must split into lines
Hi all... I searched through the forums and found a lot on separation with commas in lines; Although I'm fighting apply to my situation. I have data that looks at the below where I need to divide a value in several lines if she should be, but the same field in the table may also contain a string which should not be separated (indicated by the field 'Array' be 0 or 1)...
I looked through several of the connect_by on the forum posts, and I've not met one that divides a field if it should be, but not if it is not... maybe missed it because there are a lot of these requests on the forum!WITH t AS (SELECT 1 as array, '"Banana", "Apple", "Pear"' as str FROM dual union all SELECT 0, 'Fruit is delicious' FROM dual union all SELECT 0, 'So are vegetables' FROM dual union all SELECT 1, '"Bean", "Carrot", "Broccoli"' FROM dual union all SELECT 1, '"Apple", "Banana"' FROM dual)
If you are feeling more ambitious - the ultimate goal is to count the number of times where an answer appears in a table - view up to the last part of the data contain 'Apple', 'Banana'... the result are:
I can always sort more later from the other fields in the table - but the result above would be my ultimate goal!RESULT ---------- Banana 2 Apple 2 Pear 1 Bean 1 Carrot 1 Broccoli 1 Fruit is delicious So are vegetables
Any help is always appreciated. Thank you! 31%
-
Oracle 10.2.0.1
Windows XP
I have a table that stores the data of our customers. When I said:
Select city, city_code as CS, count (*) as the early group of customers by city, city_code:
It returns:
Power required:CITY CS TOT ---------------------------------------- -- ---------- Delhi 01 23 Bangalore 02 36 Mumbai 03 33 Hyderabad 04 8 Jaipur 00 2 Patna 00 1 Chennai 05 114
Means that if Tot for a city is between 1,5; I want to get these IDS to customer (from the customer table itself)CITY CS TOT IDS ---------------------------------------- -- ---------- ---------------------- Jaipur 01 2 393,405 Patna 02 1 200
separated by commas as above, so that I can know who are the customers, because all the
cities whose number is < = 5, there are errors in the name of the city.
Thank you.NOT TESTED! not having do not have database access
select city,city_code,tot,substr(sys_connect_by_path(to_char(customer_id),','),2) ids from (select c.customer_id,c.city,c.city_code,e.tot, row_number() over (partition by c.city,c.city_code order by customer_id) the_row from customers c, (select city,city_code,count(*) tot from customers group by city,city_code having count(*) <= 5 ) e where e.city = c.city and e.city_code = c.city_code ) where connect_by_isleaf = 1 start with the_row = 1 connect by prior the_row + 1 = the_row and prior city = city and prior city_code = city_code and prior tot = tot
Concerning
Etbin
-
When I right click on the list box column Multi that I should get the custom options
Hi all
In my application, I want to display the custom user menu when it right-click on the Multi column list box. I want to know is - it possible to do like this. Please can someone help me on this?
in abow picture I get "reset default value, cut, copy the data, past data" so I need to set other options.
Kind regards
Santhosh M
Hi santosh,.
This one is much better.
-
type in the list of columns SCRIPTUI
Hi guys,.
I have a terminology database that I created and I would like to add a feature that allows users to type in the edittext field to search for items in col1.
Here is my code for the columns and the edittext field:
var column = w.add('group{multiselect:true}');
Columns.Spacing = 0;CGEM var = [0,0,200,600];
var col1 = columns.add ("listbox", CGEM, ["Dorsiflexion", "Field", "Trans-tibiale", "Trans-fémorale"]);
var col2 = columns.add ("listbox", CGEM, ["Dorsiflexion", "Field", "Party", "Transfémoral"]); French
var col3 = columns.add ("listbox", CGEM, ["Dorsiflexion", "Field", "Trans-tibiale", "Trans-fémorale"]); German
var col4 = columns.add ("listbox", CGEM, ["Dorsiflexion", "Field", "Transtibial", "Transfemorale"]); Italian
var col5 = columns.add ("listbox", CGEM, ["Dorsiflexion", "Field", "Party", "Security"]); Spanish
var col6 = columns.add ("listbox", CGEM, ["Dorsiflexion", "Field", "Trans-tibiale", "Trans-fémorale"]); Norwegian
col7 var = columns.add ("listbox", CGEM, ["Dorsiflexion", "Field", "Trans-tibiale", "Trans-fémorale"]); Russian
var col8 = columns.add ("listbox", CGEM, ["Dorsiflexion", "Field", "Trans-tibiale", "Trans-fémorale"]); Turkish
col1. Selection = 0;{col1. OnDoubleClick = Function ()}
entry. Text = col1. Selection;
};
{col2. OnDoubleClick = Function ()}
entry. Text = col2. Selection;
};
{Col3.OnDoubleClick = Function ()}
entry. Text = Col3.Selection;
};
{Col4.OnDoubleClick = Function ()}
entry. Text = Col4.Selection;
};
{col5. OnDoubleClick = Function ()}
entry. Text = col5. Selection;
};
{col6. OnDoubleClick = Function ()}
entry. Text = col6. Selection;
};
{col7. OnDoubleClick = Function ()}
entry. Text = col7. Selection;
};
{COL8. OnDoubleClick = Function ()}
entry. Text = COL8. Selection;
};var user_input = w.add ('group')
entry var = user_input.add ("'edittext', dimH, ' click on the button to the right to convert lowercase");
entry. Characters = 30;
entry. Alignment = 'left';
entry.active = true;converting the vars = user_input.add ('button', undefined, "Convert to lowercase");
convert.onClick = function () {entry.text = entry.text.toLowerCase () ;}
user_input.orientation = 'row';
user_input. Alignment = 'left';Everyone here is so helpful.
Thank you
Jake
There are some examples of upcoming type here:
https://INDD.Adobe.com/view/a0207571-ff5b-4bbf-A540-07079bd21d75
Moreover, the group object is the multiselect property.
Peter
-
highest value in columns separated by commas
I have a table with data as shown below
trx_numbers trx_dates trx_ref
01616145/01616332/01616459 2014-11-13/2014-11-19/2014-11-24 2014090001 01616145/01616332/01616459 2014-11-13/2014-11-19/2014-11-24 2014120768 I need a sql to extract higher and corresponding date for each trx_ref
in the example above: 2014090001 - 2014-11-24 - 01616459
First advice would be to build something like a decent datamodel...
To solve your problem with your 'model', you could do (ORACLE 11.2):
WITH the DATA (trx_numbers, trx_dates, trx_ref)
AS (SELECT ' 01616145/01616332/01616459','2014-11-13/2014-11-19/2014-11-24',2014090001 UNION double, ALL)
SELECT ' double 01616145/01616332/01616459','2014-11-13/2014-11-19/2014-11-24',2014120768)
separator AS (SELECT trx_ref
to_number (regexp_substr(trx_numbers,'[^/]+',1,LEVEL)) AS trx_number,
, to_date (regexp_substr(trx_dates,'[^/]+',1,LEVEL), 'YYYY-MM-DD') AS trx_date
FROM THE DATA
CONNECT BY LEVEL<= (regexp_count(trx_numbers,'/')="" +="">=>
AND trx_ref = PRIOR trx_ref
AND PRIOR sys_guid() IS NOT NULL)
SELECT trx_ref
MAX (trx_date) KEEP (DENSE_RANK FIRST ORDER BY trx_date DESC) as trx_date
MAX (trx_number) KEEP (DENSE_RANK FIRST ORDER BY trx_date DESC) as trx_number
BETWEEN the separator
Trx_ref group
/
HTH
-
problem with column separated by commas
I'm running into a problem with the following table structure
CREATE TABLE «DETAILS»
(
'ID' NUMBER (22.0) NOT NULL,
VARCHAR2 (150 CHAR) 'NAME' NOT NULL,
"COVER" VARCHAR2 (150 CHAR) NOT NULL
);
Insert into EXPORT_TABLE (ID, NAME, COVER) values (252613546, 'VCONBU', ', 252612938,');
Insert into EXPORT_TABLE (ID, NAME, COVER) values (252613549, 'SPMABU', ', 252612932,');
INSERT INTO EXPORT_TABLE (ID, NAME, COVER) VALUES (252612938, 'HOSTEDTG', NULL);
Insert into EXPORT_TABLE (ID, NAME, COVER) values (252612932, 'INSTG', null);
Insert into EXPORT_TABLE (ID, NAME, COVER) values (367708813, 'ICF_1', ', 252613546,');
Insert into EXPORT_TABLE (ID, NAME, COVER) values (364413059, 'CSWSPT', ', 252613549,');
commit;
Output
ID NAME COVER 252613546 VCONBU HOSTEDTG 252613549 SPMABU INSTG 252612938 HOSTEDTG 252612932 INSTG 367708813 ICF_1 VCONBU 364413059 CSWSPT SPMABU Hello
You may want a self-join, like this:
SELECT c.id
c.name
p.name AS cover
Of export_table c
LEFT JOIN export_table p WE «,» | p.ID
|| ',' = c.lid
;
-
the analysis of string separated by commas
Hello people,
Indeed, this forum is great and has always helped me a lot. I hope that this time remains the same. Thank you guys for you continues a support and help.
I have a value string as a-, b, c, d, e, f
Just sql help, I want to put each value of the string above in a different line. If the output should be-
one
b
c
d
e
f
using procedures would not only complex, but I just want to do by using queries.
Please advise,
Thank you.SQL> with t as (select 'ABC,DEF GHI,JKL' str from dual) 2 select regexp_substr(str,'[^,]+', 1, level) list 3 from t connect by level <= NVL( LENGTH( REGEXP_REPLACE( str, '[^,]+', NULL ) ), 0 ) + 1 4 / LIST --------------- ABC DEF GHI JKL
-
How to pass variable separated by commas in the bind value of VOquery?
Version 11.1.1.3.0
The guys need to help you on this
I have a VO with query somethg as below
SELECT *.
FROM a schema. Table-name
WHERE (: Bind_Varible has the value null or Column_Name IN (: Bind_Varible))
User will be be select several values of the screen and I need to pass these value above bind variable.
But in the variable binding ADF take everything as a single string, then, how can I pass values separated by commas?
As SELECT *.
FROM a schema. Table-name
WHERE (: Bind_Varible has the value null or Column_Name IN (99,55))
Thank you
Any help will be appreciatedI put mine up in this way, my binding variable is a list of values separated by commas, that is to say ("A, B, C, D") (I have a select that many shuttle) then I used a regexp substr to turn them into a list
WHERE :Bind_Batch_NM_Comma_Sep_List IS NULL OR batch_nm IN ( SELECT REGEXP_SUBSTR (:Bind_Batch_NM_Comma_Sep_List, '[^,]+', 1, LEVEL) batch_nm FROM DUAL CONNECT BY LEVEL <= REGEXP_COUNT (:Bind_Batch_NM_Comma_Sep_List, ',') + 1)
Published by: pollywog on September 18, 2012 16:07
-
list separated by commas - extraction of each element in an array?
Is there a quick way to make a field that contains a list of items separated by commas and put them in a table or perhaps separate variables?
for example.
a single line in the database contains the field [matches_with] and would generally contain the following elements:
rings, bracelets, necklaces
I need to be put in a variable
< cfset item1 = 'rings' >
< cfset item2 = 'bracelets' >
< cfset item3 = necklaces >
or if its more simple, put them in a table
agenda [1] = 'rings '.
point [2] = "bracelets".
point [3] = "necklaces."
There is a built-in ListToArray function to CF.
-
I can enlarge my messages and most of the other things (windows 8) but the list of the messages themselves seems not adjustable causing forced look. Any adjustments found to apply to the message but none seem to apply to the list of columns.
https://addons.Mozilla.org/en-us/Thunderbird/addon/theme-font-size-changer/
-
Enter several values in the text box, separated by commas and spaces
Hello
I have the following syntax as my request to report to the opening of user_names in the area of text separated by commas, but the user sometimes come with a space between commas, could someone please let me know
How this can be controlled, both when the user uses the space or not use space as well as the comma recording several user names in the text box?
Thank youselect * from DW_RFA_JOBDATA where FINISH_TIME >= :P1_START_DATE and FINISH_TIME < :P1_END_DATE AND instr(',' || :P1_USER || ',', ',' || USER_NAME || ',') > 0 OR (USER_NAME = USER_NAME AND :P1_USER is null)
Select
*
of DW_RFA_JOBDATA
where FINISH_TIME > =: P1_START_DATE
and FINISH_TIME<>
AND instr ("," |) REPLACE (translate (: P1_USER, '! @# $% ^ & * () _-+= {[]}] |------:; ~ ',' '),' ', "). ',', ',' || USER_NAME | ',') > 0
OR (USER_NAME = USER_NAME AND: P1_USER is null)
Maybe you are looking for
-
registration / strangeness event management
Hi all I just stumbled upon something weired with recording of the event and handling. In my project (it comes to AF, but this is probably not relevant to the question) I'm passing some clusters/paintings reference UI control to a sub - vi for the re
-
Upgrade of RAM for my g4 2049tx pavilion
My system configuration is mentioned in this link: http://support.hp.com/us-en/document/c03548502 I want to improve RAM 4 GB to 8 GB. I don't know what RAM or its specifications to purchase. Please suggest me some links to buy some RAM for my laptop.
-
HTTP device driver cannot restart
I install a web software (IIS) on Windows Server 2003, but the installation fails because it cannot restart the HTTP service. If I go into Device Manager - show hidden devices and - no Plug and Play drivers, I can click stop on the HTTP driver but i
-
photos of Director photo came in the negative live?
started 4 weeks ago, uninstalled and resettled, retart, same.
-
Explorer.exe hangs NOT iexplorer
Windows 7 Professional Whenever I do a right click or left click on an image on the desktop, I get this: Windows crashes I can "Find a solution and restart the program", 'close program', or 'wait to face. " And then, he arranges everything on my desk