oracle11g

Oracle 11g: In PL/SQL is there any way to get info about inserted and updated rows after MERGE DML statement?

若如初见. 提交于 2020-02-02 13:16:55
问题 I would like to know is there any way to receive information in PL/SQL how many rows have been updated and how many rows have been inserted while my PL/SQL script using MERGE DML statement. Let's use Oracle example of merge described here: MERGE example This functionality is used in my function but also I'd like to log information how many rows has beed updated and how many rows have been inserted. 回答1: There is a not a built-in way to get separate insert and update counts, no. SQL%ROWCOUNT

What means square brackets in Oracle SQL query?

一世执手 提交于 2020-02-02 02:26:08
问题 I find select statement with square brackets in it. Can anybody explain what does this brackets means? e.g. select a,b,[c] from table1; Thanks. 回答1: According to oracle's documentation: http://docs.oracle.com/cd/B10500_01/text.920/a96518/cqspcl.htm The bracket characters serve to group terms and operators found between the characters; however, they prevent penetrations for the expansion operators (fuzzy, soundex, stem). Its a grouping character in the query. 回答2: This is not a valid Oracle

Oracle function to compare strings in a not ordered way

淺唱寂寞╮ 提交于 2020-01-31 18:34:53
问题 I need a function to make a comparison between two strings withouth considering the order in oracle. i.e. "asd" and "sad" should be considered as equal. Are there similar functions? Or I need to write my own function? 回答1: This can be done with a simple java function to sort the characters of a string alphabetically: CREATE AND COMPILE JAVA SOURCE NAMED SORTSTRING AS public class SortString { public static String sort( final String value ) { final char[] chars = value.toCharArray(); java.util

Drop partitions older than 2 months

ぐ巨炮叔叔 提交于 2020-01-31 05:42:29
问题 I have a table with partition based on date field. Now, I have to write a procedure to drop all partitions older than 2 months i.e. test_date is older than 2 months. How do I do it? create table test_table ( test_id number, test_date date, constraint pk_test primary key (test_id) ) partition by range (test_date) ( PARTITION pt01122012 VALUES LESS THAN (TO_DATE('01-DEC- 2012', 'DD-MON-YYYY')), PARTITION pt01022013 VALUES LESS THAN (TO_DATE('01-FEB- 2013', 'DD-MON-YYYY')), PARTITION pt01042013

Query to find Employees who have taken more than their eligible leave with respect to their Job Roles

落花浮王杯 提交于 2020-01-25 10:33:05
问题 I have these tables with the following columns : Employee24( EMPLOYEEID, FIRSTNAME, LASTNAME, GENDER, JOBROLES); Leave25( EMPLOYEEID,LEAVEID, LEAVETYPE, STARTDATE, ENDDATE); JOBROLESELIGIBLELE(JOBROLES, ELIGIBLE_SICK_LEAVES, ELIGIBLE_EARNED_LEAVES) I want to write a query to find employees who have taken more than eleigible leaves with respect to jobroles SELECT * FROM EMPLOYEE24 WHERE EMPLOYEEID IN (SELECT EMPLOYEEID FROM LEAVE25 L WHERE (STARTDATE-ENDDATE) < (SELECT ELIGIBLE_SICK_LEAVES +

how to select a unique record in a table which has no key constraints [duplicate]

自闭症网瘾萝莉.ら 提交于 2020-01-25 10:27:27
问题 This question already has answers here : Fetch the row which has the Max value for a column (34 answers) Closed 4 years ago . I had a table named uniq_select_records with the following columns: sno number, item_name varchar2(50), start_date date, end_date date, action_flag char(1), last_modified_date date, creation_date date sno is a column which I used to identify a row for a item_name and it is not unique or primary key but it was not null. sno will be present for each item. no of items is

How do I reuse Oracle sequence gaps in primary key column?

戏子无情 提交于 2020-01-25 07:06:27
问题 I used Oracle sequence as primary key of a table, and used int in Java application mapping this primary key, now I found my customer has reached to the maximum int in table, even the sequence can be continuous increase. but Java int has no longer able to store it, I don't want change Java code from int to long because of very big cost. then I found customer DB there have many big gaps in ID column. can any way I can reuse these missing Id number? If can do this in DB level, something like I

How to get the nth string in any generic word or sentence with a space delimiter

◇◆丶佛笑我妖孽 提交于 2020-01-25 04:00:07
问题 How do I get the nth word in a sentence or a set of strings with space delimiter? Sorry for the change in the requirement.Thank you. 回答1: By using instr. select substr(help, 1, instr(help,' ') - 1) from ( select 'hello my name is...' as help from dual ) instr(help,' ') returns the positional index of the first occurrence of the second argument in the first, inclusive of the string you're searching for. i.e. the first occurrence of ' ' in the string 'hello my name is...' plus the space. substr

Version Query Output after Insert, Update and Delete

萝らか妹 提交于 2020-01-24 14:42:46
问题 Following is a question related to Oracle SQL Expert exam and have 4 choices. It says the correct answer is C. But I have a doubt and think that D should be the answer as this uses Oracle FlashBack technique. Can anybody explain this please. Thank you. Q)Evaluate the following statements: CREATE TABLE digits (id NUMBER(2), description VARCHAR2(15)); INSERT INTO digits VALUES (1,'ONE'); UPDATE digits SET description='TWO' WHERE id=1; INSERT INTO digits VALUES (2, 'TWO'); COMMIT; DELETE FROM

oracle sql listagg [duplicate]

寵の児 提交于 2020-01-24 13:02:11
问题 This question already has an answer here : Not able to use LISTAGG (1 answer) Closed 2 years ago . SELECT deptno, LISTAGG(ename, ',') WITHIN GROUP (ORDER BY ename) AS employees FROM emp GROUP BY deptno; Error:- ORA-00923: FROM keyword not found where expected 00923. 00000 - "FROM keyword not found where expected" *Cause: *Action: Error at Line: 1 Column: 42 Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production 回答1: For the 10gR2 or 11gR1 versions of Oracle , you can use