Separated by comma delimited field of database
I have a ms access db field town with values like this:Vancouver, BC V6A 4 8
Richmond, BC V6Y 1 s 6
Coquitlam, BC V3J 2W4
I like to leave the city names in the City field as Coquitlam Vancouver, Richmond, goes into the city. BC, BC, British Colombia goes into the Province field. V6A 4 8, V6Y 1 s 6, V3J 2W4 goes in the postal Code field. Is this possible?
Thank you
Note that Vancouver, BC V6A 4 8 is a part of two, the list separated by commas. Also note that BC V6A 4 8 is a list of the three elements of space-delimigted. If you can do something like the following:
Tags: ColdFusion
Similar Questions
-
Value separated by commas in a table column to get each field separtely?
Hello
I have the table that a column has values separated by commas in it. This table is populated using SQL LOADER, which is staging table.
I need to retrieve the records of these values separated by commas.
format of. CSV file is as -
A separate file of pipes.
DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2|
DHCP-1-1-2. WNLB-CMTS-03-3,WNLB-CMTS-04-4,WNLB-CMTS-05-5|
DHCP-1-1-3. WNLB-CMTS-01-1.
DHCP-1-1-4. WNLB-CMTS-05-8,WNLB-CMTS-05-6,WNLB-CMTS-05-0,WNLB-CMTS-03-3|
DHCP-1-1-5 | WNLB-CMTS-02-2,WNLB-CMTS-04-4,WNLB-CMTS-05-7|
CREATE TABLE link_data (dhcp_token VARCHAR2 (30), cmts_to_add VARCHAR2 (200), cmts_to_remove VARCHAR2 (200));
insert into link_data values ('dhcp-1-1-1','wnlb-cmts-01-1,wnlb-cmts-02-2',null);
insert into link_data values ('dhcp-1-1-2','wnlb-cmts-03-3,wnlb-cmts-04-4,wnlb-cmts-05-5',null);
insert into link_data values ('dhcp-1-1-3','wnlb-cmts-01-1',null);
insert into link_data values ('dhcp-1-1-4','wnlb-cmts-05-8,wnlb-cmts-05-6,wnlb-cmts-05-0,wnlb-cmts-03-3',null);
insert into link_data values ('dhcp-1-1-5','wnlb-cmts-02-2,wnlb-cmts-04-4,wnlb-cmts-05-7',null);
Here the cmts_to_add column has comma separted
I need values such as -.
> for wnlb-cmts-01-1,wnlb-cmts-02-2 > > wnlb-CMTS-01-1
> > wnlb-CMTS-02-2
> for wnlb-cmts-03-3,wnlb-cmts-04-4,wnlb-cmts-05-5 > > wnlb-CMTS-03-3
> > wnlb-CMTS-04-4
> > wnlb-CMTS-05-5
And so on...
I do this because it's the staging table and I load data into the main tables using this table.
This second field contain different values as the simple comma-delimited string.
I need to write a PLSQL block to insert into the main table after checking as if dhcp-1-1-1 and wnlb-CMTS-01-1 is present in the main table so not to introduce other insert a new record.
To meet this requirement, I need to get the distinct value of the cmts_to_add column to insert into DB.
the value will be inserted as dhcp-1-1-1_TO_wnlb-cmts-01-1 and dhcp-1-1-1_TO_wnlb-cmts-02-2 for the first row of the array of link_data.
The process will also be same for the rest of the lines.
I use the function substrt and instr for this problem, but its does not work.
declare
cursor c_link is select * from link_data.
l_rec_link link_data % rowtype;
l_dhcp varchar2 (30);
l_cmts varchar2 (20000);
l_cmts_1 varchar2 (32000);
Start
Open c_link;
loop
extract the c_link in l_rec_link;
l_cmts: = l_rec_link.cmts_to_add;
loop
l_cmts_1: = substr (l_cmts, 1, instr(l_cmts,',')-1);
dbms_output.put_line (l_cmts_1);
end loop;
dbms_output.put_line(l_dhcp||) e '|| l_cmts);
When the output c_link % notfound;
end loop;
exception
while others then
Dbms_output.put_line ('ERROR' |) SQLERRM);
end;
Its a peusdo code I write, but it also gives me the wrong answer it gives me error ORA-20000: ORU-10027: buffer overflow, limit of 20000 bytes
I am using-
Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
Please tell me if my problem isn't clear!
Hello
little 'trick': Add a comma at the end of the chain... So it's easier to deal with the fact that there are zero, one, or N components...
CREATE TABLE link_data (dhcp_token VARCHAR2 (30), cmts_to_add VARCHAR2 (200), cmts_to_remove VARCHAR2 (200));
insert into link_data values ('dhcp-1-1-1','wnlb-cmts-01-1,wnlb-cmts-02-2',null);
insert into link_data values ('dhcp-1-1-2','wnlb-cmts-03-3,wnlb-cmts-04-4,wnlb-cmts-05-5',null);
insert into link_data values ('dhcp-1-1-3','wnlb-cmts-01-1',null);
insert into link_data values ('dhcp-1-1-4','wnlb-cmts-05-8,wnlb-cmts-05-6,wnlb-cmts-05-0,wnlb-cmts-03-3',null);
insert into link_data values ('dhcp-1-1-5','wnlb-cmts-02-2,wnlb-cmts-04-4,wnlb-cmts-05-7',null);
COMMIT;SET SERVEROUT ON
DECLARE
l_cmts VARCHAR2 (200 CHAR);
l_cmts_1 VARCHAR2 (200 CHAR);
BEGIN
FOR r IN (SELECT dhcp_token, cmts_to_add |) ',' cmts
OF link_data
)
LOOP
l_cmts: = r.cmts;
l_cmts_1: = SUBSTR (l_cmts, 1, INSTR (l_cmts, ",") - 1);
While l_cmts_1 IS NOT NULL
LOOP
DBMS_OUTPUT. Put_line (r.dhcp_token |) '|' || l_cmts_1);
l_cmts: = SUBSTR (l_cmts, INSTR (l_cmts, ",") + 1);
l_cmts_1: = SUBSTR (l_cmts, 1, INSTR (l_cmts, ",") - 1);
END LOOP;
END LOOP;
END;
/
DHCP-1-1-1. WNLB-CMTS-01-1
DHCP-1-1-1. WNLB-CMTS-02-2
DHCP-1-1-2. WNLB-CMTS-03-3
DHCP-1-1-2. WNLB-CMTS-04-4
DHCP-1-1-2. WNLB-CMTS-05-5
DHCP-1-1-3. WNLB-CMTS-01-1
DHCP-1-1-4. WNLB-CMTS-05-8
DHCP-1-1-4. WNLB-CMTS-05-6
DHCP-1-1-4. WNLB-CMTS-05-0
DHCP-1-1-4. WNLB-CMTS-03-3
DHCP-1-1-5 | WNLB-CMTS-02-2
DHCP-1-1-5 | WNLB-CMTS-04-4
DHCP-1-1-5 | WNLB-CMTS-05-7Best regards
Bruno Vroman.
-
Left join of the two tables and multiple values into a single value separated by commas
Hello
I have following tables with their structures and their data as below.
CREATE TABLE 'BETODI '. "" BETINFO ".
(
VARCHAR2 (8 BYTE) "CURRENTPRESS."
ENABLE 'TYPEIDCONTAINER' VARCHAR2 (30 BYTE) NOT NULL
)
INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A24G', 'PMC');
INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A24D', 'Pensky-MARTENS');
INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ("A25D", "CMP");
INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A25G', 'PMC');
INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A26D', 'PMC');
INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A26G', 'PMC');
INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ("A32G", "V-BFC3");
INSERT INTO Betinfo (Currentpress, typeidcontainer) VALUES ('A32D', "V-BFC2");
CREATE TABLE 'BETODI '. "" BETMASTER ".
(
ACTIVATE THE "CUREPRESS" TANK (5 BYTES) NOT NULL,
ACTIVATE THE "TYPE" VARCHAR2 (5 BYTE) NOT NULL,
NUMBER (5.0) "LASTPCIRIM".
)
INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A24', '45 M 8', 15);
INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A25', 42 16', 15);
INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ("A26", 16' 45, 15);
INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ("A27", '45 M 34', 16);
INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A28', '45 M 34', 16);
INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A29', '45 M 34', 16);
INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A30', '45MCH', 15);
INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ("A31", "45MCH", 16);
INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A32', '45MCH', 16);
INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ('A33', '45MCH', 16);
INSERT INTO BetMaster (Curepress, type, lastpcirim) VALUES ("A34", "45MCH", 16);
These two tables have left join as
BETMASTER. CUREPRESS = substr (BETINFO. CURRENTPRESS, 1, 3)
now I want to have the data in the two tables with fields Curepress, Lastpcirim, typeidcontainer.
Also something like
Make a group of typeidcontainer if this value is greater than 1 by press separated the values of semicolon (;)
So, for example above, we should be given as
A24 PMC 15; PENSKY-MARTENS
A25 15 PMC
A26 15 PMC
A27 16 (NULL)
A28 16 (NULL)
A30 15 (NULL)
A31 16 (NULL)
A32 16 BFC2-V; V BFC3
A33 16 (NULL)
A34 16 (NULL)
How could do?
My current request is as
Select distinct Curepress, lastpcirim, typeidcontainer
BETMASTER STD left join INF BETINFO
on the trim (STD. CUREPRESS) = substr (trim (INF. CURRENTPRESS), 1, 3)
but I am unable to get the values separated by commas.
Any help would be appreciated.
Thank you
Mahesh.
Hi, Mahesh,
If you want to only 1 row of output for each distinct combination of currentpress and lastpcirim? This sounds like a job for GROUP BY.
And you want the row to contain a list of all different typidcontainers-delimited? This sounds like a job for the aggregate LISTAGG function.
WITH joined_data AS
(
SELECT DISTINCT
MST.curepress, mst.lastpcirim, inf.typeidcontainer
OF betmaster STD
LEFT JOIN betinfo ON TRIM (mst.curepress) inf = SUBSTR (TRIM (inf.currentpress)
1
3
)
)
SELECT curepress, lastpcirim
LISTAGG (typeidcontainer, ',')
THE Group (ORDER BY typeidcontainer) AS container_list
OF joined_data
Curepress GROUP, lastpcirim
;
Unfortunately, you can't say LISTAGG (DISTINCT ...), so you should always get the separate containers how you already are. (Note that the subquery is just what you posted).
Thanks for posting the CREATE TABLE and INSERT statements; It is very useful. Don't forget to tell what version of Oracle you are using. LISTAGG was new in Oracle 11.2.
Why not add CHECK constraints (and perhaps triggers) to your tables, so that curepress and currentpress are not stored with the head or trailing spaces? Then you wouldn't need to use the PAD in queries like this, and your code would be simpler and more effective.
-
Find the occurrence of the word in a list separated by commas
Hello
I need to find the first occurrence of a word in a list separated by commas.
Example list:
Now I'm looking for the word: bambimonster,daemon,shark,bambi,sky
Result should be the first calculation of the event: 4
Now I'm looking for the word: Monster
Result should be the first calculation of the event: 1
Hope you can help.
TobiasHi, Tobias,.
This can be more efficient, because it does not use CONNECT BY or regular expressions. Instead of splitting the string to the level of every comma, just find the target string and count how many commas occur in front of her.
WITH got_found_pos AS ( SELECT list_txt , INSTR ( ',' || list_txt || ',' , ',bambi,' ) AS found_pos FROM table_x ) SELECT list_txt , found_pos + 1 - LENGTH ( REPLACE ( SUBSTR (list_txt, 1, found_pos) , ',' ) ) AS item_num , found_pos FROM got_found_pos WHERE found_pos > 0 ;
Delimited lsits storage is usually a bad idea in a relational database. It is best to store each item in the list on a separate line.
-
Treatment of comma-delimited file
Hi all
I need to treat more file separated by commas (example data):
' ' 'ILPS2', '2', ' ', ' 1293051491.000 ',' outward_drum ', 'top', 'T 30000025429, 22', 'V', 'PVIDC', '9', 'PVOCR', "13", "M", "3030369900545", "N", "N", "N", "N", ', 'Y', ', "N", "", "","","", "01.37", "F", "N", ",", ""
' ' 'ILPS2', '2', ' ', ' 1293051491.000 ',' outward_drum ', 'top', 'T 30000025329, 22', 'V', 'PVIDC', '8', 'PVOCR', "12", "M", "3030369900545", "N", "N", "N", "N", ', 'Y', ', "N", "", "","","", "01.37", "F", "N", ",", ""
But each column begins and ends by ". I need these characters and lead single 'data' in the columns how can I achieve this?
ODI can process fixed or delimited files.
All ideas are most appreciated.
Thank you
KSHi, KS,
I would like to contribute to a point.
You can manage this when creating data store.
"Go to-> your model-> open your data store-> go to the files tab-> in the text delimiter add * ' *. Save it.
PS: If its not taking "then try to create a new database. I tried with your sample data and review data when adding "as the delimiter text.
Thank you
Guru -
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.
-
Using .split on an import script with a comma delimited data file
Hi everyone-
Any attempt to create a script to import amount field to remove the apostrophes (') of a description field to account in a .csv data import file (any folder with an apostrophe will be rejected during the import phase). Now if it was a file delimited by semicolons (or other separators and more by commas), I could remove all the apostrophes recording with a string.replace command, then return the amount with a command of string.split. Unfortunately, there is a problem with this solution when using comma delimiters. My data file is comma-delimited .csv file with several amount fields that have commas in them. Even if the fields are surrounded in quotes, the .split ignores the quotes and treats the commas in fields amount as delimiters. Therefore, the script does not return the correct amount field.
Here is an example of a record of reference data:
"", "0300-100000", "description of the account with an apostrophe ' ', '$1 000.00",' $1 000.00 "," $1 000.00 ","$1 000.00"," $1 000,00 "" "
My goal is to remove the apostrophes from field 3 and return the amount in field 8.
Some things to note:
- If possible, I would like to keep this as an import script for amounted to simplify administration - but am willing to undertake the event script BefImport if this is the only option or more frank than the import script-based solution.
- I tried using regular expressions, as seems to be conceptually the simplest option to respect the quotes as escape character, but think that I am not implementing properly and impossible to find examples of regex for FDMEE.
- I know that we cannot use the jython csv on import the script by Francisco blog post - fishing with FDMEE: import scripts do not use the same version of Jython as event/Custom scripts (PSU510). This may be a factor to go with a script of the event instead.
- It's probably a little more engineering solution, but I have considered trying to write a script to determine where to start all the quotes and the end. Assuming that there are no quotation marks on the inside of my description of account (or I could remove them before that), I could then use the positioning of the quotes to remove commas inside those positions - leaving the commas for the delimiters as is. I could then use the .split as the description/amount fields have no commas. I think it may be better to create a script of the event rather than down this solution from the point of view to keep administration as simple as possible
- Yes, we could do a search and replace in the excel file to remove the apostrophes before import, but it's no fun
Thanks for any advice or input!
Dan
Hi Dan,.
If your line is delimited by comma and quote qualified, you can consider the delimiter as QuoteCommaQuote or ', ' because it comes between each field. Think about it like that, then simply divided by this value:
split("\",\"")
Here's something I put together in Eclipse:
'''
Created on Aug 26, 2014
@author: robb salzmann
'''
import re
strRecord = "\"\",\"0300-100000\",\"Account description with an apostrophe ' \",\"$1,000.00\",\"$1,000.00\",\"$1,000.00\",\"$1,001.00\",\"$1,002.00\""
strFields = strRecord.split("\",\"")
strDescriptionWithoutApos = strFields[2].replace("'", "") 'remove the apostrophe
strAmountInLastCol = strFields[-1:].replace("\"", "") 'You'll need to strip off the last quote from the last field
print strDescriptionWithoutApos
print strAmountInLastCol
Account with an apostrophe description
' $1 002,00
-
Reg. separated by commas of the values in the Text parameter
Hello
I tried to keep a text box parameter to contain multiple values by enabling the option 'field contains values separated by commas. But still, in my report, when I gave multiple values, I got the below error.
ORA-00909: invalid number of arguments
I have provided the values as below.
001IB01141130003, 001IB01141170002
use also all other special characters?
Thanks in advance.
Please try this
Where (AC. TRN_REF_NO IN (: PM_REF_NO) OR LEAST(:PM_REF_NO) IS NULL)
-
regular expressions for numbers demical in a comma-delimited list
I have a table that lists the details of the occupation of the sites of a comma-delimited list:create table tenure_test)
number of site_number
tenure_detail varchar2 (255));insert into tenure_test values (1, ' Crown (Other) (0.15 ha), private (555.25 ha)');
insert into tenure_test values (2, ' private (5.76 ha)');
insert into tenure_test values (3, ' private (0.18 ha, Crown (3.25 hectares), Indeterminate (Leased) (5.85 ha)');)What I want to do is to use a regular expression to calculate the sum only numbers in the tenure_detail column.
For example, for site_number 1, it would be 0.15 + 555.25 = 555,4
I also have another regular expression that has just the numbers in a comma-delimited list.
For site_number 1: 0.15, 555.25
I tried this:
Select site_number, tenure_detail, regexp_substr (tenure_detail, "[0-9] + \.") ([0-9] {2}') under the name test1
of tenure_test;
but it lists only the first number.
Hello
996454 wrote:
I have a table that lists the details of the occupation of the sites of a comma-delimited list:
create table tenure_test)
number of site_number
tenure_detail varchar2 (255));insert into tenure_test values (1, ' Crown (Other) (0.15 ha), private (555.25 ha)');
insert into tenure_test values (2, ' private (5.76 ha)');
insert into tenure_test values (3, ' private (0.18 ha, Crown (3.25 hectares), Indeterminate (Leased) (5.85 ha)');)What I want to do is to use a regular expression to calculate the sum only numbers in the tenure_detail column.
For example, for site_number 1, it would be 0.15 + 555.25 = 555,4
I also have another regular expression that has just the numbers in a comma-delimited list.
For site_number 1: 0.15, 555.25
I tried this:
Select site_number, tenure_detail, regexp_substr (tenure_detail, "[0-9] + \.") ([0-9] {2}') under the name test1
of tenure_test;
but it lists only the first number.
Here's one way:
SELECT site_number
SUM (TO_NUMBER (REGEXP_SUBSTR (tenure_detail
, "\d+\.\d*" - see Note 1
) T
LEVEL
)
)
), Total
OF tenure_test
CONNECT BY LEVEL<= regexp_count="" (="">=>
, '\d+\.\d*'
)
AND PRIOR site_number = site_number
AND PRIOR SYS_GUID () IS NOT NULL
GROUP BY site_number
;
Output:
TOTAL OF SITE_NUMBER
----------- ----------
1 555,4
2 5.76
3 9.28
Note 1: what exactly makes a 'number '? I'm assuming it's 1 or more digits, followed by a comma, followed by 0 or more numbers. You can have a slightly different definition; in this case, change the arguments 2nd REGEXP_SUBSTR and REGEXP_COUNT.
I guess also that site_number is unique. If not, you will have to change the CONNECT BY and GROUP BY clauses, to refer to something (or a combination of things) which is unique.
Relational databases are designed for each column of each row contain 1 single piece of information, not a list delimited with a variable number of elements. It is so basic to the design of database he called the first normal form. If your first followed table form normal, this query (and many other queries that involve that table) would be much simpler to write, more efficient to run and less likely to have bugs. See if you can normalize this table. Any effort that you have to spend now to normalize the table will pay very quickly.
Thanks for posting the CREATE TABLE and INSERT statements; It is very useful.
Don't forget to tell what version of Oracle you are using. I tried the query in Oracle 11.2 above. You may need to CONNECT BY a little differently in earlier versions, and REGEXP_COUNT will not work in Oracle 10.
-
Hello
I have 3 tables with the following structure.
create table a_os_lang_stls
(ID NUMBER )
SWB_NUMBER VARCHAR2 (30),
Pc_NUMBER VARCHAR2 (30),
PC_FLAG TANK (1),
INSTALLATION_ord NUMBER ,
SP_OR_LATER_VSN TANK (1),
Platform VARCHAR2 (4000),
OS VARCHAR2 (4000),
LANG VARCHAR2 (4000),
LOSS_OF_FUNC_REASON_TXT VARCHAR2 (4000),
CREATION_DATE DATE ,
MODIFIED_DATE DATE ,
CREATED_BY VARCHAR2 (100 BYTE),
MODIFIED_BY VARCHAR2 (100 BYTE)
);
Insert in a_os_lang_stls
values (1 'SWB1' 'SWB0','P',1 of ','11118,14,16,234,124' '12,26,17,24,35''34,28,45,67,123,95',USER, NULL, NULL, NULL, SYSDATE);
Insert in a_os_lang_stls
values (2,'SWB1' 'SWB2','P',2 of ','111,20,14,16,124''11,26,18,24,35''35,27,42,67,123,95', SYSDATE, NULL, NULL, NULL, USER);
insert into a_os_lang_stls
values (3,'SWB1','SWB3','C', 1,'','11118,14,16,234,124','12,26,17,24,35',' 35,27,42,67,123,95', SYSDATE, NULL, NULL, NULL, USER);
insert into a_os_lang_stls
values (4,'SWB1','SWB4','C', 2,'','111,20,14,16,124','11,26,18,24,35'' 34,28,45,67,123,95, SYSDATE, NULL, NULL, NULL, USER)
CREATE TABLE os_dtls
(
OSCODE VARCHAR2 (10 BYTE),
ID NUMBER DEFAULT NULL,
AG_OSCODE VARCHAR2 (250 BYTE),
);
insert into os_dtls
values ('HUX', 12, 'HP UNIX');
insert into os_dtls
values('SUX',26,'SOLARIS');
insert into os_dtls
values ('LUX', 17, 'LINUX');
CREATE TABLE lang_dtls
(
LANGCD TANK (2 BYTE),
LANGNAME VARCHAR2 (255 BYTE),
ID NUMBER DEFAULT 1 NOT NULL
);
insert into lang_dtls
values ('ENG', 'ENGLISH UK', 35);
insert into lang_dtls
values ('UEG', 'USA ENGLISH', 27);
insert into lang_dtls
values('FR','FRENCH',45);
Information on the database:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
PL/SQL version 11.1.0.7.0 - Production
Production base 11.1.0.7.0
AMT for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
I have to write a procedure like this
procedure os_lang_info (P_SB_NO IN varchar2, p_pcur sys_refcursor, p_ccur, sys_refcursor );
The requirement is to get the details for a given swb_no where pc_flag is P or C pass like 2 different sys_refcursor. But the value of column of bones and lang I need to map to the os_dtls and lang_dtls tables to get the ag_oscode and langname respectively for the corresponding id then through sys_refcursor.
So sys_refcursor structure will be
Open the p_pcur for
Select * from a_os_lang_stls
where swb_number = p_sb_no
and PC_FLAG = 'P' ;
so the output will resemble the following
1 , « SWB1 » , « SWB0 » , 'P' , 1 , 'S' , '11118,14,16,234,124' , «HP UNIX,SOLARIS,LINUX,... « , "UK ENGLISH,US ENGLISH,FRENCH,...» ', NULL, NULL, NULL, USER, SYSDATE
I must get the id separated by commas of column bone and lang and map to the corresponding table to get the names separated by commas of the bones and langs and pass it as a component of sys_refcursor.
Open the p_ccur for
Select * from a_os_lang_stls
where swb_number = p_sb_no
and PC_FLAG = 'C';
Could someone please help me how to convert the value separated by commas in a comma separated value new map to another table and pass it as part of the sys_refcursor.
Thanks in advance.
Kind regards
SB2011
Hello. Here are the queries for the two sys_refcursors.
(1) FOR THE FLAG = 'P '.
SELECT T1.ID,
T1. SWB_NUMBER,
T1. PC_NUMBER,
T1. PC_FLAG,
T1. INSTALLATION_ORD,
T1. SP_OR_LATER_VSN,
T1. PLATFORM,
T1. OS_CODE,
T2. LANG_CODE
DE)
SELECT T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
RTRIM (XMLAGG (XMLELEMENT(A,AG_OSCODE,',')). Extract ('//Text ()'), ',') OS_CODE
FROM (SELECT ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
(COLUMN_VALUE). GETNUMBERVAL() os_id
Of a_os_lang_stls t, xmltable (os) t1) T1.
OS_dtls T2
WHERE T2.ID = T1. OS_ID
GROUP OF T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
T1 PLATFORM),
(SELECT T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
RTRIM (XMLAGG (XMLELEMENT(A,LANGNAME,',')). Extract ('//Text ()'), ',') LANG_CODE
FROM (SELECT ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
(COLUMN_VALUE). GETNUMBERVAL() lang_id
Of a_os_lang_stls t, xmltable (lang) t1) T1.
lang_dtls T2
WHERE T2.ID = T1.lang_id
GROUP OF T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
T2 PLATFORM)
WHERE T1.ID = T2.ID
AND T1. SWB_NUMBER = T2. SWB_NUMBER
AND T1. PC_NUMBER = T2. PC_NUMBER
AND T1. INSTALLATION_ORD = T2. INSTALLATION_ORD
AND T1. PLATFORM = T2. PLATFORM
AND T1. PC_FLAG = "P";
(2) PC_FLAG FOR = 'C '.
SELECT T1.ID,
T1. SWB_NUMBER,
T1. PC_NUMBER,
T1. PC_FLAG,
T1. INSTALLATION_ORD,
T1. SP_OR_LATER_VSN,
T1. PLATFORM,
T1. OS_CODE,
T2. LANG_CODE
DE)
SELECT T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
RTRIM (XMLAGG (XMLELEMENT(A,AG_OSCODE,',')). Extract ('//Text ()'), ',') OS_CODE
FROM (SELECT ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
(COLUMN_VALUE). GETNUMBERVAL() os_id
Of a_os_lang_stls t, xmltable (os) t1) T1.
OS_dtls T2
WHERE T2.ID = T1. OS_ID
GROUP OF T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
T1 PLATFORM),
(SELECT T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
RTRIM (XMLAGG (XMLELEMENT(A,LANGNAME,',')). Extract ('//Text ()'), ',') LANG_CODE
FROM (SELECT ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
PLATFORM,
(COLUMN_VALUE). GETNUMBERVAL() lang_id
Of a_os_lang_stls t, xmltable (lang) t1) T1.
lang_dtls T2
WHERE T2.ID = T1.lang_id
GROUP OF T1.ID,
SWB_NUMBER,
PC_NUMBER,
PC_FLAG,
INSTALLATION_ORD,
SP_OR_LATER_VSN,
T2 PLATFORM)
WHERE T1.ID = T2.ID
AND T1. SWB_NUMBER = T2. SWB_NUMBER
AND T1. PC_NUMBER = T2. PC_NUMBER
AND T1. INSTALLATION_ORD = T2. INSTALLATION_ORD
AND T1. PLATFORM = T2. PLATFORM
AND T1. PC_FLAG = 'C ';
-
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%
-
How to parse a comma delimited by the string in BPEL 11.1.1.4
I have the MyTag element in xml. I get value for MyTag as Eng, [email protected] (separated by commas) in the BPEL workflow.
I need to parse this string separated by commas in BPEL and extract
Eng AND [email protected]
How can I do this in BPEL? What is the process?Hello
If you get the value like Eng, [email protected] and say that tempVariable Eng, [email protected] data. So, here you go...
substring-after (bpws:getVariableData('tempVariable'), ','), use it in the Expression Builder on the side of the copy operation and that assign to the variable (variable database entry). This will give you [email protected]
substring-before (bpws:getVariableData('tempVariable'), ','), use it in the Expression Builder on the side of the copy operation and that assign to the variable (variable database entry). This will give you in English
I hope this helps...
Thank you
N -
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
-
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,
PrazyPublished by: Prazy on April 28, 2010 10:23
-
Enter several values in the comma-delimited text box
Hello
I have a text box element on my entry page, where to enter specific user name to get the data it is an optional field,
the requirement is now so the user want to type in several user names in the text box element.
Is it possible, and they want to enter usernames separated by commas...
How can I change my code?
Here is the code that I currently have a
select * from DW_RFA_JOBDATA where FINISH_TIME >= :P1_START_DATE and FINISH_TIME < :P1_END_DATE AND ( USER_NAME = :P1_USER OR (USER_NAME = USER_NAME AND :P1_USER is null))
Misspelling in the sql. Try this one
select * 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)
Maybe you are looking for
-
Qosmio G20: XP Installation disk & SATA USB
Hello I have Toshiba Qosmio G20 and I have the following problem:When I try to install new windows using the SATA drivers via the floppy USB drive as a process of installing classic XP SATA drivers are needed 2 times: First time as usual, you will ne
-
Qosmio G20: The AC adapter heats
HelloI would ask to the users of this computer if they notice that their heating adapter when is in use. I've had different laptops in the past and the power adapter wasn't that hot at all... and even heats up this pretty quickly, say in all about 30
-
All-in-one HP PSC 1315v: psc 1315v
When you try to print word documents, the HP PSC 1315v all-in-One print only certain colors. Currently, yellow and blue will print vaguely, but not black. The last time, black would print very slightly, but some color would be to print. Initially,
-
I need a new power adapter for my HP Office 6500 - E709n. Does it matter if I buy an adapter for a model E709a? Will it work on the E709n? The power adapter E709a looks identical in the photos. Thank you.
-
Win XP (Pro) - the screen seems to flatten
Hello I reinstall Win XP (Pro) after upgrade to a larger hard drive. My window and Dell drivers are up to date. However, I notice that the font size is much greater than before, and flatten the appearance of the screen. The fonts are sttetched on the