Files separated by commas
I'm reading in the data. CSV file.The CSV file contains a list of questions / answers to the format;
Option 1, option 2, option3, option4, question, answer
My problem is that I can get the entire row in a table, but I can't find a way to get each item in the file separated by commas in a multi sized table.
I need to be able to use MyArray [1,1] is equal to the issue and MyArray [1,2] is equal to option1 etc etc.
Hope it makes sense
Paul
'The doctor Pc'
Try something like: MyData: = ReadExtFile (...) [MyList: =]
Chris Forecast
News:eimvmm$g2o$1@forums. Macromedia.com...
> The CSV file contains a list of questions / answers to the format;
>
> Option1 option2 option3, option4, answer question
>
> My problem is that I can get the entire row in a table, but I can't find
> a
> way to get each item in the file separated by commas in a multi
> dimensioned array.
>
> I need to be able to use MyArray [1,1] is equal to the Question and
> MyArray [1,2] is equal to option1 etc etc.
Repeat with i: = 1 to LineCount (MyData)
Temp: = getline (mydata, i)
[ MyList: =]
Repeat with j: = 1 to LineCount (temp, ",")
MyList [i, j]: = GetLine (temp, j, j, ",")
end repeat
end repeat
Tags: Authorware
Similar Questions
-
Form of: separation by comma cfg file access
I need a script to idoc that read these values:
WorkflowsPattern = workflow_one, workflow_two
For single value, I used <$ # about WorkflowsPattern$ > and it works very well, what script to use for the values separated by commas.
Thank yoursMakeFromString: creates a column of a result set of a string.
Parameters:
Takes two required parameters and an optional parameter:
The first parameter is the name of the ResultSet object to create.
The second parameter is a list separated by commas of chains to analyze (for example a, b, c and d), or a variable that has a string separated by commas as its value.
The third optional parameter is the name of the column in the result set. If no value is specified, the name of default column to row.
Output: Creates a result set with a single column, populated by values from the specified string.
http://docs.Oracle.com/CD/E14571_01/doc.1111/e10726/c08_config_ref255.htm#i1111695
Jonathan
http://jonathanhult.com -
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.
-
Entering both the keywords separated by comma
Does anyone know how to enter keywords for the stock footage at the same time (separated by commas) to the new site of contributor Adobe Stock?
Thank you for your question. The ability to copy and paste keywords is not a feature that is available at this time. Please note that if you embed your keywords in the metadata of your content before downloading, the system automatically reads the keywords and they will be applied to your presentation files.
Kind regards
Mat Hayward
-
Splitting data separated by commas
Hi friends,
I have a few million records that must be formatted as data and need your help with this.
Actual data in the csv file:
«30375516451 ',' June 3, 2013 23:31:33 ","June 4, 13"," Tag #: 2490544Sharjah - White 33708 ", 'Al Garhoud bridge nine', 'Abu Dhabi', '4.00»»'
Value using request, separated by commas:
Select
Replace (replace (replace (replace (test_value,'"', null"), chr (13), null), chr (160), null), chr (10), null) "test_value"
of the test
where to_number (length (test_value) - length (replace(test_value,',',''))) in (3.6);
Output:
30375516451, 03-Jun-2013 23:31:33, 4 June 13, Tag #: 2490565Sharjah - white 33708, new Al Garhoud bridge Abu Dhabi, 4.00
Need to change a part with highest result of the query to make it entirely comma separated:
Tag #: 2490565Sharjah - White 33708,.
Output:
2490565, Sharjah, 33708 white,-remove the space before the comma: white 33708,.
Power required:
30375516451, 03-Jun-2013 23:31:33, June 4, 13, 2490544, Sharjah, white 33708, Al Garhoud new bridge, Abu Dhabi, 4.00
Sample data:
CREATE TABLE TEST (TEST_VALUE VARCHAR2 (4000));
INSERT INTO TEST VALUES (' "30375516451","June 3, 2013 23:31:33", "June 4, 13","Tag #: 2490565Sharjah - White 33708", "Al Garhoud bridge nine", "Abu Dhabi", "4.00" ' ");
Thank you
with the trial as)
Select "" 30375516451 ',' June 3, 2013 23:31:33 ","June 4, 13"," Tag #: 2490544Sharjah - 33708 white ', 'Al Garhoud New Bridge', 'Abu Dhabi', '4.00' ' test_value»
of the double
)
Select regexp_replace)
regexp_replace)
test_value,
'( *")| [' || Chr (13) | Chr (160) | Chr (10) | ']',
NULL,
1,
0,
« n »
),
'Tag #:(\d+)(.+) - ([^,]+)',
'\1,\2,\3 '.
) test_value
of the test
/TEST_VALUE
--------------------------------------------------------------------------------------------------------------
30375516451, 03-Jun-2013 23:31:33, 04-Jun-13, 2490544, Sharjah, White 33708, new Al Garhoud bridge Abu Dhabi, 4.00SQL >
SY.
-
Table separated by commas.
I want to create a PL/SQL function that allows you to convert your list separated by commas of values in a nested using Table
Function STRING_TO_TABLE, but I can't do that.
so please help me in this matter.
I create the function, but it displays the following errors.
Thank youSQL> ed Wrote file afiedt.buf 1 Create or replace function STRING_TO_TABLE(pi_string in varchar2) 2 Return varchar2 3 is 4 l_tablen BINARY_INTEGER; 5 l_tab DBMS_UTILITY.uncl_array; 6 BEGIN 7 DBMS_UTILITY.comma_to_table ( 8 list => pi_string, 9 tablen => l_tablen, 10 tab => l_tab); 11 FOR i IN 1 .. l_tablen LOOP 12 l_tab(i) := pi_string; 13 END LOOP; 14* END STRING_TO_TABLE ; SQL> / Function created. SQL> ed Wrote file afiedt.buf 1 create table x1 2 ( 3 value varchar2(200) 4* ) 5 / Table created. SQL> insert into x1 values('&value'); Enter value for value: 32,36,12,65,85,9663 1 row created. SQL> / Enter value for value: 43,36,89,65,112,9663 1 row created. SQL> / Enter value for value: 36,63,12,65,95,123 1 row created. SQL> / Enter value for value: 32,36,12,85, 85,9663 1 row created. SQL> select * from x1; VALUE ---------------------------------------------- 32,36,12,65,85,9663 43,36,89,65,112,9663 36,63,12,65,95,123 32,36,12,85, 85,9663 SQL> select STRING_TO_TABLE(value) from x1; select STRING_TO_TABLE(value) from x1 * ERROR at line 1: ORA-00931: missing identifier ORA-06512: at "SYS.DBMS_UTILITY", line 125 ORA-06512: at "SYS.DBMS_UTILITY", line 160 ORA-06512: at "SYS.DBMS_UTILITY", line 202 ORA-06512: at "SCOTT.STRING_TO_TABLE", line 7
Kind regards.
-
Written for several digital lines separated by commas
Hello people,
I use a USB-6009 box and want to write several digital lines created in the style, separated by commas:
error = DAQmxCreateDOChan(taskSelHead,"dev3/port0/line0,dev3/port0/line6","",DAQmx_Val_ChanPerLine);
When I try to write in this channel I do
uInt8 data [8] = {d1, 0, 0, 0, 0, 0, d2, 0}; with d1 and d2 that represents 0 or 1, which bits I want to get written
int error = DAQmxWriteDigitalLines (taskSelectFilter, 1, 1, 10, DAQmx_Val_GroupByChannel, data, NULL, NULL);
The result is, this only $line0 is updated, lin6 rest 0.
I also tried DAQmxWriteDigitalU8 with the same effect.
Can anyone help?
Thanks in advance,
Michael
Hi Michael,
you have defined two dig.out channels in your task: line 0 and line 6. So, when you write an array of string values, d1 Gets the mapping to your line 0 straight - but line 6 still receives a zero!
Have you tried to set data uInt8 [2] = {d1, d2}?
Best regards
Sebastian -
How can I reach a complete file to send instead of having to attach each file separately
I need to send a complete file to someone. This folder has about 200 hundred files it contains. Is it possible that I can just reach the folder instead of having to attach to each file separately.
Right-click on the folder and To Sen. Compressed (zipped) file and send the file resulting in an attachment. The recipient can decompress.
That's assuming that the file is not a size that is too large for e-mail.
Bruce Hagen ~ MS - MVP [Mail]
-
Hello
I use apex 5.
I used the shuttle to load the list of values of SQL query.now I want to get the list of the selected values on the right side of the shuttle to a textfield.values should be separated by commas.
Please someone tell me how to do this.
Thank you
Hi geslin,.
Garza says:
I use apex 5.
I used the shuttle to load the list of values of SQL query.now I want to get the list of the selected values on the right side of the shuttle to a textfield.values should be separated by commas.
Please someone tell me how to do this.
You can do it by using dynamic action.
Create a dynamic action on the onchange event of your Shuttle point (say P1_SHUTTLE) to get the values to select in the text element (say P1_TEXT) as follows:
Name: give a name
Event: change
Selection type: item (s)
Article (s): P1_SHUTTLE (select your Shuttle point)
Condition: is not null
Action: Execute the PL/SQL Code
Fire on loading the Page: No.
PL/SQL code
BEGIN :P1_TEXT := REPLACE(:P1_SHUTTLE,':',','); END;
Page items to submit: P1_SHUTTLE
Page referred to return: P1_TEXT
Kind regards
Kiran
-
Separated by commas as columns
The text below table can values separated by commas and want to divide it into parts and display them as different columns.
For example
I'm able to do with the CASE statement, but I was wondering if it can be done in a different way.
CREATE TABLE T)
ID NUMBER 4,
TEXT VARCHAR2 (100)
);
INSERT INTO T VALUES (1, 'ALL, biased');
INSERT INTO T VALUES (2, 'ALL, Zero');
INSERT INTO T VALUES (3, 'STAT, NOSTAT');
INSERT INTO T values (4, 'ONEVALUE');
SELECT id, text,
CASE WHEN INSTR (text, ',') > 0 THEN
SUBSTR (text, 1, (INSTR(text,',')-1))
ON THE OTHER
TEXT
END part_1
CASE WHEN INSTR (text, ',') > 0 THEN
SUBSTR (text, INSTR (text, ",") + 1, LENGTH (text))
ON THE OTHER
NULL VALUE
END Part_2
T;
Hello
MyOAF wrote:
The text below table can values separated by commas, and you want to divide it into parts & post them as different columns.
For example
I'm able to do with the CASE statement, but I was wondering if it can be done in a different way.
CREATE TABLE T)
ID NUMBER 4,
TEXT VARCHAR2 (100)
);
INSERT INTO T VALUES (1, 'ALL, biased');
INSERT INTO T VALUES (2, 'ALL, Zero');
INSERT INTO T VALUES (3, 'STAT, NOSTAT');
INSERT INTO T values (4, 'ONEVALUE');
SELECT id, text,
CASE WHEN INSTR (text, ',') > 0 THEN
SUBSTR (text, 1, (INSTR(text,',')-1))
ON THE OTHER
TEXT
END part_1
CASE WHEN INSTR (text, ',') > 0 THEN
SUBSTR (text, INSTR (text, ",") + 1, LENGTH (text))
ON THE OTHER
NULL VALUE
END Part_2
T;
Here's one way:
WITH got_comma_pos AS
(
SELECT id, text
, INSTR (text |) ','
, ','
) AS comma_pos
T
)
SELECT id, text
, SUBSTR (text, 1, comma_pos - 1) AS part_1
SUBSTR (text, comma_pos + 1) AS part_2
OF got_comma_pos
ORDER BY id
;
You can also use regular expressions, but it will be slower.
-
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)
-
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 ';
-
How to split string separated by commas and pass to the clause of the select statement
Referring to article How to divide string separated by commas, then pass to clause of a select statement, tquery that there the following plan:
Query1:
select * from emp where ename in ( select regexp_substr('SMITH,ALLEN,WARD,JONES','[^,]+', 1, level) from dual connect by regexp_substr('SMITH,ALLEN,WARD,JONES', '[^,]+', 1, level) is not null );
Base1:
Plan hash value: 4242290184 -------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 133 | 7 (29)| 00:00:01 | |* 1 | HASH JOIN | | 1 | 133 | 7 (29)| 00:00:01 | | 2 | VIEW | VW_NSO_1 | 1 | 46 | 3 (34)| 00:00:01 | | 3 | HASH UNIQUE | | 1 | | 3 (34)| 00:00:01 | |* 4 | CONNECT BY WITHOUT FILTERING| | | | | | | 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 | | 6 | TABLE ACCESS FULL | EMP | 14 | 1218 | 3 (0)| 00:00:01 | -------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - access("ENAME"="$nso_col_1") 4 - filter( REGEXP_SUBSTR ('SMITH,ALLEN,WARD,JONES','[^,]+',1,LEVEL) IS NOT NULL)
However, the following query generates the plan I want:
Query2:
select * from emp where ename in ('SMITH','ALLEN','WARD','JONES');
Plan2:
Plan hash value: 3956160932 -------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 4 | 348 | 3 (0)| 00:00:01 | |* 1 | TABLE ACCESS FULL| EMP | 4 | 348 | 3 (0)| 00:00:01 | -------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter("ENAME"='ALLEN' OR "ENAME"='JONES' OR "ENAME"='SMITH' OR "ENAME"='WARD')
Can I change the query1 query for plan2?
As Juliet was mentioned in the first SQL that you generate from the ENAME list that you must pass in the IN clause when executing. But in the second SQL, it passed as a static value. So first SQL must do more work. So you see a different execution plan.
But this is a work around to get what you are looking for. But I can't say it's a foolproof method. But anyway here you go.
SQL > var ename_list varchar2 (100)
SQL > exec: ename_list: = 'SMITH, ALLEN, WARD, JONES ';PL/SQL procedure successfully completed.
SQL > select *.
2 of PEM
where the 3 «,» | : ename_list | ',' like '%', | Ename | ',%';EMPNO, ENAME, JOB HIREDATE DEPTNO ID COM SAL MGR
---------- ------ --------- ---------- --------- ---------- ---------- ---------- ----------
7369 SMITH COMMITTED 7902 2975 2 APRIL 81 0 20
7499 ALLEN 7698 1600 20 FEBRUARY SALESMAN 81 300 30
7521 WARD 7698 1250 22 FEBRUARY SALESMAN 81 500 30
7566 JONES MANAGER 7839 2975 2 APRIL 81 0 20SQL > select * from table (dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------------------------
SQL_ID, 848zhvbvgf7d6, number of children 0
-------------------------------------
Select * from emp where «,» | : ename_list | ',' like '%', | Ename
|| ',%'Hash value of plan: 2872589290
--------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 2 (100) | |
|* 1 | TABLE ACCESS FULL | EMP | 1. 38. 2 (0) | 00:00:01 |
--------------------------------------------------------------------------Information of predicates (identified by the operation identity card):
---------------------------------------------------1 - filter(','||:ENAME_LIST||',' LIKE '%,'||") ENAME "|", %')
19 selected lines.
SQL >
-
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.
-
passing values separated by commas of a single parameter
Hi experts,
I am writing a report where I need to pass the values (dates) separated by commas for one parameter in the query.
parameter passing is 19810928, 19830112
to do this, I wrote like this
WITH AS's Data1
(SELECT TRIM (SUBSTR (txt,
INSTR (txt, "," 1, LEVEL) + 1.
INSTR (txt, "," 1, LEVEL + 1)
-INSTR (txt, "," 1, LEVEL)
-1
)
) Token.
FROM (SELECT ',' |: txt |) ',' txt
THE DOUBLE)
CONNECTION OF LEVEL < = LENGTH (: txt)-LENGTH (REPLACE (: txt, ",", ")) + 1);
Select ename, sal, deptno, job, hiredate
WCP
where hiredate between (19810928) and (19830112)
above it is argued IN the list
can you help me please
Published by: mbb774 on May 10, 2013 16:07mbb774 wrote:
Sorry, could not help me.Well, she would have done if you'd read and understood it. but it doesn't matter.
SQL> with params as (select '19810928,19830112' as p from dual) 2 -- 3 -- end of simulated parameters 4 -- 5 select ename, deptno, sal, job, hiredate 6 from emp 7 ,(select regexp_substr(p,'[^,]+',1,1) as start_date 8 ,regexp_substr(p,'[^,]+',1,2) as end_date 9 from params) p 10 where hiredate between to_date(p.start_date,'YYYYMMDD') and to_date(p.end_date,'YYYYMMDD') 11 / ENAME DEPTNO SAL JOB HIREDATE ---------- ---------- ---------- --------- -------------------- MARTIN 30 1250 SALESMAN 28-SEP-1981 00:00:00 KING 10 5000 PRESIDENT 17-NOV-1981 00:00:00 JAMES 30 950 CLERK 03-DEC-1981 00:00:00 FORD 20 3000 ANALYST 03-DEC-1981 00:00:00 MILLER 10 1300 CLERK 23-JAN-1982 00:00:00 SQL>
Maybe you are looking for
-
Why my optimum voice mail is not operable using Firefox? OK with IE and Google Chrome.
Whenever recently, lately, using Firefox to open my homepage of optimum.net my voicemail is "not available at this time." It of OK for a few years and is still OK if I use Internet Explorer of Google Chrome, Firefox only gives the problem. Looks like
-
Black & white TV on satellite A200 - 19L-out
Hello I bought a TV out cable with SCART and I couldn't get a fine image quality.In fact, it's all black and white. I borrowed a cable from my friend (who is tested...) and the same result here.If I am more accurate, this cable has produced a few col
-
Installation and stop, but nothing moved?
Hello Yesterday, 03/06/2010, I noticed a shutdown option and install updates in my Start menu, with the shield icon and everything, so I did. I restarted, and the icon and the option are still there. I rebooted since then and stop several times tod
-
Why do I get my network places empty?
Hello I tried to solve this problem using regedit and various DLLs running problem is resolved and then back again. I'm so bored with this problem. I keep trying to fix it and it comes back. Could you kelp me please in this. Kind regards SK
-
Speed of Ram DDR3 X120e! Photos!
I have a question about the speed of the actual ram in the Lenovo x120e. Mine came with only one of 2 Go DDR3-1333 (PC3-10666). When I got it, I ran CPU - Z to see what that memory actually ran to, because I had 2 x 4 Go DDR3-1066 (PC3-8500) to an ol