Strange Condition Oracle Merge
I have an Oracle Merge statement. The condition I am facing is that the statement is updating the table as well as inserting the record that its updated. I have duplicates in the table for this reason. Can someone please advice why this condition occurs? the primary key constraint of the table is disabled.
The Merge statement is attached below. I am selecting my query from a view thats based on a table. My aim is to generate a summary at a level higher than that of the table. date_key here refers to the weekend date. ITs used instead of a week id.
My problem is that the table has duplicate records after the merge. when i run the select part of this merge, it doesnt get me any duplicates.
MERGE INTO WEEKLY_PGROUP_SUMMARY w
USING (
SELECT date_key, ccid, year_id, period_id, week_id, company, country,
location, brand, mainbrand, pgroup,
sales_qty, sales_cost, sales_value,
fp_sales_qty, fp_sales_cost, fp_sales_value,
md_sales_qty, md_sales_cost, md_sales_value,
sreturns_qty, sreturns_cost, sreturns_value,
grn_qty, grn_cost, grn_value,
tfrin_qty, tfrin_cost, tfrin_value,
tfrout_qty, tfrout_cost, tfrout_value,
intake_qty, intake_cost, intake_value,
preturns_qty, preturns_cost, preturns_value,
adjm_qty, adjm_cost, adjm_value,
adjw_qty, adjw_cost, adjw_value,
adjc_qty, adjc_cost, adjc_value,
adjt_qty, adjt_cost, adjt_value,
adjv_qty, adjv_cost, adjv_value,
stockob_qty, stockob_cost, stockob_value,
fp_stockob_qty, fp_stockob_cost, fp_stockob_value,
md_stockob_qty, md_stockob_cost, md_stockob_value,
tm_stockob_qty, tm_stockob_cost, tm_stockob_value,
stockcl_qty, stockcl_cost, stockcl_value,
fp_stockcl_qty, fp_stockcl_cost, fp_stockcl_value,
md_stockcl_qty, md_stockcl_cost, md_stockcl_value,
se_stockcl_qty, tm_stockcl_cost, tm_stockcl_value,
tm_stockcl_qty, se_stockcl_cost, se_stockcl_value,
co_stockcl_qty, co_stockcl_cost, co_stockcl_value,
currency, exrate1, exrate2, exrate3, exrate4, exrate5
FROM generate_pgroup_summary_v ) v
-- On condition includes all fields that are indexed
ON (v.date_key = w.date_key AND v.ccid = w.ccid AND v.brand = w.brand
AND v.pgroup = w.pgroup)
WHEN MATCHED THEN
UPDATE
SET w.currency = v.currency,
w.exrate1 = v.exrate1,
w.exrate2 = v.exrate2,
w.exrate3 = v.exrate3,
w.exrate4 = v.exrate4,
w.exrate5 = v.exrate5,
w.sales_qty = v.sales_qty,
w.sales_cost = v.sales_cost,
w.sales_value = v.sales_value,
w.fp_sales_qty = v.fp_sales_qty,
w.fp_sales_cost = v.fp_sales_cost,
w.fp_sales_value = v.fp_sales_value,
w.md_sales_qty = v.md_sales_qty,
w.md_sales_cost = v.md_sales_cost,
w.md_sales_value = v.md_sales_value,
w.sreturns_qty = v.sreturns_qty,
w.sreturns_cost = v.sreturns_cost,
w.sreturns_value = v.sreturns_value,
w.grn_qty = v.grn_qty,
w.grn_cost = v.grn_cost,
w.grn_value = v.grn_value,
w.tfrin_qty = v.tfrin_qty,
w.tfrin_cost = v.tfrin_cost,
w.tfrin_value = v.tfrin_value,
w.tfrout_qty = v.tfrout_qty,
w.tfrout_cost = v.tfrout_cost,
w.tfrout_value = v.tfrout_value,
w.intake_qty = v.intake_qty,
w.intake_cost = v.intake_cost,
w.intake_value = v.intake_value,
w.preturns_qty = v.preturns_qty,
w.preturns_cost = v.preturns_cost,
w.preturns_value = v.preturns_value,
w.adjm_qty = v.adjm_qty,
w.adjm_cost = v.adjm_cost,
w.adjm_value = v.adjm_value,
w.adjw_qty = v.adjw_qty,
w.adjw_cost = v.adjw_cost,
w.adjw_value = v.adjw_value,
w.adjc_qty = v.adjc_qty,
w.adjc_cost = v.adjc_cost,
w.adjc_value = v.adjc_value,
w.adjt_qty = v.adjt_qty,
w.adjt_cost = v.adjt_cost,
w.adjt_value = v.adjt_value,
w.adjv_qty = v.adjv_qty,
w.adjv_cost = v.adjv_cost,
w.adjv_value = v.adjv_value,
w.stockob_qty = v.stockob_qty,
w.stockob_cost = v.stockob_cost,
w.stockob_value = v.stockob_value,
w.fp_stockob_qty = v.fp_stockob_qty,
w.fp_stockob_cost = v.fp_stockob_cost,
w.fp_stockob_value = v.fp_stockob_value,
w.md_stockob_qty = v.md_stockob_qty,
w.md_stockob_cost = v.md_stockob_cost,
w.md_stockob_value = v.md_stockob_value,
w.tm_stockob_qty = v.tm_stockob_qty,
w.tm_stockob_cost = v.tm_stockob_cost,
w.tm_stockob_value = v.tm_stockob_value,
w.stockcl_qty = v.stockcl_qty,
w.stockcl_cost = v.stockcl_cost,
w.stockcl_value = v.stockcl_value,
w.fp_stockcl_qty = v.fp_stockcl_qty,
w.fp_stockcl_cost = v.fp_stockcl_cost,
w.fp_stockcl_value = v.fp_stockcl_value,
w.md_stockcl_qty = v.md_stockcl_qty,
w.md_stockcl_cost = v.md_stockcl_cost,
w.md_stockcl_value = v.md_stockcl_value,
w.se_stockcl_qty = v.se_stockcl_qty,
w.se_stockcl_cost = v.se_stockcl_cost,
w.se_stockcl_value = v.se_stockcl_value,
w.tm_stockcl_qty = v.tm_stockcl_qty,
w.tm_stockcl_cost = v.tm_stockcl_cost,
w.tm_stockcl_value = v.tm_stockcl_value,
w.co_stockcl_qty = v.co_stockcl_qty,
w.co_stockcl_cost = v.co_stockcl_cost,
w.co_stockcl_value = v.co_stockcl_value,
w.modifiedon=stime
WHEN NOT MATCHED THEN
INSERT (date_key, ccid, year_id, period_id, week_id,
company, country,location, brand, mainbrand,
pgroup,
sales_qty, sales_cost, sales_value,
fp_sales_qty, fp_sales_cost, fp_sales_value,
md_sales_qty, md_sales_cost, md_sales_value,
sreturns_qty, sreturns_cost, sreturns_value,
grn_qty, grn_cost, grn_value,
tfrin_qty, tfrin_cost, tfrin_value,
tfrout_qty, tfrout_cost, tfrout_value,
intake_qty, intake_cost, intake_value,
preturns_qty, preturns_cost, preturns_value,
adjm_qty, adjm_cost, adjm_value,
adjw_qty, adjw_cost, adjw_value,
adjc_qty, adjc_cost, adjc_value,
adjt_qty, adjt_cost, adjt_value,
adjv_qty, adjv_cost, adjv_value,
stockob_qty, stockob_cost, stockob_value,
fp_stockob_qty, fp_stockob_cost, fp_stockob_value,
md_stockob_qty, md_stockob_cost, md_stockob_value,
tm_stockob_qty, tm_stockob_cost, tm_stockob_value,
stockcl_qty, stockcl_cost, stockcl_value,
fp_stockcl_qty, fp_stockcl_cost, fp_stockcl_value,
md_stockcl_qty, md_stockcl_cost, md_stockcl_value,
se_stockcl_qty, tm_stockcl_cost, tm_stockcl_value,
tm_stockcl_qty, se_stockcl_cost, se_stockcl_value,
co_stockcl_qty, co_stockcl_cost, co_stockcl_value,
currency, exrate1, exrate2, exrate3, exrate4, exrate5,
modifiedon)
values
(v.date_key, v.ccid, v.year_id, v.period_id, v.week_id, v.company, v.country,
v.location, v.brand, v.mainbrand, v.pgroup,
v.sales_qty, v.sales_cost, v.sales_value,
v.fp_sales_qty, v.fp_sales_cost, v.fp_sales_value,
v.md_sales_qty, v.md_sales_cost, v.md_sales_value,
v.sreturns_qty, v.sreturns_cost, v.sreturns_value,
v.grn_qty, v.grn_cost, v.grn_value,
v.tfrin_qty, v.tfrin_cost, v.tfrin_value,
v.tfrout_qty, v.tfrout_cost, v.tfrout_value,
v.intake_qty, v.intake_cost, v.intake_value,
v.preturns_qty, v.preturns_cost, v.preturns_value,
v.adjm_qty, v.adjm_cost, v.adjm_value,
v.adjw_qty, v.adjw_cost, v.adjw_value,
v.adjc_qty, v.adjc_cost, v.adjc_value,
v.adjt_qty, v.adjt_cost, v.adjt_value,
v.adjv_qty, v.adjv_cost, v.adjv_value,
v.stockob_qty, v.stockob_cost, v.stockob_value,
v.fp_stockob_qty, v.fp_stockob_cost, v.fp_stockob_value,
v.md_stockob_qty, v.md_stockob_cost, v.md_stockob_value,
v.tm_stockob_qty, v.tm_stockob_cost, v.tm_stockob_value,
v.stockcl_qty, v.stockcl_cost, v.stockcl_value,
v.fp_stockcl_qty, v.fp_stockcl_cost, v.fp_stockcl_value,
v.md_stockcl_qty, v.md_stockcl_cost, v.md_stockcl_value,
v.se_stockcl_qty, v.tm_stockcl_cost, v.tm_stockcl_value,
v.tm_stockcl_qty, v.se_stockcl_cost, v.se_stockcl_value,
v.co_stockcl_qty, v.co_stockcl_cost, v.co_stockcl_value,
v.currency, v.exrate1, v.exrate2, v.exrate3, v.exrate4, v.exrate5,
stime);
Similar Messages
-
Implementing Auto Correct Load as Oracle Merge
Data Services 3.0 documentation reads that Auto Correct Load option for Oracle target will be implemented as a Merge statement, if both the source and the target reside in the same datastore.
I have set this up as per documentation, however the Optimized SQL still shows a pl/sql stored procedure logic, NOT the Merge Statement.
My questions are:
1. Has anybody successfully implemented Oracle Merge?
2. If answer to (1) is yes, then is there a way to control update and insert elements of the Merge statement? I would like to update the rec_created_timestamp of the target table only on Insert, and update the rec_updated_timestamp on update.
Thank you.having both source and target on the same database or source table accesible from target table throguh Database link is not the only condition for DS Optimizer to use Oracle MERGE command to do auto correct load
check the following
Auto Correct load and Allow Merge option is set to yes for target table
its possible to push down the complete read and load operation to DB, (you are not using function or mapping or join etc that are not supported by Oracle)
You have Primary Keys defined correctly, this is required to avoid situation where you may not end up inserting and updating the same record (MERGE will fail with Ora error )
the Identification of INSERT and UPDATE will depend on your key column, you can modify the PK for target table either modfiying the table column properties by opening the schema from Datastore or if you want this only for a particular DF then add a Query transfrom before loader and set the key columns in output schema and set the loader option Use Input Key to yes
Using User Defined key is safe as long as you make sure that the source data will be unique for that combination else MERGE will fail -
Can you create nested condition in merge(e.g. insert/update) using owb
Hi,
Does OWB9iR2 allow you to build in nested condition in merge. such as
If no match on col1 and col2 then
if col3 match then no new sequence insert <---
else insert new sequence;
else (there is match on col1 and col2)
update col3 and sequence.
I have an incremental load for a lookup table, where insert/update is used. There are two match columns and surrogate key is used. When there is no match, it shall not insert a sequence when there is a match on third column. I can not use the 3rd column in the original match because it shall be updated where there is a match for the two match column.
I am trying to avoid using transformant for performance impact. ThanksHIi I think the misleading thing is that in PL/SQL you can use booleans, which is not possible in SQL. So in a PL/SQL tranformation, this is OK:
a:= case when not orgid_lkup( INGRP1.ORG_ID )
then get_supid(..)
else ...
but, the following SQL does not work:
select case when not orgid_lkup( INGRP1.ORG_ID )
then get_supid(..)
else ...
into a
from dual;
I ended up using only 0/1 as boolean return values for these reasons;
so I can have:
select
case when orgid_lkup( INGRP1.ORG_ID ) = 0 then ...
though true booleans are better if you don't have to embed them in SQL.
Antonio -
Strange condition on 4948 nexus
I had a strange condition today. Had a snmp discovery running ( from a ca product called spectrum) it does extensive mapping both layer2 and layer 3 ....however we had a 4948 crash in our data centre possibly as a result thereof...no real evidence but snmp load was huge .
Anyone seen anything like this before ?
Thanks
Sent from Cisco Technical Support iPad AppI have seen snmp bury switches cpu before so it's certainly possible. I would check your tool and see if there is some way to rate limit the snmp polling or you may have try and figure out if there is a way using control plane policeing . Also check for bugs for
your version of code . -
Strange: Conditional Error in Intermedia Text Index Creation
Hi All,
I am facing a strange error while creating the Intermedia Text index on 8.1.6 release for NT 4.0.
I have one database instance installed on the server. When i connect to Oracle through SQL plus as: connect username/password;
The index creation works fine!
But, if i connect using: username/password@servicename;
The index creation does not work!
The following error occurs.
ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-20000:intermedia Text error:
ORA-50704:Net8 listener is not running or cannot start external procedures
ORA-28575:unable to open RPC connection to external procedure agent
ORA-12154:TNS:could not resolve service name
ORA-06512:at "CTXSYS.DRUE", line 126
ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 54
ORA-06512:at line 1
Could anyone please help as to why it works without when connected without the service name but not otherwise?
Thanking you in advance!
Thanks and Regards
Anurag AgarwalHi All,
I am facing a strange error while creating the Intermedia Text index on 8.1.6 release for NT 4.0.
I have one database instance installed on the server. When i connect to Oracle through SQL plus as: connect username/password;
The index creation works fine!
But, if i connect using: username/password@servicename;
The index creation does not work!
The following error occurs.
ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-20000:intermedia Text error:
ORA-50704:Net8 listener is not running or cannot start external procedures
ORA-28575:unable to open RPC connection to external procedure agent
ORA-12154:TNS:could not resolve service name
ORA-06512:at "CTXSYS.DRUE", line 126
ORA-06512: at "CTXSYS.TEXTINDEXMETHODS", line 54
ORA-06512:at line 1
Could anyone please help as to why it works without when connected without the service name but not otherwise?
Thanking you in advance!
Thanks and Regards
Anurag Agarwal -
Oracle MERGE in to a single table error.
Experts, please find any errors in this merge query as it throws following exception when trying to execute,
MERGE INTO md.PER_USER PU
USING (
SELECT
+'aaa.bbb.ccc' AS NAME,+
+'222' AS VALUE,+
+( SELECT U_ID+
FROM md.USER U
WHERE upper(U.NAME) = upper('sds')) AS U_ID
FROM dual
+) val ON (+
PU.NAME=val.NAME
and PU.U_ID=val.U_ID
+)+
WHEN MATCHED THEN
update set PU.VALUE = val.value
WHEN NOT MATCHED THEN
INSERT (PU.ID, PU.NAME, PU.VALUE,PU.U_ID) VALUES (SELECT sys_guid(), val.NAME, val.VALUE,val.U_ID);
Following exception throws :
nested exception is java.sql.SQLSyntaxErrorException: ORA-00936: missing expression'; cause: 'org.springframework.jdbc.BadSqlGrammarException';
Iam using oracle 11g.INSERT (PU.ID, PU.NAME, PU.VALUE,PU.U_ID) VALUES (SELECT sys_guid(), val.NAME, val.VALUE,val.U_ID);leave away the SELECT before sys_guid():
INSERT (PU.ID, PU.NAME, PU.VALUE,PU.U_ID) VALUES (sys_guid(), val.NAME, val.VALUE,val.U_ID); -
CARACTERES EXTRAÑOS ORACLE REPORT 6I (STRANGE CHARACTERS ORACLE REPORT 6I)
Español:
Hola compañeros. Estoy utilizando Oracle Report 6i y cuando quiero imprimir un reporte en modo caracter me aparecen unos extraños simbolos al final de las lineas, como se puede apreciar en la imagen:
English:
Hello fellow. I am using Oracle Report 6i and when I want to print a character mode report me strange symbols appear at the end of the lines, as you can see in the picture:
Español:
Según esta revisado, sería problema de espacio, pero ya le di mayor margen al reporte, he hecho la letra mas pequeña y nada ha resuelto el problema. ¿Alguna sugerencia? De antemano, gracias.
English:
Under this revised, would be space problem, but it gave greater scope to the report, I made the smallest point and nothing has solved the problem. Any suggestions? Thank you in advance.Hi Pat
The answer is no, not in Reports 6i.
Reports 9i, however, includes rich PDF enhancements such as Type1 font embedding and Type3 font subsetting that can be used to display Chinese characters.
Browse this url for more information:
http://otn.oracle.com/products/reports/htdocs/getstart/whitepapers/pdfenh.htm
Regards
Sripathy -
Strange behavior of merged clips on import
After much troubleshooting I've noticed more strange behavior in the reimport of merged clips from XML...
I have merged clips made out of film transfer and the audio from an aiff file. I can export and xml of a merged clip... all of about 30 seconds and when I reimport the clip from xml it is like 47 minutes long and will not reconnect the audio part of the merged clip. That is actually happening to ALL of my merged clips in a current film project.Yes, all phones are 111, all faxes are 222 and all mobiles are 333
Please see these images:
Test-Database in Excel:
Export from Excel:
Import into Adress Book:
The result(s) (see the aligning of "Andere" (=phone), Fax and Mobile): -
Urgent: Strange JDBC Oracle error
<b>SQLException: ORA-03120: two-task conversion routine: integer overflow</b>
I get the above error when i retrieve more than 1 column of data from a oracle 8.0.5 database, using jdbc driver (i tried using both classes111.zip and 816classes12b.zip) on a JDK1.2.2 platform, NT environment.
note 1: no error occurs when i retrieve only 1 column at a time.
note 2: when i use exactly the same program to retrieve data from a 8.1.5 database, no
error occurs at all.
So, what's going on here?
Can you please help and explain.
nullI guess the problem lies with version compatability.
Newer versions of driver classes like 816classes12b.zip and others do not work well with Oracle 8.0.5, but they works fine with 8.1.5 and above.
So to work with 8.0.5 and below, we need classes111.zip. But I suspect even classes111.zip has different versions because I encountered the same problem with my previous download of classes111.zip. And then I download from another place and it works fine. Very Strange. Can someone from oracle explain in details?
Conclusion: it is a matter of trying and testing the different driver classes by specifying and removing them from the environment class path. You need to start a new DOS prompt for the new classpath to take effect.
null -
Strange error oracle.jbo.ReadOnlyAttrException: JBO-27008:
Hello, friends!
I use uix for my application (generated with JHeadstart).
Now I have one problem, and this problem is very strange. One of VOs throws exception after commit changes. First time it was error
(oracle.jbo.ReadOnlyAttrException) JBO-27008: for atribute mgrList
at oracle.jbo.AttrValException.<init>(AttrValException.java:112)
at oracle.jbo.ReadOnlyAttrException.<init>(ReadOnlyAttrException.java:40)
at oracle.jbo.server.ViewRowImpl.setAttribute(ViewRowImpl.java:815)
at oracle.jbo.jbotester.JboTesterUtil.setData(JboTesterUtil.java:173)
Then I setted updateable property of MgrList attribute to always and now i have this error:
oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:java.util.List with value:[{}]
I don't know why, but all worked fine yestarday.
I think that this is not view project problem. Because the same problem appear on the other pages (oracle.jbo.ReadOnlyAttrException: JBO-27008:) and when i test model project with bc4j tester today. But all this pages and data model worked correctly before and i did not edit this.
And this problem look like the bug. Because this error must appear for attributes which are always updatable and when i do not update it.
Maybe you can tell me how to solve this problem, please.
Thank you.We havent written any custom code in the extended EO.
Case 1 : Without any extension (basic oracle behaviour)
When the Page is first Rendered, the Org Name (LOV) Field is populated on the screen,and OrgId (form value) is also populated with it.
(this is a create screen and Org is populated with the Default Org name and ID)
Case 2 : With we have Extended EO
(we havent generated the EOImpl of extended EO so we cannot possible write any custom code to insert/ update any of the attrubutes.
This Case gives an error as mentiond in my previous mails. -
Oracle Merge vs Informatica Update Strategy
How do you guys compare the two? Consider we have a large data set. About 5-10 million rows in the table and upto 1 million rows daily as insert/update. How does the performance vary if we only 10,000 rows daily as insert/update?
Any inputs are appreciated. We currently have Oracle 9i and are soon upgrading to 10g. Has the merge feature has any improvements in 10g.
thanksI'm attacking the idea that concepts and principles of an application layer system (like Informatica) should be enforced onto Oracle, or is even at all relevant to Oracle.
The core of an Information System is what? The application? Applications come and go. Here today. Legacy tomorrow. Replaced next year.
Ask any business user what is important - the spreadsheet application or the spreadsheet's data? Data is forever. The database is the core of the Information System.
So it does not matter what Informatica may think is a bright idea or brilliant concept. The fact is that all RDBMS products are not equal. E.g. what works for Oracle does not work for SQL-Server. And vice versa. The on-shoe-fit-all approach from the application tier is flawed. Informatica's concurrency controls may work well with Ingres or SQL-Server - but that does not say it will work well at all with Oracle. (and likely not in such a case as Oracle's concurrency controls are very different)
To ensure that the core does not rot, one need to ensure that the core is design correctly. So when it comes to something like Oracle and Informatica (or J2EE or .NET or CORBA or whatever) - so what? Do it right in the RDBMS first and foremost. (and this is as relevant for SQL-Server/Ingres/Informix/etc as for Oracle)
As for how does Informatica and Oracle compare? Not relevant. The former is not the leading and most advance RDBMS product in the world. Oracle is. -
Strange scenario,Oracle can not display the data in mysql correctly
I use Heterogeneous Service+ODBC to achieve "oracle access mysql"(any other method?),and now i find Oracle can not display the data in mysql correctly:
-------mysql------------
mysql> create table tst(id int,name varchar(10));
Query OK, 0 rows affected (0.00 sec)
mysql> insert into tst values(1,'a');
Query OK, 1 row affected (0.00 sec)
mysql> select * from tst;
------------+
| id | name |
------------+
| 1 | a |
------------+
1 row in set (0.00 sec)
mysql> show create table tst\G
*************************** 1. row ***************************
Table: tst
Create Table: CREATE TABLE `tst` (
`id` int(11) DEFAULT NULL,
`name` varchar(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
-------------oracle ------------------
SQL> select count(*) from "tst"@mysql;
COUNT(*)
49
SQL> select * from "tst"@mysql;
id
1
SQL> desc "tst"@mysql;
Name Null? Type
id NUMBER(10)You can make the following query on the result page:
"select * from the_table where movietitle = ? and cinema = ?"
then you set movietitle and cinema to those which the user selected. If the resultset contains more than 0 rows, that means the movie is available.
Below is the sample code, it assumes you have a connection to the database:
PreparedStatement stat = myConnection.prepareStatement("select * from the_table where movietitle = ? and cinema = ?");
stat.setString(1, usersMovieTitleSelection);
stat.setString(2, usersCinemaSelection);
ResultSet res = stat.executeQuery();
if (res.next()) {
out.print("The movie is available");
} else {
out.print("The movie is not available");
}Now just add that to your JSP page. Enjoy ! =) -
Count depending on condition - Oracle
I want to count only rows which satisfy a particular condition.
I have several conditions but it needs to be one query. How would I do that?
ex:
select
count (no of days) where sales where below 100
count (no of days) where no of customers were below 100
from products
join customers
join salesLike this, can you post your table structure
select
count (case when nb_sales < 100 then no_of_days end ) ,
count (case when no_ of_customers < 100 then no_of_days end )
from products
join customers
join sales
group by no_client Example
SQL> select * from emp order by deptno;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7839 KING PRESIDENT 17-NOV-81 5000 10
7934 MILLER CLERK 7782 23-JAN-82 1300 10
7566 JONES MANAGER 7839 02-APR-81 2975 20
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7369 SMITH CLERK 7902 17-DEC-80 800 20
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-DEC-81 950 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
14 rows selected.
SQL>
SQL> select deptno ,count( case when sal>1000 then 1 end ) cpt_sup_1000,
2 count( case when sal<=1000 then 1 end ) cpt_ind_equ_1000
3 from emp
4 group by deptno;
DEPTNO CPT_SUP_1000 CPT_IND_EQU_1000
30 5 1
20 4 1
10 3 0
SQL> Add example -
Strange problem oracle db is starting automatically
Friends,
OS: RHEL AS 3.0
DB: Oracle 9iR2
when ever my rhel server is starting/restarting oracle database is starting up automatically.
There is no crontab job either in the root user or in the oracle user.
Also, i checked in the oratab entry that also fine.
i checked in /etc/rc3.d there also nothing related to oracle.
what might be the reason?where i have to check for this?
thanksis there any script related to oracle start/stop under /etc/init.d/
You can read here for more details on automating startup of db:
http://www.oracle-base.com/articles/linux/AutomatingDatabaseStartupAndShutdownOnLinux.php -
Hi ,
I am writing a merge query for a Java application. I have a screen and I am going to take the values in the screen and check if those values exist in the database. If they exist, then I will have to update the data, else I will have to insert the data.
The query is like
MERGE INTO XYZ USING
(SELECT BONUS_ID,CUST_NBR FROM XYZ)B ON
(B.BONUS_ID = 2027 and B.CUST_NBR='181258225')
WHEN MATCHED THEN UPDATE SET
CUST_TYPE= 'S', REV_AMT= 123, POUND_TOTAL= 123, PKG_TOTAL= 123 WHERE
CUST_NBR = '181258225'
WHEN NOT MATCHED THEN INSERT
But this query is not working. I get the "Missing Keyword"I meant nothing else
update xyz set ... where ...;
and
insert into xyz select ... from xyz where ...;
I wrote "When I check B.Bonus_ID it refers to the BonusID from XYZ table".
Let me give you one example with SCOTT schema.
I hope it illustrates well my concern of your
statement:
SQL> select ename, empno, sal from emp;
 
ENAME EMPNO SAL
SMITH 7369 800
ALLEN 7499 1600
WARD 7521 1250
JONES 7566 2975
MARTIN 7654 1250
BLAKE 7698 2850
CLARK 7782 2450
SCOTT 7788 3000
KING 7839 5000
TURNER 7844 1500
ADAMS 7876 1100
JAMES 7900 950
FORD 7902 3000
MILLER 7934 1300
 
14 rows selected.
 
SQL> merge into emp using (select * from emp) b
2 on (b.ename = 'KING')
3 when matched then update set sal = 1000
4 when not matched then insert (emp.empno, emp.ename, emp.deptno, emp.sal
5 values(-b.empno, b.ename, b.deptno, 0)
6 /
 
27 rows merged.
 
SQL> select ename, empno, sal from emp;
 
ENAME EMPNO SAL
SMITH -7369 0
ALLEN -7499 0
WARD -7521 0
JONES -7566 0
MARTIN -7654 0
BLAKE -7698 0
CLARK -7782 0
SCOTT -7788 0
TURNER -7844 0
ADAMS -7876 0
JAMES -7900 0
FORD -7902 0
MILLER -7934 0
SMITH 7369 1000
ALLEN 7499 1000
WARD 7521 1000
JONES 7566 1000
MARTIN 7654 1000
BLAKE 7698 1000
CLARK 7782 1000
SCOTT 7788 1000
KING 7839 1000
TURNER 7844 1000
ADAMS 7876 1000
JAMES 7900 1000
FORD 7902 1000
MILLER 7934 1000
 
27 rows selected.Rgds.
Maybe you are looking for
-
I am using tye datasrc 2lis_11_v_itm for loading oen order qty & open porder values in to cube 0sd_c03 When I compare these values with va05 eneter sold to party & sale org,document date selct open sales orders & execute Then in that report I am che
-
Printing issue of report output
Hi Friends, I am trying to print a report having one record but getting printed two pages instead of one. The first page contains the output data and second page contains 'Data statistics and number of records' which can be accomodated in same pa
-
Moving house, do I need to be in?
Got an activation date for our house move on the 30th of the month. Will I need to be in (does an engineer need access to the new house) on that day? Or is it all just at the exchange? Worried now as well, as Sky are the providers at the new propert
-
How do I calculate days from two different dates?
Hi all, How do I calculate days from two different dates? my requirement is to pass the number of days to target field from two dates. Current date : 14/04/2010 Standard date: 01/01/1957 is the standard = day 0 Is it possible in graphical mapping wi
-
Hello Everyone, I've Installed Windows 8 using Bootcamp, and installed all the drivers on the boot camp folder, but I have no sound. I wiped the partition, reinstalled and still no sound. I have also gone on the realtek website, downloaded drivers, s