oracle11g

How can I test for null and not null at the same time in sql?

蹲街弑〆低调 提交于 2019-12-13 08:56:08
问题 I have this sql: select * from employees where lastname like '%smith%' and firstname like '%bob%' and middle like '%%' The problem is the values of the name, particularly the middle name, can be null. So the statement above will find: smith, bob mike but will not find smith, bob because Bob's middle name is null (he has no middle name.) I have this which works but I thought there was a better way and wanted input: select * from employees where lastname like '%smith%' and firstname like '%bob%

how to get all version and latest iteration of object in the SQL

久未见 提交于 2019-12-13 08:55:54
问题 I'm very new to SQL... I have data like below in table called versioniteration . I want build a query in SQL (oracle) to get the out as in the second table. Please guide me how to do this? Here the part get altered many times in given version, each time the changes made the iteration increases. The part can also change to new version then the Iteration will be assigned (number). | Name | Version | Iteration | |===============|===============|============| | Part 1 | A | 1 | |:----------------

Top 2 offers with sum of all offers

为君一笑 提交于 2019-12-13 08:30:40
问题 Can someone please tell how can I get the results as below. Using dense_rank function where rank <=2 will give me top 2 offers. I am also looking to get 'total_offer' which should be sum of 'offer1' and 'offer2'. when there is no offer2 ( eg:taurus) 'total offer' should be 'offer1' and 'null' for 'offer2' Input: customer make zipcode offer notes mark focus 101 250 cash mark focus 101 2500 appreciation cash mark focus 101 1000 cash mark focus 101 1500 cash offer henry 520i 21405 500 cash offer

How to deal with sequence in insert from XMLTable?

≯℡__Kan透↙ 提交于 2019-12-13 07:17:43
问题 I have write a PL/SQL function that takes input in XML format for the following table: TABLE: TBL_MEDICAL_CENTER_BILLS Name Null Type ------------- -------- ------------- MED_RECORDNO NOT NULL NUMBER MED_EMPID NVARCHAR2(10) MED_BILL_HEAD NVARCHAR2(20) MED_DATE DATE MED_AMOUNT FLOAT(126) Here is the function code: FUNCTION save_medical_center_bills(medical_bill_data NVARCHAR2 ) RETURN clob IS ret clob; xmlData XMLType; v_code NUMBER; v_errm VARCHAR2(100); BEGIN xmlData:=XMLType(medical_bill

ORA-06550: Wrong number or type of arguments error | Calling Oracle Procedure with Table type IN parameter

强颜欢笑 提交于 2019-12-13 06:59:14
问题 We have one stored procedure in Oracle which accepts 1 IN parameter of type Table of Varchar2(50) . This is just sample Procedure to test how to pass IN parameter of type table. We are using PLSQLAssociativeArray type parameter to pass the array as IN parameter. But it is throwing error: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'SPGETMARKETPROMOTIONS' ORA-06550: line 1, column > 7: PL/SQL: Statement ignored I have read mostly all the threads

Sqlldr- No terminator found after terminated and enclosed field

烂漫一生 提交于 2019-12-13 06:57:41
问题 I use Oracle 11g. My data file looks like below: 1|"\a\ab\"|"do not "clean" needles"|"@" 2|"\b\bg\"|"wall "69" side to end"|"@" My control file is: load data infile 'short.txt' CONTINUEIF LAST <> '"' into table "PORTAL"."US_FULL" fields terminated by "|" OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS ( u_hlevel, u_fullname NULLIF u_fullname=BLANKS, u_name char(2000) NULLIF c_name=BLANKS , u_no NULLIF u_no=BLANKS ) While loading data through sqlldr, a .bad file is created and .log file contains

-bash: imp: command not found oracle

狂风中的少年 提交于 2019-12-13 06:54:47
问题 I have a centos Linux machine and a oracle server installed on a server which is located at a remote location. I have installed oracle client on my Linux centos machine using the link : How to install SQL * PLUS client in linux It may be noted that while installing client there was no /network/admin directory and hence no tnsnames.ora file. now I have manually created the directories and have have created a tnsnames.ora file. I am able to connect to remote server. Now when I look into the bin

oracle - same query but different plan in 11g and 12c

人盡茶涼 提交于 2019-12-13 06:48:49
问题 This Question is relative to this question. This is code i try to use in 12c SELECT * FROM DMProgDate_00001 WHERE 1=1 AND ProgressOID IN ( SELECT P.OID FROM ( SELECT OID FROM ( SELECT A.OID, ROWNUM as seqNum FROM ( SELECT OID FROM DMProgress_00001 WHERE 1=1 AND Project = 'Moho' AND Phase = 'Procurement' AND Displine = 'Q340' ORDER BY actCode ) A WHERE ROWNUM <= 20 ) WHERE seqNum > 0 ) P ); result 11g : under 1 sec 12c : over 8 sec This is the query plan in 11g This is the query plan in 12c

How to get database notification to C++ application

大憨熊 提交于 2019-12-13 06:03:46
问题 We are developing a C++ server which will process based on time based events. For example if a particular user has configured a particular task that has to be processed at a particular time, then an event or notification needs to be sent to the C++ server from the database, to initiate the task. The timming configuration is stored in the database, and the C++ server shouldnt poll the database at an interval, but event should be notified from the database at the configured timming. We are

Constraining a database table so only one row can have a particular value in a column

て烟熏妆下的殇ゞ 提交于 2019-12-13 05:38:37
问题 I am brand new to SQL and I am trying to figure out an error message I get when I try to follow the suggestions in the post here to enforce only one 'Yes' in my column. DROP TABLE team CASCADE CONSTRAINTS PURGE; create table team ( name varchar2(4) NOT NULL UNIQUE, isTeamLead char(3) check (isTeamLead in ('Yes'))); create unique index only_one_yes on team(isTeamLead) (case when col='YES' then 'YES' end); The error report is as follows: Error report - SQL Error: ORA-02158: invalid CREATE INDEX