Problem with MERGE statement
Hi All,
We are encountering a strange problem with the merge command.
The following statement works :-
merge into ATTRIBUTE_GROUP@US_PRODUCT_UAT a
using
select
a1.group_id,
a1.NAME,
a1.CREATE_DATE,
a1.MODIFY_DATE
from
ATTRIBUTE_GROUP_LOG a1,
product_push_wrk a2
where
a2.column_id = a1.group_id and
a2.modify_date = a1.modify_date ) b
on ( a.group_id = b.group_id)
when matched then
update set
a.NAME = b.NAME,
a.CREATE_DATE = b.CREATE_DATE,
a.MODIFY_DATE = b.MODIFY_DATE
when not matched then
insert
a.group_id,
a.NAME,
a.CREATE_DATE,
a.MODIFY_DATE
values
b.group_id,
b.NAME,
b.CREATE_DATE,
b.MODIFY_DATE
However when we change the order of the columns in the select query as follows the an error occurs : -
merge into ATTRIBUTE_GROUP@US_PRODUCT_UAT a
using
select
a1.NAME,
a1.group_id,
a1.CREATE_DATE,
a1.MODIFY_DATE
from
ATTRIBUTE_GROUP_LOG a1,
product_push_wrk a2
where
a2.column_id = a1.group_id and
a2.modify_date = a1.modify_date ) b
on ( a.group_id = b.group_id)
when matched then
update set
a.NAME = b.NAME,
a.CREATE_DATE = b.CREATE_DATE,
a.MODIFY_DATE = b.MODIFY_DATE
when not matched then
insert
a.group_id,
a.NAME,
a.CREATE_DATE,
a.MODIFY_DATE
values
b.group_id,
b.NAME,
b.CREATE_DATE,
b.MODIFY_DATE
ERROR at line 15:
ORA-00904: "B"."GROUP_ID": invalid identifier
SQL> l 15
15* on ( a.group_id = b.group_id)
The structure of the attribute_log table is as follows :-
SQL> desc ATTRIBUTE_GROUP
Name Null? Type
GROUP_ID NOT NULL NUMBER
NAME NOT NULL VARCHAR2(96)
CREATE_DATE NOT NULL DATE
MODIFY_DATE NOT NULL DATE
Any pointers to the cause of this error will be highly appreciated.
Thanks and Regards,
Suman
The table structures are as follows :-
04:17:17 SQL> desc product_push_wrk
Name Null? Type
COLUMN_ID NOT NULL NUMBER
TYPE NOT NULL VARCHAR2(10)
PARENT_COLUMN_ID NUMBER
LEVEL_NO NUMBER
MODIFY_DATE NOT NULL DATE
04:17:25 SQL> desc ATTRIBUTE_GROUP_LOG
Name Null? Type
GROUP_ID NOT NULL NUMBER
NAME NOT NULL VARCHAR2(96)
CREATE_DATE DATE
MODIFY_DATE DATE
04:18:02 SQL> desc ATTRIBUTE_GROUP
Name Null? Type
GROUP_ID NOT NULL NUMBER
NAME NOT NULL VARCHAR2(96)
CREATE_DATE DATE
MODIFY_DATE DATE
Similar Messages
-
Performance problem with MERGE statement
Version : 11.1.0.7.0
I have an insert statement like following which is taking less than 2 secs to complete and inserts around 4000 rows:
INSERT INTO sch.tab1
(c1,c2,c3)
SELECT c1,c2,c3
FROM sch1.tab1@dblink
WHERE c1 IN (SELECT c1 FROM sch1.tab2@dblink);I wanted to change it to a MERGE statement just to avoid duplicate data. I changed it to following :
MERGE INTO sch.tab1 t1
USING (SELECT c1,c2,c3
FROM sch1.tab1@dblink
WHERE c1 IN (SELECT c1 FROM sch1.tab2@dblink) t2
ON (t1.c1 = t2.c1)
WHEN NOT MATCHED THEN
INSERT (t1.c1,t1.c2,t1.c3)
VALUES (t2.c1,t2.c2,t2.c3);The MERGE statement is taking more than 2 mins (and I stopped the execution after that). I removed the WHERE clause subquery inside the subquery of the USING section and it executed in 1 sec.
If I execute the same select statement with the WHERE clause outside the MERGE statement, it takes just 1 sec to return the data.
Is there any known issue with MERGE statement while implementing using above scenario?riedelme wrote:
Are your join columns indexed?
Yes, the join columns are indexed.
You are doing a remote query inside the merge; remote queries can slow things down. Do you have to select all thr rows from the remote table? What if you copied them locally using a materialized view?Yes, I agree that remote queries will slow things down. But the same is not happening while select, insert and pl/sql. It happens only when we are using MERGE. I have to test what happens if we use a subquery refering to a local table or materialized view. Even if it works, I think there is still a problem with MERGE in case of remote subqueries (atleast till I test local queries). I wish some one can test similar scenarios so that we can know whether it is a genuine problem or some specific problem from my side.
>
BTW, I haven't had great luck with MERGE either :(. Last time I tried to use it I found it faster to use a loop with insert/update logic.
Edited by: riedelme on Jul 28, 2009 12:12 PM:) I used the same to overcome this situation. I think MERGE needs to be still improved functionally from Oracle side. I personally feel that it is one of the robust features to grace SQL or PL/SQL. -
Problem with READ Statement in the field routine of the Transformation
Hi,
I have problem with read statement with binary search in the field routine of the transformation.
read statement is working well when i was checked in the debugging mode, it's not working properly for the bulk load in the background. below are the steps i have implemented in my requirement.
1. I selected the record from the lookuo DSO into one internal table for all entried in source_packeage.
2.i have read same internal table in the field routine for each source_package entry and i am setting the flag for that field .
Code in the start routine
select source accno end_dt acctp from zcam_o11
into table it_zcam
for all entries in source_package
where source = source_package-source
and accno = source_package-accno.
if sy-subrc = 0.
delete it_zcam where acctp <> 3.
delete it_zcam where end_dt initial.
sort it_zcam by surce accno.
endif.
field routine code:
read table it_zcam with key source = source_package-source
accno = source_package-accno
binary search
transportin no fields.
if sy-subrc = 0.
RESULT = 'Y'.
else.
RESULT = 'N'.
endif.
this piece of code exist in the other model there its working fine.when comes to my code it's not working properly, but when i debug the transformation it's working fine for those accno.
the problem is when i do full load the code is not working properly and populating the wrong value in the RESULT field.
this field i am using in the report filter.
please let me know if anybody has the soluton or reason for this strage behaviour.
thanks,
Rahim.i suppose the below is not the actual code. active table of dso would be /bic/azcam_o1100...
1. is the key of zcam_o11 source and accno ?
2. you need to get the sortout of if endif (see code below)
select source accno end_dt acctp from zcam_o11
into table it_zcam
for all entries in source_package
where source = source_package-source
and accno = source_package-accno.
if sy-subrc = 0.
delete it_zcam where acctp 3.
delete it_zcam where end_dt initial.
endif.
sort it_zcam by surce accno.
field routine code:
read table it_zcam with key source = source_package-source
accno = source_package-accno
binary search
transportin no fields.
if sy-subrc = 0.
RESULT = 'Y'.
else.
RESULT = 'N'.
endif. -
Hi Experts,
I have 2 problems with merging accounts:
1) Opportunity is not moved from source data to master data. I do not know why. Central BP is changable.
2) Contact Person is only copied, not moved. This causes problems later on when we want to delete the source data.
Any idea how to solve this?
Best regards,
CristinaHi Arno:
First of all: Thanks for answering my thread!
The problem with opportunities in my system is, that they are not merged at all, not even with the batch job. I checked trx. BUSWU02. Node CRM370 is assigned to variant CLEAR_REP.
Also the central Business Partner in opportunity remains changable, once the opportunity was saved.
Anything else I have to check??
Best regards,
Cristina -
Problem with merge using package (row)variable
We're doing an ETL project, where we have to validate data coming from staging tables before inserting / updating them in our data tables.
We use a validate function for this, in which we 'test' our mappings and business logic, and returns 'OK' if no errors were occured.This function is called in the WHERE clause, and populates a package row variable. From this variable, values are read in the insert / update statement, using a get function.
The problem is that sometimes, with a data set with NO duplicate keys, we get an ORA-00001 error, and sometimes not.
Does anyone have any idea why this error could occur ? We're on Oracle 9.2.0.5.0.
For the demo mentioned below, the following statement fails , while it succeeds if we add 'and rownum < 11' to the where clause :
merge into target_tab t
using (select st.* from source_tab st where demo_pack.assign_var(st.attrib_1, st.attrib_2, st.attrib_3) = 'OK') s
on (t.attrib_1 = s.attrib_1 and
t.attrib_2 = s.attrib_2)
when matched then update
set t.attrib_3 = demo_pack.get_attrib('ATTRIB_3')
when not matched then
insert(attrib_1, attrib_2, attrib_3)
values (demo_pack.get_attrib('ATTRIB_1'), demo_pack.get_attrib('ATTRIB_2'), demo_pack.get_attrib('ATTRIB_3'));
Can anyone explain to me why this statement sometimes fails, and other times not ?
Thanks in advance .
demo tables / packages :
create table source_tab
attrib_1 varchar2(30),
attrib_2 varchar2(30),
attrib_3 varchar2(200)
create table target_tab
attrib_1 varchar2(30) not null,
attrib_2 varchar2(30) not null,
attrib_3 varchar2(200),
constraint pk_target_tab primary key(attrib_1, attrib_2)
insert into source_tab
select table_name, column_name, data_type
from user_tab_columns;
commit;
create or replace package demo_pack as
function assign_var(p_attrib_1 in target_tab.attrib_1%type,
p_attrib_2 in target_tab.attrib_2%type,
p_attrib_3 in target_tab.attrib_3%type) return varchar2;
function get_attrib(p_name in varchar2) return varchar2;
end;
create or replace package body demo_pack as
g_rec target_tab%rowtype;
function assign_var(p_attrib_1 in target_tab.attrib_1%type,
p_attrib_2 in target_tab.attrib_2%type,
p_attrib_3 in target_tab.attrib_3%type) return varchar2 is
begin
g_rec.attrib_1 := p_attrib_1;
g_rec.attrib_2 := p_attrib_2;
g_rec.attrib_3 := p_attrib_3;
return 'OK';
end;
function get_attrib(p_name in varchar2) return varchar2 is
l_return varchar2(200);
begin
if p_name = 'ATTRIB_1' then
l_return := g_rec.attrib_1;
elsif p_name = 'ATTRIB_2' then
l_return := g_rec.attrib_2;
elsif p_name = 'ATTRIB_3' then
l_return := g_rec.attrib_3;
end if;
return l_return;
end;
end;
/It's not necessarily that the problem is within your package code. As long as UNIQUE constraint exists on DEST table, any MERGE statement may fail with ORA-00001 due to concurrent updates and inserts taking place.
Of course, it's just my guess but consider the following scenario (three sessions modify DEST table in parallel – and to keep this example clear, I put their commands in chronological order):
S#1> create table dest(x primary key, y) as
2 select rownum, rownum
3 from dual
4 connect by level <= 5;
Table created.
S#1> create table src(x, y) as
2 select rownum + 1, rownum + 1
3 from dual
4 connect by level <= 5;
Table created.
S#1> select * from src;
X Y
2 2
3 3
4 4
5 5
6 6
S#1> select * from dest;
X Y
1 1
2 2
3 3
4 4
5 5
S#2> -- Now, session #2 will update one row in DEST table
S#2> update dest
2 set y = 40
3 where x = 4;
1 row updated.
S#2> select * from dest;
X Y
1 1
2 2
3 3
4 40
5 5
S#1> -- Session #1 issues the following MERGE:
S#1> merge into dest d
2 using (select * from src) s
3 on (s.x = d.x)
4 when matched then update set d.y = s.y
5 when not matched then insert (d.x, d.y)
6 values (s.x, s.y);
-- At this point, session #1 becomes blocked as it can not modify row locked by session #2
S#3> -- Now, session #3 inserts new row into DEST and commits.
S#3> -- MERGE in session #1 is still blocked.
S#3> insert into dest values (6, 6);
1 row created.
S#3> select * from dest;
X Y
1 1
2 2
3 3
4 4
5 5
6 6
6 rows selected.
S#3> commit;
Commit complete.
S#2> -- Session #2 rolls back its UPDATE.
S#2> rollback;
Rollback complete.
-- Finally, session #1 is getting unblocked, but...
merge into dest d
ERROR at line 1:
ORA-00001: unique constraint (MAX.SYS_C0032125) violated
S#1>Hope this helps,
Andrew. -
Hi All,
I am using merge statement to update 30000 records from the tables having 55 lacs records.
But it is taking much time as i have to kill the session after 12 hours,as it was still going on.
If,Same update i m doing using cursors,it will finish in less than 3 hours.
Merge i was using is :-
MERGE INTO Table1 a
USING (SELECT MAX (TO_DATE ( TO_CHAR (contact_date, 'dd/mm/yyyy')
|| contact_time,
'dd/mm/yyyy HH24:Mi:SS'
) m_condate,
appl_id
FROM Table2 b,
(SELECT DISTINCT acc_no acc_no
FROM Table3, Table1
WHERE acc_no=appl_id AND delinquent_flag= 'Y'
AND financier_id='NEWACLOS') d
WHERE d.acc_no = b.appl_id
AND ( contacted_by IS NOT NULL
OR followup_branch_code IS NOT NULL
GROUP BY appl_id) c
ON (a.appl_id = c.appl_id AND a.delinquent_flag = 'Y')
WHEN MATCHED THEN
UPDATE
SET last_contact_date = c.m_condate;
In this query table 1 has 30000 records and table2 and table 3 have 3670955 and 555674 records respectively.
Please suggest,what i am doing wrong in merge,because as per my understanding merge statement is much better than updates or updates using cursors.
Required info is as follows:
SQL> show parameter user_dump_dest
NAME TYPE VALUE
user_dump_dest string /opt/oracle/admin/FINCLUAT/udu
mp
SQL> show parameter optimizer
NAME TYPE VALUE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.4
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
SQL> show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 16
SQL> show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
SQL> column sname format a20
SQL> column pname format a20
SQL> column pval2 format a20
SQL> select
2 sname ,
3 pname ,
4 pval1 ,
5 pval2
6 from
7 sys.aux_stats$;
sys.aux_stats$
ERROR at line 7:
ORA-00942: table or view does not exist
Elapsed: 00:00:00.05
SQL> explain plan for
2 -- put your statement here
3 MERGE INTO cs_case_info a
4 USING (SELECT MAX (TO_DATE ( TO_CHAR (contact_date, 'dd/mm/yyyy')
5 || contact_time,
6 'dd/mm/yyyy HH24:Mi:SS'
7 )
8 ) m_condate,
9 appl_id
10 FROM CS_CASE_DETAILS_ACLOS b,
11 (SELECT DISTINCT acc_no acc_no
12 FROM NEWACLOS_RESEARCH_HIST_AYLA, cs_case_info
13 WHERE acc_no=appl_id AND delinquent_flag= 'Y'
14 AND financier_id='NEWACLOS') d
15 WHERE d.acc_no = b.appl_id
16 AND ( contacted_by IS NOT NULL
17 OR followup_branch_code IS NOT NULL
18 )
19 GROUP BY appl_id) c
20 ON (a.appl_id = c.appl_id AND a.delinquent_flag = 'Y')
21 WHEN MATCHED THEN
22 UPDATE
23 SET last_contact_date = c.m_condate
24 ;
Explained.
Elapsed: 00:00:00.08
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
| 0 | MERGE STATEMENT | | 47156 | 874K| | 128K (1)|
| 1 | MERGE | CS_CASE_INFO | | | | |
| 2 | VIEW | | | | | |
| 3 | HASH JOIN | | 47156 | 36M| 5672K| 128K (1)|
| 4 | VIEW | | 47156 | 5111K| | 82339 (1)|
| 5 | SORT GROUP BY | | 47156 | 4236K| 298M| 82339 (1)|
| 6 | HASH JOIN | | 2820K| 247M| 10M| 60621 (1)|
| 7 | HASH JOIN | | 216K| 7830K| | 6985 (1)|
| 8 | VIEW | index$_join$_012 | 11033 | 258K| | 1583 (1)|
| 9 | HASH JOIN | | | | | |
| 10 | INDEX RANGE SCAN | IDX_CCI_DEL | 11033 | 258K| | 768 (1)|
| 11 | INDEX RANGE SCAN | CS_CASE_INFO_UK | 11033 | 258K| | 821 (1)|
| 12 | INDEX FAST FULL SCAN| IDX_NACL_RSH_ACC_NO | 5539K| 68M| | 5382 (1)|
| 13 | TABLE ACCESS FULL | CS_CASE_DETAILS_ACLOS | 3670K| 192M| | 41477 (1)|
| 14 | TABLE ACCESS FULL | CS_CASE_INFO | 304K| 205M| | 35975 (1)|
Note
- 'PLAN_TABLE' is old version
24 rows selected.
Elapsed: 00:00:01.04
SQL> rollback;
Rollback complete.
Elapsed: 00:00:00.03
SQL> set autotrace traceonly arraysize 100
SQL> alter session set events '10046 trace name context forever, level 8';
ERROR:
ORA-01031: insufficient privileges
Elapsed: 00:00:00.04
SQL> disconnect
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> spool off
Edited by: user4528984 on May 5, 2009 10:37 PMFor one thing, alias your tables and use that in the column specifications (table1.column1 = table2.column3 for example)...
SELECT
DISTINCT
acc_no acc_no
FROM Table3, Table1
WHERE acc_no = appl_id
AND delinquent_flag = 'Y'
AND financier_id = 'NEWACLOS'We don't know what your tables look like, what columns come from where. Try and help us help you, assume we know NOTHING about YOUR system, because more likely than naught, that's going to be the case.
In addition to that, please read through this which will give you a better-er idea of how to post a tuning related question, you've not provided near enough information for us to intelligently help you.
HOW TO: Post a SQL statement tuning request - template posting -
Problem with PIVOT statement and ORA-56901
Hi,
I am having a problem with PIVOT in Oracle.
I have a view in an oracle 11g database
that returns me data in the format:- (... indicates left out text)
DefinitionID ... AttributeValue FieldID
============ ============== =======
... 3000 X30a9...
... JohnN X4674...
I am then trying to use a PIVOT statement to hopefully give me data
in the format
COLUMN1 COLUMN2
======= =======
JohnN 3000
The PIVOT statement I am trying is
SELECT X4674... AS Column1,
X30A9... AS COLUMN2
FROM (SELECT instanceid, definitionid, attributevalue, FIELDID
FROM PI_ENTITY_INSTANCE_VIEW) up PIVOT (MAX(ATTRIBUTEVALUE)
FOR FIELDID IN (X4674...,X30A9... ) )
where definitionid = hextoraw('7353C67A56C74B5A8234CD16064399E8')
I have used a very similar VIEW and PIVOT statement for sql server
(with necessary changes for Oracle applied) and the
data returns in SQL Server as expected.
Unfortunately I am getting the Oracle error
ORA-56901: non-constant expression is not allowed for pivot|unpivot values
Is there anyway to get a PIVOT working on Oracle where I use the
fieldid's like I do above or is there some other way to supply the vales to the
IN clause to overcome this error?
Thank you for any help you can provide
John NugentHi, John,
Welcome to the forum!
X4674, X30A9 and os on are the literal values that you're looking for, right?
In Oracle, string literals need to be enclosed in single-quotes, like this:
FOR FIELDID IN ('X4674', 'X30A9') You might find it more convenient to assign column aliases in the PIVOT clause, like this:
PIVOT ( MAX (attributevalue)
FOR fieldid IN ( 'X4674' AS column1
, 'X30A9' AS column2
) Remember that anything inside quotes is case-sensitive, so 'X30A9' is not equal to 'X30a9'. Use UPPER (or LOWER) to do case-insensitive string comparisons.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
If you can use commonly available tables (such as those in the scott or hr schemas) to show your problem, then you don't have to post any sample data; just the results and explanation.
Always say which version of Oracle you're using. You did say you were using Oracle 11g, but there's no 11f or 11h, and sometimes the difference between, say 11.1 and 11.2 can be significant. Why not say exactly what you're using, e.g. 11.1.0.7.0?
You'll get better answers faster if you always supply this information whenever you post a question.
Edited by: Frank Kulash on Sep 22, 2011 2:09 PM
Added allliterative alias alternative
Edited by: Frank Kulash on Sep 22, 2011 4:04 PM -
Emergency: problem with update statement!
hello guys, i have a very serious problem with an update statement in pl/sql.
i had an application written in sybase, where i had the following update statement:
update mis_dik_adeia
set trexon_etos_days = days_per_year
from mis_dik_adeia, mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
and mis_dik_adeia.adeia_id between :aapo and :aews
and mis_dik_adeia.employee_id = :erg
and mis_dik_adeia.etos = :etos
and mis_plafon_adeivn.years_yphr = ( select max( a.years_yphr ) from mis_plafon_adeivn a where a.adeia_id = mis_plafon_adeivn.adeia_id and a.years_yphr <= :eth ) using sqlca;
This is working properly in sybase. When i copied this code in pl/sql it displayed me error and it's impossible to work. Then i thought to make a nested select statement like this:
update mis_dik_adeia
set trexon_etos_days = (select days_per_year
from mis_dik_adeia, mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
and mis_dik_adeia.adeia_id between aapo and aews
and mis_dik_adeia.employee_id = erg
and mis_dik_adeia.etos = etos1
and mis_plafon_adeivn.years_yphr = (
select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth )
but as you can understand, it is working, but it doesn't produce the same results as the update statement in Sybase!
It is very important for me to solve this problem , which is a very big trouble for me for a long time.
Please if anyone can help me i would appreciate it a lot!
Regards ,
Bill...Bill,
folowing the logic of your original query by Sybase
(it's embedded SQL in Power Builder, isn't it ?):
update mis_dik_adeia
set trexon_etos_days = (select days_per_year
from mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
and mis_plafon_adeivn.years_yphr = (
select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth )
where
mis_dik_adeia.adeia_id between aapo and aews
and mis_dik_adeia.employee_id = erg
and mis_dik_adeia.etos = etos1
and
exists (select 1
from mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
and mis_plafon_adeivn.years_yphr = (
select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth )
In 9i you can also try the following:
megre into mis_dik_adeia
using (
select
days_per_year,
mis_dik_adeia.rowid rid
from mis_dik_adeia, mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
mis_dik_adeia.adeia_id between aapo and aews
and mis_dik_adeia.employee_id = erg
and mis_dik_adeia.etos = etos1
and mis_plafon_adeivn.years_yphr =
(select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth)
) src
on (mis_dik_adeia.rowid = src.rid)
when matched then
update set mis_dik_adeia.trexon_etos_days = src.days_per_year
when not matched then
insert (mis_dik_adeia.adeia_id) values(0);
In 10G it can be easily:
megre into mis_dik_adeia
using (
select
days_per_year,
mis_dik_adeia.rowid rid
from mis_dik_adeia, mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
mis_dik_adeia.adeia_id between aapo and aews
and mis_dik_adeia.employee_id = erg
and mis_dik_adeia.etos = etos1
and mis_plafon_adeivn.years_yphr =
(select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth)
) src
on (mis_dik_adeia.rowid = src.rid)
when matched then
update set mis_dik_adeia.trexon_etos_days = src.days_per_year;
I have to notice I didn't check it carefully, so I can miss...
Rgds.
Corrected a mistake in the table name
Message was edited by:
dnikiforov -
Hi
I am trying to achieve the following in my report:
If an employee has a surname of . (dot) or a first name of . (dot), the report should not display a dot. An employee's name is made up of surname, first name and middle name which should all be concatenated together. To try to achieve this, I have the following statement in my report:
decode(e.Surname, '.', ( LTRIM(RTRIM((INITCAP(e.FIRST_NAME)))||' '||INITCAP(e.MIDDLE_NAME)) ) ,
e.FIRST_NAME, '.', ( LTRIM(RTRIM((INITCAP(e.Surname)))||' '||INITCAP(e.MIDDLE_NAME)) ) ,
( LTRIM(RTRIM((INITCAP(e.SURNAME )))||', '||INITCAP(e.FIRST_NAME)||' '||INITCAP(e.MIDDLE_NAME)) ) ) as emp_name
FROM Employee e
Problem: The above statement is only working for those employees with surname of . (dot). It's not working for first names of dot. How can I use the decode statement OR is there any other way of doing it without using the CASE statement?
It seems my decode statement doesn't work with 2 different fields (surname, firstname) being tested within one decode statement.Thanks.Thank you so much InoL . I have used the ltrim with Replace but now have a new problem.
Because I am joining Surname, First name and middle name together and put a comma after the Surname, the name now appears as follows:
, Maria Ane (if Surname is a dot)
Boiler, (if first name is a dot)
I would like to get rid of a comma and only have comma when surname or first name does not have a dot, i.e. for those people with full names e.g. Blake, Anna Marie.
InoL, how can I achieve this? Thanks. -
Hi All,
I have a problem with the usage of the submit statement.
I have a report program, say report 'A'.
In the report program 'A', I have a custom screen with number '9001'.
In the screen 9001, of program A, there is a button to display ALV.
In the PAI event, under module Module call_report, i am calling another report program say B, using the statement Submit B and return, when the button is clicked.
In the report program B i have a select options. and a docking alv container in it.
Flow of the program is:
1. Run the program A.
2. Select the button on screen 9001.
3. Call the report program B.
4. Enter a value in the select option and run the program B.
5. Go back to program A by selecting back button.
The problem is as at step 4.:
Now, when i press Intervals button ( Arrow mark ) present beside the select option, my program B is getting executed and the list output is being shown.
Kindly let me know what is the problem.you can very well use the submit procedure as suggested above or you also can do "leave to screen '9001' " for the back button.
-
Problem with while statement :(
i am having a problem with my while statement, can anyone help me to get it working :(
i am trying to get the while statement to only run when the input hasnt been a yes or a no, can someone please help me.
System.out.print("Are you a Resident? (yes/no): ");
Resident = console.next(); //Requests resident status from user and puts in in Resident
while ((Resident != "yes") && (Resident != "no"))
System.out.print("error - You didnt type yes or no. Try again: ");
Resident = console.next();
}while ((Resident != "yes") && (Resident != "no"))Don't compare Strings with ==, use the equals() method instead.
while(!("yes".equals(Resident) && "no".equals(Resident))) -
Problems with Callable Statement
Hi All,
I have a problem with the callable statement that contains stored procedure.Here main thing i want to know is that can a stored procedure can be used for a database like Access.Because i am using Access as a database here.In which i have created the table Students.
The table Students contains 3 fields they are name,amount & balance.
The program is compiling well but during the runtime it is showing an error:-
"Syntax error in Create Table" .
For ur reference i have posted the code:-
import java.io.*;
import java.sql.*;
public class CallStatDemo
public static void main(String arg[])
Connection con;
CallableStatement cs;
Driver dr;
String str1,str2;
int in1,in2;
double d1;
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Ananth"); //the dsn name is Ananth
init(con);
if(con==null)
System.out.println("Connection not Established");
else
cs=con.prepareCall("{call Payment(?,?)}");
cs.setString(1,"Raman"); //name
cs.setString(2,"2000"); //amount
cs.execute();
catch(Exception e)
System.out.println("Error Message : "+e);
static void init(Connection con)
throws SQLException
Statement stmt = con.createStatement();
stmt.execute ("create or replace procedure Payment(name in text,amount in text)is " +
" begin"+
" update Students set balance=balance-amount where name =name;"+
"end Payment;");
stmt.close();
Thanx,
m.ananthuI have no clue if Access supports stored procedures, and this surely isn't related to JDBC at all. Did you check your Access documentation?
Your posted code does not contain any CREATE TABLE statement, so where do you get your error (which line)
Most probably Access does not support stored procedures. To verify that, you should execute your CREATE PROCEDURE statement from within Access, to verify that it is a supported statement. -
Problem with switch-statement & ä, ö, ü
Hi all,
I am doing this Java online tutorial right now and have a problem with one of the exercises. Hopefully you can help me:
I have to write a program that determines the number of consonants, vowels, punctuation characters, and spaces in an input line. I found a solution, but have two questions about it:
Im unable to calculate the amount of umlauts (ä, ö, ü). Somehow the program doesnt recognize those characters. Why?
In general Im not very happy with this huge list of cases. How would you solve a problem like this? Is there a more convenient/elegant way?
Thanks in advance!
Write a program that determines the number of consonants, vowels, punctuation characters, and spaces in an input line.
Read in the line into a String (in the usual way). Now use the charAt() method in a loop to access the characters one by one.
Use a switch statement to increment the appropriate variables based on the current character. After processing the line, print out
the results.
import java.util.Scanner;
class Kap43A1
public static void main ( String[] args )
String line;
char letter;
int total, countV=0, countC=0, countS=0, countU=0, countP=0;
Scanner scan = new Scanner(System.in);
System.out.println( "Please write a sentence " );
line = scan.nextLine();
total=line.length(); //Gesamtanzahl an Zeichen des Satzes
for (int counter=0; counter<total; counter++)
letter = line.charAt(counter); //ermitteln des Buchstabens an einer bestimmten Position des Satzes
switch (letter)
case 'A': case 'a':
case 'E': case 'e':
case 'I': case 'i':
case 'O': case 'o':
case 'U': case 'u':
countV++;
break;
case 'B': case 'b': case 'C': case 'c': case 'D': case 'd': case 'F': case 'f': case 'G': case 'g': case 'H': case 'h':
case 'J': case 'j': case 'K': case 'k': case 'L': case 'l': case 'M': case 'm': case 'N': case 'n': case 'P': case 'p':
case 'Q': case 'q': case 'R': case 'r': case 'S': case 's': case 'T': case 't': case 'V': case 'v': case 'W': case 'w':
case 'X': case 'x': case 'Y': case 'y': case 'Z': case 'z':
countC++;
break;
case ' ':
countS++;
break;
case ',': case '.': case ':': case '!': case '?':
countP++;
break;
case 'Ä': case 'ä': case 'Ö': case 'ö': case 'Ü': case 'ü':
countU++;
break;
System.out.println( "Total amount of characters:\t" + total );
System.out.println( "Number of consonants:\t\t" + countC );
System.out.println( "Number of vocals:\t\t" + countV );
System.out.println( "Number of umlauts:\t\t" + countU );
System.out.println( "Number of spaces:\t\t" + countS );
System.out.println( "Number of punctuation chars:\t" + countP );
}WRE wrote:
In general Im not very happy with this huge list of cases. How would you solve a problem like this? Is there a more convenient/elegant way?I've been doing this a lot lately myself evaluating documents with 20 or so million words. Few tips:
1. Regular expressions can vastly reduce the list of cases. For example you can capture all letters from a to z or A to Z as follows [a-zA-Z]. To match a single character in a String you can then make use of the Pattern and Matcher classes, and incorporate the regular expression. e.g.
//Un-compiled code, may contain errors.
private Pattern letterPattern = Pattern.compile("[a-zA-Z]");
public int countNumberOfLettersInString(final String string) {
int count = 0;
Matcher letterMatcher = letterPattern.matcher(string);
while(letterMatcher.find()) {
count++;
return count;
}2. As mentioned above, Sets are an excellent choice. Simply declare a static variable and instantiate it using a static initializer block. Then loop over the String to determine if the character is in the given set. e.g.
//Un-compiled code, may contain errors.
private static Set<Character> macrons = new HashSet<Character>();
static {
macrons.add('ä');
macrons.add('ö');
macrons.add('ü');
public int countNumberOfMacronsInString(final String string) {
int count = 0;
for(char c : string.toCharArray()) {
if(macrons.contains(c) {
count++;
return count;
}Mel -
ICloud not syncing and Contact problems with merging duplicates
I was having problems with the syncing of my notes app. When I got the iphone 5 I had since using Mountain Lion I had started to make use of the fact that the notes sync across iCloud. Great. Although not for long. Everything was going fine notes were syncing across devices but then spontaneously they stopped syncing for no apparent reason. I then went to look in settings, looked online and all through discussion forums. Switching notes on and off on icloud both on the macbook and on my iphone. Restarting devices etc etc. iCloud itself online was not able to access the notes app. I kept getting error messages that I would submit to apple. Then I finally relqinquished and unhooked the iCloud accounts from the computer and phone. And at the sacrifice of losing albums in my photostream they sprung back to syncing.
Then the real problem happened. I had selected to keep a copy of my address book in contacts when I unhooked my computer just in case. When everything linked back up again, I then had duplicates in my address book. Not 1 (this can happen just having icloud active) but 5 sets of duplicates, granted I had kept a version from when I unhooked. So I looked around again for how I could quickly and easily get rid of duplicates. Following suggestions online I go into contacts>cards>look for duplicates. I had 1200 or somthing duplicates, so naturally when given the option "would you like to merge the info in these duplicates I click yes. The MacBook starts to chugg away. Its gonna take a while. So I come back later. And before returning to CONTACTS, go to send a message from MESSAGES and I notice that 80% of the threads have no name. I go back to CONTACTS and WHAM 100s of contacts disappeared in the merge never to be retrieived again. You cant restore CONTACTS from Time Machine as it is just mirrors the contacts that you have in present time. Restoring phone doesn't work becasue it just downloads from iCloud after it has restored. TOTALLY RIDICULOUS. I am livid.what I mean is - create a complete new contact on your contacts and select a picture for it from your Mac. Then set it as "make this my card"
Once you have done that - presumably it will sync with iCloud - have a look and the contact should appear on your iPhone too.
On your iPhone go on Settings>Mail,Contacts,Calendar> Under "Contacts: in "My Info" select That new contact you created on your Mac.
Let me know if that works.
-On another note, so what you are saying is, if I take my 15' Macbook Pro in and they have none of the old ones in stock, they just give you a Retina display one! Did you take it to them for the contact issue you were having or something else? -
Oracle 9i, Rel.2 - Problems with dynam statement and cursor
Hello,
I have the following problem with Oracle 9i, Release 2:
I have a SQL-statement, which I create with the help of a configuration table. That means I don’t know how this statement looks at runtime. It could be look like this:
SELECT Att1, Att2, Att3
FROM Tab1
or this…
SELECT Att1, Att2
FROM Tab1
or this…
SELECT Att1
FROM Tab1
etc.
That means I don’t know in advance how many columns will be in the select-clause.
Here my code snippet until here:
v_query_str := 'SELECT ' || v_select_clause_str
|| ' FROM cb.' || v_table;
,,v_select_clause_str" willl be created dynamically
,,v_table" is as well from the config-table
Now I want to iterate through the result of the query and do further processing.
For this reason I wanted to use a cursor, iterate through the rows and save every value of each row in an own variable (but I don’t know the number of columns!!!).
But how can I open a cursor and iterate through it without knowing the number of columns???
The following code is NOT working:
TYPE t_dataColumnComp IS TABLE OF VARCHAR2(200);
a_dataColumnComp t_dataColumnComp;
--here I create the query…
v_query_str := 'SELECT ' || v_select_clause_str
|| ' FROM cb.' || v_table;
OPEN c_tempAtt FOR v_query_str;
LOOP
FETCH c_tempAtt INTO a_dataColumnComp; --THIS DON’T WORK
EXIT WHEN c_tempAtt%NOTFOUND;
FOR i IN 1..a_dataColumnComp.COUNT
LOOP
DBMS_OUTPUT.PUT_LINE(a_dataColumnComp(i));
END LOOP;
END LOOP;
CLOSE c_tempAtt; --close cursor variable
Regards
HomerYou will need to use DBMS_SQL to handle this since the number of columns in the result set is not known until runtime.
See here for an example of using DBMS_SQL:
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:235814350980
Maybe you are looking for
-
Missing Export Data - Accounting document not being triggered for Billling
Hello All, We are facing probem in getting an accounting document posted for an Invoice. The error i found is that the deliverying country in the header of Invoice is NlL (Netherlands) and in the line item is CH (Switzerland). But as per configuratio
-
Upgrading a DC in place from Server 2008 R2 to Server 2012 R2
This is not a question but more of an information post. I've found lots of posts regarding the upgrade of a DC and most say that you should do a clean install and migrate services and then decommission the old server. But I was more interested in an
-
I want to cancel the Skype number I am being automatically billed for. I know what the Skype numb er is. In my profile, purchase history and profile it all shows that I have made no purchases and in the manage account area my I see no settings opti
-
BI Pattern Wizard Question? BI 7.0
Hi, When creating a new Web Template in WAD I am invoking the BI Wizard. I select the "Small Web Template w/Analysis Item and 1DP", but only 2 steps are shown. 1. Web Template Properties and Data Provider Settings 2. Analysis Item (Confusing at bes
-
What technology should be used?
i want to make remote desktop type of application with limited functionality. In achieving this i thought viewing the desktop from client should be the first step. so i want to know what technology should i use to send live video type of thing to cli