Turning parts of a string into rows in another table
I need to extract unit codes that are stored in a string into rows in a new table as below
From:
Set_cd sequence_number rule_text
KP106A 15432 {1234,4567,8910,1567}
To:
Set_cd sequence_number unit
KP106A 15432 1234
KP106A 15432 4567
KP106A 15432 8910
KP106A 15432 1567
The strings will be of varying lengths but the layout will always be the same with the curley brackets and commas.
Any ideas please?
Thanx
Rob.
Edited by: Rob Mc on Sep 23, 2009 2:38 PM
Something like this ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Elapsed: 00:00:00.03
satyaki>
satyaki>
satyaki>with ta_tab
2 as
3 (
4 select 'KP106A' set_cd, 15432 sequence_number, '{1234,4567,8910,1567}' rule_text from dual
5 )
6 select set_cd,
7 sequence_number,
8 REGEXP_SUBSTR (replace(replace(rule_text,'{',''),'}',''), '[^,]+', 1, level) rule_part
9 from ta_tab
10 connect by level <= (
11 select length(regexp_replace(replace(replace(rule_text,'{',''),'}',''),'[^,]*'))+1
12 from ta_tab
13 );
SET_CD SEQUENCE_NUMBER RULE_PART
KP106A 15432 1234
KP106A 15432 4567
KP106A 15432 8910
KP106A 15432 1567
Elapsed: 00:00:01.02
satyaki>
satyaki>Regards.
Satyaki De.
Similar Messages
-
Converting comma separated string into rows
for my procedure varchar2 is i/p paramter. i will get this i/p from java. this string value is like 'VTP,VR','VM'.
i want to split taht string into rows ie o/p will be
VTR
VR
VM.
how to do this.Hi,
As always, the solution depends on your data, your requirements, and you Oracle version.
Here's one way:
-- Simulating Java input with a bind variable:
VARIABLE str VARCHAR2 (100)
EXEC :str := 'VTP,VR,VM';
SELECT LEVEL AS n
, REGEXP_SUBSTR ( :str
, '[^,]+'
, 1
, LEVEL
) AS str_part
FROM dual
CONNECT BY LEVEL <= 1 + REGEXP_COUNT (:str, ',')
I'm just guessing that your original string doesn't include single-quotes after VR or before VM. If it does, you can use TRIM to remove them from the string passed back by REGEXP_SUBSTR. -
Insert missing rows from another table
Hi
I need to insert rows from another table if there is gaps in my transaction table. For each ärendenr there should be 5 Id status rows (1-5). Except for the fact that the inserted rows never should have higher IdStatus number then the highest value from
the transaction for each Ärendenr. See my example below that illustrates my transaction table, Stages master and the desired result.
Is there some t sql code that could handle this problem?
Best regards
Arne
So far i have tried to solve this with the code below but it doesnt work.
I have copied the transaction file information to the TempLogTransTimes
and then insert into LogTransTimes
IF OBJECT_ID('dbo.TempLogTransTimes', 'U') IS NOT NULL --Här raderas den tillfälliga tabellen
DROP TABLE dbo.TempLogTransTimes;
SELECT *
INTO TempLogTransTimes
FROM LogTransTimes
DECLARE @TopÄrende INT
WHILE EXISTS(SELECT * FROM TempLogTransTimes)
BEGIN
SET @TopÄrende = (SELECT TOP(1) Ärendenr FROM TempLogTransTimes ORDER BY Ärendenr)
INSERT INTO LogTransTimes(Ärendenr, IdStatus, StatusNamn, SourceId)
SELECT @TopÄrende, SM.IdStatus, SM.StatusNamn, 'Beräkning'
FROM Statusmall SM
FULL JOIN TempLogTransTimes LT ON SM.IdStatus = LT.IdStatus
WHERE LT.IdStatus IS NULL
DELETE TempLogTransTimes WHERE Ärendenr = @TopÄrende
END
Arne OlssonHi Arne Olsson, try this..
DECLARE @Transactions TABLE
Id1 INT,
IdStatus INT,
StatusName VARCHAR(10)
DECLARE @Stages TABLE
IdStatus INT,
StatusName VARCHAR(10)
INSERT INTO @Transactions VALUES(1,1,'AA'), (1,3,'CC'), (1,5,'EE'), (2,1,'AA'), (2,3,'CC')
INSERT INTO @Stages VALUES (1,'AA'), (2,'BB'), (3,'CC'), (4,'DD'), (5,'EE')
;WITH CTE AS(SELECT DISTINCT Id1 FROM @Transactions)
SELECT Id1, IdStatus, StatusName FROM CTE, @Stages
EXCEPT
SELECT Id1, IdStatus, StatusName FROM @Transactions
Please mark as answer, if this has helped you solve the issue.
Good Luck :) .. visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles. -
Set of string into array or a table....
Hi Experts,
I am using Oracle 10G, where I need to accomplish a task...
I am getting a set of string of the sort
"|session_id~q_id~q_key~rt_id~rt_key~request_type~field_id|session_id~q_id~q_key~rt_id~rt_key~request_type~field_id| ....."
Here, as you can see every set which has 7 values is delimited by a "| (pipe)" and every value is delimited by a "~" ...
I need to insert all these into a generic table and before doing that I need to split it into individual values where every set which has 7 values will get into 7 columns in a row...
Can anyone help me out with a proper logic as to how do i go about accomplishing the same...???Hi,
You have to use regular expression to tokenize string in fragments.
This is sample for determining CRLF in a string:
-- Tokenize rows
FOR token IN ( SELECT REGEXP_REPLACE(REGEXP_SUBSTR(XMLCDATA('custom_string') || Chr(10), '(.*' || Chr(10) || ')', 1, LEVEL ), Chr(10), '') t
FROM dual
CONNECT BY REGEXP_INSTR('custom_string'||Chr(10), '(.*'||Chr(10)||')',1, LEVEL ) > 0) LOOP
token.t --> single fragment
END LOOP;
Bear in mind that this forum is for Data Modeler product related issues, feedback etc. So before posting question search for appropriate forum. It's quite possible that you won't get answer while in wrong forum.
Regards
Edited by: Dimitar Slavov on Apr 15, 2011 2:11 AM -
Update row in a table based on join on multiple rows in another table
I am using SQL Server 2005. I have the following update query which is not working as desired.
UPDATE DocPlant
SET DocHistory = DocHistory + CONVERT(VARCHAR(20), PA.ActionDate, 100) + ' - ' + PA.ActionLog + '. '
FROM PlantDoc PD INNER JOIN PlantAction PA on PD.DocID = PA.DocID AND PD.PlantID = PA.PlantID
For each DocID and PlantID in PlantDoc table there are multiple rows in PlantAction table. I would like to concatenate ActionDate and ActionLog information into DocHistory column of DocPlant table. But the above update query is considering only one row from
PlantAction table even though there are multiple rows that match with DocID and PlantID.
DocHistory column is of type NVARCHAR(MAX).
How do I fix my query to achieve what I want ? Thanks for the help.UPDATE DocPlant
SET DocHistory = DocHistory + CONVERT(VARCHAR(20), PA.ActionDate, 100) + ' - ' + PA.ActionLog + '. '
FROM PlantDoc PD INNER JOIN PlantAction PA on PD.DocID = PA.DocID AND PD.PlantID = PA.PlantID
We do not use the old Sybase UPDATE..FROM.. syntax. Google it and learn how it does not work. We do not use the old Sybase CONVERT() string function. You are still writing 1950's COBOL with string dates instead of temeproal data types.
You also did not post DDL, so we have to guess about everything. Does your boss make you work without DDL? How do you do it?
>> For each DocID and PlantID in PlantDoc table there are multiple rows in PlantAction [singular name?] table. I would like to concatenate ActionDate and ActionLog information into DocHistory column of DocPlant table. <<
Why? What does this new data element mean? This is like dividing Thursday by Red and expecting a reasonable answer. Now, non-SQL programmers who are still writing COBOL will violate the tiered architecture rule about doing display formatting in the database.
If you will follow forum rules, we can help you.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Connecting Each row to another Table
Hi
This probably isnt the JDBC question but can some one tell me how to Connect each row of a column to another Table.
I have a Table with two columns Name and UserID. I want to connect each UserID to another Table. like User01 will be connected to another table called burn table for user01. User 02 will be connected to another table called burn table for user 02. Each table for user01 and user02 has 3 columns: CDName, EULA, License Key.
I read about primary and foreign keys but can some one give me a hint on this about how to start on it?
And if i get this done, then how would i execute a SQL query command so that I can read the data for each user. I am using java Servlets.
I am new sorry.
-bhaarati agree with you that making seperate table for each
user is terrible and i would be ashamed to present
this projec to anyone.
how do you think i should design this database other
than what i have suggested..
i might have alredy explained what the database is
doing but let me do that again..
1. There are about 150 or more CD's from MS.
2. Each user is able to burn a cd once only. for
example if user has already burned xp pro he cant burn
again.
3. there are about 600 or more users(thats why making
each table for each user is wrong, eventhough some one
else will be doing it, instead of me).
4. each cd has a license key associated with it.
please suggest me how i should do this database so its
not much of a hazzle and i dont have to pay some one
100 an hour so fix the problems lol.okay first i am going to list out the table designs and then I am going to provide some explanations
tblUser
username VARCHAR PRIMARY KEY
firstname VARCHAR
lastname VARCHAR
tblCD
cdname VARCHAR PRIMARY KEY
licensekey VARCHAR PRIMARY KEY
eula VARCHAR or TEXT
tblUserCD
username VARCHAR PRIMARY KEY
cdname VARCHAR PRIMARY KEY
licensekey VARCHAR PRIMARY KEY
so what's happening here...
well we have a table for users.. since we need a unique key i am using username... this could be the
name for someone uses to login to your system.
there is a different table that is list of all the cds. the primary key for this one is both the name and license together.
then there is a table that builds a relationship between the two.
in this scheme each user may download or whatnot each cd zero or one times. you can't put a second
download in because that will violate the primary key of tblUserCD
now let's look at some sample data
if the user table has this....
username----firstname----lastname
jsmith----------John----------Smith
aadams-------Audrey--------Adams
and the CD table has this
cdname----license----eula
Access-----12345----blah blah
Word--------12356----blah blah
Windows---99999---blah blah
then we do the following queries when John wants to get Access and Windows and Audrey wants to get Word and Access.
INSERT INTO tblUserCD(username,cdname,licensekey) VALUES('jsmith','Access','12345');
INSERT INTO tblUserCD(username,cdname,licensekey) VALUES('jsmith',Windows,'99999');
INSERT INTO tblUserCD(username,cdname,licensekey) VALUES('aadams','Word','12356');
INSERT INTO tblUserCD(username,cdname,licensekey) VALUES('aadams','Access','12345');
now if you want to get the list of program for any user (example John Smith) you just do this....
SELECT cdname FROM tblUserCD WHERE username='jsmith'
which gives you this
cdname
Access
Windows
there are several pluses to this design
1) as I alluded to earlier this design prevents you putting in the same cd and license key more than once for each user
2) You now can get a nice list of all the CD's easily.
SELECT cdname,licensekety FROM tblCD;
3) if you need to make any changes, like a persons username or more likely the cd stuff then it is easier to do so.. for example in your old design if you wanted to change Access to Access XP you would have to change EVERY table. in the new model you can do this in two queries.
UPDATE tblCD SET cdname='Access XP' WHERE cdname='Access' AND licensekey='12345';
UPDATE tblUserCD SET cdname='Access XP' WHERE cdname='Access' AND licensekey='12345';
(actually if you set up the keys properly and to cascade changes then you would just need the one query)
there is actually a theory for this sort of timesaving and error prevention work called normal form data.
for your further "enjoyment" may I suggest reading this http://databasejournal.com/sqletc/article.php/1443021
anyway hope this helps you out....
does this make sense to you? -
Hi ,
I have a table with 20 records and 10 columns.I want to add columns from another table with out cross join.As others have said, you need to have some sort of join condition otherwise it is a cross join.
SQL> ed
Wrote file afiedt.buf
1 with T1 as (select 'e' as c1, 2 as c2 from dual union all
2 select 'd', 3 from dual)
3 ,T2 as (select 'x' as c3, 5 as c4 from dual union all
4 select 'y', 6 from dual union all
5 select 'z', 2 from dual)
6 --
7 select T2.c3, T2.c4, T1.c1, T1.c2
8 FROM (select c1, c2, row_number() over (order by c1) as rn from T1) T1
9 FULL OUTER JOIN
10 (select c3, c4, row_number() over (order by c3) as rn from T2) T2
11* ON (T1.rn = T2.rn)
SQL> /
C C4 C C2
x 5 d 3
y 6 e 2
z 2
SQL>This example assigns a row number to each row within each table and then joins using that row number.
(I've assumed the row number should be generated based on the order of the first column of each table, but you can change that as required).
What is the point of your requirement? -
How to convert column with delimited string into rows
I have a string value in a single column, delimited by colon. The number of items in the string is variable. I need to select the data from this column into separate rows based on the delimiter. I can write a function with a loop but if there is a way to do this in SQL it would be better.
Table contains a column with data value:
12:130:1400
And I want to select data and return as:
12
130
1400
This in in Oracle 9i.
Please don't post "look for pivot or transpose in the forum" as that is not a helpful answer (I have already done that).
Thanks!
Message was edited by:
splinternetSQL> create table mytable (id,value)
2 as
3 select 1, '12:130:1400' from dual union all
4 select 2, '483' from dual union all
5 select 3, '1:2:3:4:5:6:77:888' from dual union all
6 select 4, null from dual
7 /
Tabel is aangemaakt.
SQL> select id
2 , trim(':' from v) value
3 , substr
4 ( v
5 , instr(v,':',1,t.column_value) + 1
6 , instr(v,':',1,1 + t.column_value)
7 - instr(v,':',1,t.column_value) - 1
8 ) part
9 from ( select id, ':' || value || ':' v from mytable ) m
10 , table
11 ( cast
12 ( multiset
13 ( select level l
14 from dual
15 connect by rownum <= length(m.v) - length(replace(m.v,':')) - 1
16 )
17 as sys.dbms_debug_vc2coll
18 )
19 ) t
20 order by m.id
21 , t.column_value
22 /
ID VALUE PART
1 12:130:1400 12
1 12:130:1400 130
1 12:130:1400 1400
2 483 483
3 1:2:3:4:5:6:77:888 1
3 1:2:3:4:5:6:77:888 2
3 1:2:3:4:5:6:77:888 3
3 1:2:3:4:5:6:77:888 4
3 1:2:3:4:5:6:77:888 5
3 1:2:3:4:5:6:77:888 6
3 1:2:3:4:5:6:77:888 77
3 1:2:3:4:5:6:77:888 888
4
13 rijen zijn geselecteerd.Regards,
Rob. -
How to split a delimited string into rows
Hi Everyone,
I have a field in my EMPLOYEE table named "OLD_USER_IDS" which stores all the old system ID's that the employee was once assigned to. This field is comma separated like so: "USERID1,USERID2,USERID3". My question is: how can I write a SELECT query that splits each individual User ID into its own row?
For example:
EMP_ID USER_ID
10 USERID1
10 USERID2
12 USERID3
15 USERID4
15 USERID5
15 USERID6
Thank You
-SamI think you should search this forum first for similar questions. I keep track of some interesting stuffs posted in this forum in a file, and from that
WITH t AS (SELECT 'USER1,USER2,USER3' str FROM DUAL
select substr(str,
decode(level,
1,
1,
instr(str, ',', 1, level - 1) + 1),
decode(instr(str, ',', 1, level),
0,
length(str),
instr(str, ',', 1, level) -
decode(level,
1,
0,
instr(str, ',', 1, level - 1)) - 1)) the_value
from (select str from t)
connect by level <=
length(str) - length(replace(str, ',')) + 1; -
I have a table that contains unit rules with one column containing the unit code and another containing the rule text eg.
Unit Code xyz
Rule Text Unit was previously coded {20017, A1537, A2524}
I need to list the old codes in a new table in seperate rows.
Any ideas please?
Thanx
Rob.MJ
The column names are:
Unit_cd || Rule_text
xyz || Unit was previously coded {20017, A1537, A2524}
Output I would like is:
Unit_cd || Prevoius_unit_cd
xyz || 20017
xyz || A1537
xyz || A2524
Not all rules have three valuse, most are single values and some even more.
Thanx
Rob.
Edited by: Rob Mc on Aug 29, 2008 2:52 PM
Edited by: Rob Mc on Aug 29, 2008 2:54 PM
Edited by: Rob Mc on Aug 29, 2008 2:55 PM -
Pipe delimiter string into rows using regular expression
hi Can anyone please help writing pipe' l 'delimiter values to rows
sample data 'something1|something2|something3'
i tried with below query
SELECT LEVEL,
TRIM ('"' FROM RTRIM (REGEXP_SUBSTR ('something1|something2|something3' || '|',
'".*?"||[^|]*|',
1,
LEVEL
'|'
) sub_str
FROM dual
CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE ('something1|something2|something3' , '".*?"|[^|]*')) + 1SQL> ed
Wrote file afiedt.buf
1 with t as (select 'something1|something2|something3' as txt from dual)
2 -- end of sample data
3 select REGEXP_SUBSTR (txt, '[^|]+', 1, level)
4 from t
5* connect by level <= length(regexp_replace(txt,'[^|]*'))+1
SQL> /
REGEXP_SUBSTR(TXT,'[^|]+',1,LEVE
something1
something2
something3
SQL> -
Decide to insert into one or another table
Hi guys,
I have the following problem:
Need to run a process which inserts records into TABLE A (COL1, COL2, COL3), but then if COL3 = 3 then I have to insert the current record in TABLE B without inserting in table A.
Table A = Table B in structure.
I cannot modify the process to do this as I will loose my warranty period, so I think it can be possible to do it by triggers, as I thought in "INSTEAD OF" but this solution only apply (I guess) to views.
Any clues?
Thanks in Advance.
-EdI figured out this code. The only thing is that is crying for the null insert (ORA-01400 cannot insert null).
What I want to see is if this error will cut the insertion process as a whole.
Let me know your comments please and thanks for help.
CREATE OR REPLACE TRIGGER SCOTT.TRG_INDICES_INS
BEFORE INSERT
ON SCOTT.INDICES
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
falla EXCEPTION;
pragma AUTONOMOUS_TRANSACTION;
BEGIN
IF :NEW.col1 = 1
THEN
RAISE falla;
END IF;
EXCEPTION
WHEN falla
THEN
INSERT INTO asoc
VALUES (:NEW.col1, :NEW.col2, :NEW.col3);
COMMIT;
:NEW.COL1:=NULL;
-- INDICES TABLE ATTRIBUTES CANNOT BE NULL
WHEN OTHERS
THEN
null;
END trg_indices_ins; -
How to populate rows from another table in new blank rows of other table
I have to convert an oracle form 6i to Jdeveloper application. In forms 6i we use create a cursor for other table and then populate the current table data block row using create record and assigning its values from cursor and then issuing next record until all cursor records are written in data block. After some manual editing we save the whole form and then all block records are saved as new rows in table.
Now how to create this functionality in jdeveloper application.
Kindly help.two steps-
1. get row from first VO.iterate them - like below -
DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcIteratorBindings = bindings.findIteratorBinding("ViewObj1Iterator");
HSSFRow excelrow = null;
// Get all the rows of a iterator
oracle.jbo.Row[] rows = dcIteratorBindings.getAllRowsInRange();
int i = 0;
for (oracle.jbo.Row row : rows) {
row.getAttribute(colName).toString()); // by this you can get row attribute value..
2. inside iteration create row for VO 2 for example-
ViewObject employee= findViewObject("EmployeeVO");
// Create a row and fill in the columns.
Row row = employee.createRow();
row.setAttribute("Name", "Vinay");
row.setAttribute("EmpId", 1);
//Insert row in to the default row set
employee.insertRow(row);
Read more: http://www.techartifact.com/blogs/2012/12/creating-new-row-of-view-object-in-adf-techartifact.html#ixzz2iL978UOD
http://www.techartifact.com/blogs/2012/12/creating-new-row-of-view-object-in-adf-techartifact.html -
How to show data in table on the basis of click on a row of another table
Hi All,
I want to show two tables. In first table the main objects show in turn there is another collection in that main object for which i want to show data in separate table.
e.g.,
ObjectA
have the collection of ObjectBs
when i select ObjectA in main table then all the collection Objects of ObjectBs shows in separate table. Plz help me how to handle this case ??hi,
You can create two value nodes for storing these collections. The first one would be singleton node as it is the main list. Under that create the second node with singleton = false.
e.g.
---NodeA
--attrA1
--attrA2
--NodeB(singleton = false)
--attrB1
--attrB2
Now populate collection of object A in NodeA and after adding element in NodeA populate respective elements in NodeB.
IPrivate<View>View.INodeANode nodeA = wdContext.NodeAnode();
for (Iterator it = collectionA.iterator(); it.hasNext(); )
ObjectA objA= it.next();
IPrivate<View>View.INodeAElement nodeAElem= nodeA.createNodeAElement();
wdCopyservice.copy Corresponding(objA,nodeAElem);
nodeA.addElement(nodeAElem);
Collection collectioB =objA.getCollectionB();
for (Iterator it1 = collectionB.iterator(); it1.hasNext(); )
ObjectB objB= it1.next();
IPrivate<View>View.INodeBNode nodeB = nodeAElem.nodeBnode();
IPrivate<View>View.INodeAElement nodeBElem= nodeB.createNodeBElement();
wdCopyservice.copy Corresponding(objB,nodeBElem);
nodeB.addElement(nodeBElem);
Bind NodeA to the first table and NodeB to second one.
After that when you select record in first table automatically its corresponding records will be populated in second table.
Hope this helps!
Monalisa -
Update one row based on a row from another table
Hi,
I have two tables which are having the same field but with a different name.
CREATE TABLE FAVE_CODE2_NEW_JOIN
BANKID VARCHAR2(5 BYTE) NOT NULL,
CUSTOMERID VARCHAR2(12 BYTE) NOT NULL,
SIXID VARCHAR2(12 BYTE) NOT NULL,
FAVCODE VARCHAR2(13 BYTE),
IDX NUMBER(5),
DEFAULTT NUMBER(1)
TABLESPACE PORTFOLIO_FAVORITE
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
CREATE TABLE SUBSCRIPTION
SUBSCRIPTIONID RAW(16) NOT NULL,
APPID VARCHAR2(64 BYTE) NOT NULL,
DEVICEID VARCHAR2(64 BYTE),
SUBSCRIBERID NUMBER NOT NULL,
TIME_REGISTERED TIMESTAMP(6) DEFAULT SYSTIMESTAMP NOT NULL,
TIME_LAST_USED TIMESTAMP(6) DEFAULT SYSTIMESTAMP NOT NULL,
SUBSCRIPTION_TYPE VARCHAR2(30 BYTE) NOT NULL,
SUBSCRIPTION_INFO VARCHAR2(512 BYTE)
TABLESPACE PORTFOLIO_FAVORITE
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 64K
NEXT 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
SUBSCRIPTION_INFO in SUBSCRIPTION is equal to SIXID in FAVE_CODE2_NEW_JOIN. They have the same value
In FAVE_CODE2_NEW_JOIN table there is also a FAVCODE filed.
Now i want to find out the record from VE_CODE2_NEW_JOIN which are having the same sixid like SUBSCRIPTION_INFO in SUBSCRIPTION and then replace that SUBSCRIPTION_INFO with the value in FAVCODE
Here are some sample from both tables:
SUBSCRIPTION:
B31E5F5D3CB6 RIe9pnbe7BtA8IuQ BB2-58CA815F9958 21 2012-01-10 19:18:39 2012-01-11 12:24:04 FT FSB0650444
010FB3AE74AE RIe9pnbe7BtA8IuQ 845-AD375E95ED90 21 2012-01-12 08:31:47 2012-01-24 08:53:09 FT FSB0650444
6119E731A26F RIe9pnbe7BtA8IuQ 76A-DAD2E359BF3F 113 2012-01-04 00:25:05 2012-01-19 16:17:21 FT FSB0632948
FAVE_CODE2_NEW_JOIN:
08999 191111111111 FSB0650444 SWB0553263 11 0
As you see they both have the same 'FSB0650368' but i want to replace this code with the corresponding FAVCODE in FAVE_CODE2_NEW_JOIN which is 'SWB0553263'.
I hope you have got what i mean, please tell me to explain more if you have any problem to understand what i mean.
Many thanks in Advance!
/ HesamHesam wrote:
hi,
I'm trying this code:
update subscription a
set a.subscription_info =
select b.favcode
from fave_code2_new_join b
where b.sixid = a.subscription_info
where exists
select b.favcode
from fave_code2_new_join b
where b.sixid = a.subscription_info
)but its taking a lot of time. Until now 10 minutes and lots of presure on the CPU!!
Can we optimize this or its just due to the number of records?
Edited by: Hesam on Mar 25, 2013 3:01 PMSo now you are getting into performance issues?
I would suggest you read {message:id=9360003} and post the necessory details so that we can see what can be improved and how.
Maybe you are looking for
-
How to display data in the same tab components ?
Hi, I have a tabbed pane and contains 3 tabs. I have entered some value in the text field and clicked the enter button in the 3rd tab.This enter button contains some validation code and after validation it will display some data in the text area in t
-
I have been tring to convert PAL-DV to NTSC for some time now from Media 100 8.2.2 through both Compressor & JES. I have searched most of the posts here in Compressor/DVDSP & Creative Cow. My problem is that if I export from Media 100 as by-ref file
-
Installing Vista after replacing hard drive in a Toshiba Satellite L45-57423
The hard drive in my old Toshiba laptop went bad and had to be replaced. I no longer have (and am unsure I ever had) the Windows recovery disk. Do I need to purchase a new Windows Vista recovery disk for this computer or is it better to buy a Windows
-
T520 hotkeys stopped working on Win 8
I upated some apps like: PM, Bluetooth drivers and some more which had updates in 2013 (since I last upated in 2012) and hotkeys doesn't work. For example Fn+F5 just turns off wifi through windows 8. Fn+F8 doesn't work either. Please help.
-
Trigger - Identifying Modified Columns
Hi All, I have created AFTER INSERT OR DELETE OR UPDATE FOR EACH ROW trigger. To audit the changes, if update or delete performed old values will get insert into PRM_CURFILEDATE_AUDIT and if insert happen new values will get insert. In PRM_CURFILEDAT