One of our developers is creating a table.........
Code:
CREATE TABLE TAB1 AS
select t.*, CASE WHEN p.plan_date is NULL THEN null ELSE p.plan_date END plan_date
from w_card_transaction t, tmp_df_plans p
where t.account_org = p.account_org(+)
and t.account_number = p.account_number(+)
and t.statement_id_code = p.statement_id_code(+)
and t.statement_sequence_number = p.statement_sequence_number(+);
The plan says it will use 434 M of tempspace.......
Are you sure that it is the segment in the temp tablespace that is raising the error, not the temporary segment created in the permanent tablespace that houses the result set and which will get turned into TAB1 on completion of the CTAS?
Definately the temp tablespace Dave. Upped it from 10 G to 20 G and it still fills up then crashes out. Tried an 'order by' clause in the CTAS in an attempt to stop it sorting in temp, but to no avail.
Gandolf, I might be being a bit thick here, but how would I incorporate the nvl clause into the code? And how would that help this situation?
Definately the temp tablespace Dave. Upped it from 10 G to 20 G and it still fills up then crashes out. Tried an 'order by' clause in the CTAS in an attempt to stop it sorting in temp, but to no avail.
Gandolf, I might be being a bit thick here, but how would I incorporate the nvl clause into the code? And how would that help this situation?
Thanks......
Code:
CREATE TABLE TAB1 AS
SELECT t.*, NVL(p.plan_date, p.plan_date) plan_date
FROM w_card_transaction t
LEFT OUTER JOIN tmp_df_plans p
ON t.account_org = p.account_org
AND t.account_number = p.account_number
AND t.statement_id_code = p.statement_id_code
AND t.statement_sequence_number = p.statement_sequence_number;
That the explain plan does not show cartesian product is no guarantee that you are not getting one. What are the primary keys of the two tables? Are you joining on more or less columns than you need? Would an index make the sort more efficient?
CREATE TABLE TAB1 AS
SELECT t.*, NVL(p.plan_date, t.plan_date) plan_date
FROM w_card_transaction t
LEFT OUTER JOIN tmp_df_plans p
ON t.account_org = p.account_org
AND t.account_number = p.account_number
AND t.statement_id_code = p.statement_id_code
AND t.statement_sequence_number = p.statement_sequence_number;
I want to populate TAB1 with plan_date from p.
If the outer join returns NULL, then NULL is inserted in the new column. If NOT NULL, i.e., a row exists in p. that is not null, then populate the new column with the not null value from p.
I eventually upper the tempspace to 25G and the table created successfully. I might try to add an index, to test your theory, but surely the optimiser would use the primary key index if it chose to do so.
I want to populate TAB1 with plan_date from p.
If the outer join returns NULL, then NULL is inserted in the new column. If NOT NULL, i.e., a row exists in p. that is not null, then populate the new column with the not null value from p.
Originally Posted by Horace
Code:
CREATE TABLE TAB1 AS
select t.*, CASE WHEN p.plan_date is NULL THEN null ELSE p.plan_date END plan_date
from w_card_transaction t, tmp_df_plans p
where t.account_org = p.account_org(+) ....
So, what's wrong with plain and simple:
Code:
CREATE TABLE TAB1 AS
select t.*, p.plan_date
from w_card_transaction t, tmp_df_plans p
where t.account_org = p.account_org(+) ....
Where is the difference?
Jurij Modic ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
Bookmarks