oracle10g

What SQL returns duplicates in first column where values in 2nd column differ?

萝らか妹 提交于 2019-12-13 15:15:00
问题 Question is very similiar to this find duplicates but I'd like to find only those duplicate id with code different than 'ROME' and at least one name is 'ROME'. I want desired results because: 1. ID is duplicate. 2. At least one origin is 'ROME' 3. Remaining rows for that ID are NOT 'ROME' Table ID ORIGIN ----------- 1 ROME 1 ROME 2 ROME 2 LODI 3 ASTI 4 PISA 4 BARI Desired Results ID ORIGIN ----------- 2 ROME 2 LODI 回答1: SELECT id, origin FROM My_Table T1 WHERE EXISTS (SELECT * FROM My_Table

Oracle special characters

一世执手 提交于 2019-12-13 14:21:40
问题 I have a query select * from table where name in ('52 T&M', '60 T&M'); The "&" is causing the query to expect a parameter. How do I qualify the "&" in the query to sting so that the query can find string with the "&" character in them? 回答1: I would normally use set define off as suggested by omg but it is also possible to do it like this: select * from table where name in ('52 T'||Chr(38)||'M', '60 T'||Chr(38)||'M'); 回答2: The ampersand ("&") is a character interpreted by SQLPlus as a variable

Oracle query using 'like' on indexed number column, poor performance

狂风中的少年 提交于 2019-12-13 12:01:25
问题 On Query 1 a full table scan is being performed even though the id is an indexed column. Query 2 achieves the same result but much faster. If Query 1 is run returning an indexed column then it returns quickly but if non-indexed columns are returned or the entire row is then the query takes longer. In Query 3 it runs fast but the column 'code' is a VARCHAR2(10) in stead of a NUMBER(12) and is indexed the same way as 'id'. Why does Query 1 not pick up that it should use the index? Is there

output with single quote in sql

≯℡__Kan透↙ 提交于 2019-12-13 11:25:55
问题 Table Values CNAME Firstname Amount Postalcode Lastname Accountnumber REQUIRED O/P CNAME 'Firstname' 'Amount' 'Postalcode' 'Lastname' 'Accountnumber' 回答1: In mysql you can use the function concat(): SELECT CONCAT("'", CNAME, "'") FROM yourTable In oracle you can use the same function as above concat() or the concatenation operator: SELECT '''' || CNAME || '''' FROM yourTable; SELECT CONCAT('''', CNAME, '''') FROM yourTable; 来源: https://stackoverflow.com/questions/41736930/output-with-single

Retrieve records from a specific column in oracle

好久不见. 提交于 2019-12-13 11:06:25
问题 S.NO id Pid 1 123 PAQ123 2 433 WSD3FF 3 565 PAS45E 4 123 PAQ123X 5 433 WSD3FFY 6 123 PAQ123Z suppose the above is the sample records in the database. Now I want to find out in the database whether there is any word (example PAQ123) which is repeating with some prefixes/suffixes like in (PAQ123X,PAQ123Z). How can I write a query which would result into the above list scenario? 回答1: Oracle Setup : CREATE TABLE table_name ( S_NO, id, Pid ) AS SELECT 1, 123, 'PAQ123' FROM DUAL UNION ALL SELECT 2,

How to find host string?

試著忘記壹切 提交于 2019-12-13 08:28:13
问题 I have just installed Oracle - DevSuitehome2, Oracle Database 10g Express Edition and Oracle Developer Suit - DevSuiteHome2. I am new to this Oracle forms, Oracle Reports, etc. During installation, it asked for the password. I entered it. It was written that use your password in SYS and SYSTEM Database accounts. After installation was completed I started SQL *Plus. I entered SYSTEM as username and my password. ERROR: ORA-12154 :TNS:could not resolve the connect identifier specified I also

how can save DateTime c# language to oracle10g database

徘徊边缘 提交于 2019-12-13 08:27:53
问题 there is a table== create table newstudent(enroll int, name varchar2(20), DoJoin date); in c# when i type oraclecommand(1,'amit purohit', DateTime.Now()); //Error found 'nvalid month' oraclecommand(1,'amit purohit', String.Format("{0:dd-MMM-yyyy}")); //problme that save only date into database but i need time also. like '11-AUG-2009 11:22:32.0' oraclecommand(1,'amit purohit', String.Format("{0:dd-MMM-yyyy hh:mm:ss}") //also error get like string picture format in date time values 回答1: One of

How to call oracle function which return sys_refcursor using java + hibernate

房东的猫 提交于 2019-12-13 08:03:53
问题 I am having a problem while calling oracle function, the function look like bellow CREATE OR REPLACE FUNCTION get_port_out_select (pi_id_pout_order IN PORT_OUT_ORDER.ID_POUT_ORDER % TYPE) RETURN sys_refcursor IS lc_cursor sys_refcursor; BEGIN OPEN lc_cursor FOR SELECT ID_POUT_ORDER, ID_LEC_USER, ID_POUT_LEC, ID_SERVICE_REC, POUT_TN, ID_IPTN, POUT_LEC_OCN, POUT_LEC_SPID, POUT_ALI_CODE, LEC_CONTACT_FNAME, LEC_CONTACT_LNAME, LEC_CONTACT_TN, LEC_CONTACT_EMAIL, DL_LEC_OCN, CUST_ACCT, CUST_F_NAME,

Creating this table in oracle 10g

心已入冬 提交于 2019-12-13 07:27:49
问题 This table is not creating in oracle 10g and I dont know why, the code is CREATE TABLE "shift" ( SHIFT_DATE DATE, OPERATOR1 VARCHAR2(30), ENGINEER VARCHAR2(30), ENGINEER2 VARCHAR2(30), MANAGER VARCHAR2(30), SHIFT VARCHAR2(5), PRIMARY KEY (SHIFT_DATE) ENABLE, FOREIGN KEY (MANAGER) REFERENCES SHIFT_MNG (MANAGER) ENABLE FOREIGN KEY (SHIFT) REFERENCES SHIFT_TYPE (SHIFT) ENABLE ); the Error message i get is ORA-00907: missing right parenthesis Any help would be greatly appreciated Thanks 回答1:

RA-00904 invalid identifier error even when column name exists

萝らか妹 提交于 2019-12-13 07:14:14
问题 I am running an oracle query in sqldeveloper: merge into invoices c using (select CUSTOMER_ID, INVOICE_NUMBER, INVOICE_DATE from dual where INVOICE_NUMBER = '123' and CUSTOMER_ID = '456' and INVOICE_DATE = '19-APR-12') cd on (c.INVOICE_NUMBER = cd.INVOICE_NUMBER) when not matched then insert (c.CUSTOMER_ID, c.INVOICE_NUMBER, c.INVOICE_DATE) values ('987', '654','179-APR-12') I keep getting a RA-00904 invalid identifier for the RA-00904 INVOICE_DATE column, even though that column exists. I