oracle10g

Oracle - return newly inserted key value

雨燕双飞 提交于 2021-02-07 05:43:21
问题 We have a table with a Primary Key that gets populated on insert by a trigger on the table - the trigger gets the next sequence number from a sequence we created for the table and uses that for the value of the key on insert. Now we would like to be able to return that value in our insert procedure (PL\SQL), similar to select @@scope_identity in SQL Server. I have been googling all day and basically come up with nothing - anyone been successful with this before? Thanks 回答1: I don't know if it

Oracle 10g accepting 5 digit year in a Date

风流意气都作罢 提交于 2021-02-02 09:55:13
问题 I managed to enter the date 21-Feb-12017 (I know it's not a correct date) in Oracle 10g into a date column. Oracle accepted the date fine. When I tried to select it back in SQL Developer, SQL Developer displayed it as NULL. But when I tried to retrieve the date thru java, I got the value back as how I inserted. Wondering what's going on because I could also see that Oracle converted a different 5 digit year into a 4 digit year. I entered 21-Feb-21019 and Oracle converted the year to 4581

How Can I Send Emails in PL/SQL (Oracle)?

橙三吉。 提交于 2021-01-29 06:44:06
问题 I have a procedure which count the number of rows in SMS_OUTBOX table and send emails if its row cont is over 1000. My procedure is given below: CREATE OR REPLACE PROCEDURE SEND_EMAIL_ABOUT_PENDING_SMS IS CHECK_SMS_COUNT NUMBER := 1000; CURRENT_SMS_COUNT NUMBER; BEGIN SELECT COUNT(1) INTO CURRENT_SMS_COUNT FROM SMS_SCHEMA.SMS_OUTBOX; IF CURRENT_SMS_COUNT >= CHECK_SMS_COUNT THEN UTL_MAIL.SEND( sender=>'<SENDER_EMAIL>', recipients=>'<RECIPIENT_EMAIL>', subject=>'Pending SMS', Message=>'Pending

Formatting INTERVAL DAY(0) TO SECOND(0)

蹲街弑〆低调 提交于 2021-01-27 21:46:06
问题 I have a few time fields that are INTERVAL DAY(0) TO SECOND(0) Datatypes to store various times of the day. Currently on normal retrieval, my fields display as such: +00 19:00:00.000000 How am I able to format this such that it displays as 19:00? 回答1: You want hours and minutes from an interval. If that interval cannot exceed 24 hours, then you can add the interval to a date without time part and then use TO_CHAR to get the formatted hours and minutes: select to_char(trunc(sysdate) +

how to show only the time in oracle?

笑着哭i 提交于 2021-01-27 05:09:19
问题 I have table that has date field. When I run a query, I see this: 01/10/2009 22:10:39 How can I retrieve only the time (IE: 22:10:39) 回答1: you can try this: SELECT TO_CHAR(yourval, 'DD-MON-YYYY HH:MI:SS') FROM yourtable; SELECT TO_CHAR(yourval, 'HH:MI:SS') FROM yourtable; Edit: as @steven pointed out, to have 24 hours style use SELECT TO_CHAR(yourval, 'HH24:MI:SS') FROM yourtable; 回答2: You need the format HH24 , since HH is only a 12 hour date. select to_char(SYSDATE, 'HH24:MI:SS') from dual

how to show only the time in oracle?

…衆ロ難τιáo~ 提交于 2021-01-27 05:06:53
问题 I have table that has date field. When I run a query, I see this: 01/10/2009 22:10:39 How can I retrieve only the time (IE: 22:10:39) 回答1: you can try this: SELECT TO_CHAR(yourval, 'DD-MON-YYYY HH:MI:SS') FROM yourtable; SELECT TO_CHAR(yourval, 'HH:MI:SS') FROM yourtable; Edit: as @steven pointed out, to have 24 hours style use SELECT TO_CHAR(yourval, 'HH24:MI:SS') FROM yourtable; 回答2: You need the format HH24 , since HH is only a 12 hour date. select to_char(SYSDATE, 'HH24:MI:SS') from dual

how to show only the time in oracle?

我的梦境 提交于 2021-01-27 05:06:48
问题 I have table that has date field. When I run a query, I see this: 01/10/2009 22:10:39 How can I retrieve only the time (IE: 22:10:39) 回答1: you can try this: SELECT TO_CHAR(yourval, 'DD-MON-YYYY HH:MI:SS') FROM yourtable; SELECT TO_CHAR(yourval, 'HH:MI:SS') FROM yourtable; Edit: as @steven pointed out, to have 24 hours style use SELECT TO_CHAR(yourval, 'HH24:MI:SS') FROM yourtable; 回答2: You need the format HH24 , since HH is only a 12 hour date. select to_char(SYSDATE, 'HH24:MI:SS') from dual

Cumulative Calculation - Based on Sample Data

梦想与她 提交于 2021-01-20 12:43:54
问题 Hi I am providing Sample Data below: Based on Sample data I want result output as per screenshot .. create table mytable ( emp_name varchar2(50) ,dept_number number ,Salary number ,Calendar_Year number ,Calendar_Period number ); insert into mytable values ('Bob',6620,6500,2020,1); insert into mytable values ('Bob',6620,1500,2020,1); insert into mytable values ('Rachel',6620,3400,2020,1); insert into mytable values ('Nancy',6620,1400,2020,1); insert into mytable values ('Rachel',6620,4500,2020

Cumulative Calculation - Based on Sample Data

谁说我不能喝 提交于 2021-01-20 12:41:28
问题 Hi I am providing Sample Data below: Based on Sample data I want result output as per screenshot .. create table mytable ( emp_name varchar2(50) ,dept_number number ,Salary number ,Calendar_Year number ,Calendar_Period number ); insert into mytable values ('Bob',6620,6500,2020,1); insert into mytable values ('Bob',6620,1500,2020,1); insert into mytable values ('Rachel',6620,3400,2020,1); insert into mytable values ('Nancy',6620,1400,2020,1); insert into mytable values ('Rachel',6620,4500,2020

Row with latest value by customer and month [duplicate]

丶灬走出姿态 提交于 2021-01-04 04:21:08
问题 This question already has answers here : Fetch a record on maximum date of every month (3 answers) Closed last month . I have a table that keeps track of changes in customer profiles. Here's a simplified version: CREATE TABLE HISTORY ( CUSTOMER_ID NUMBER(9,0), DATE_CHANGED DATE, ACCOUNT_TYPE VARCHAR2(20), CONSTRAINT HISTORY_PK PRIMARY KEY (CUSTOMER_ID, DATE_CHANGED) ); INSERT INTO HISTORY (CUSTOMER_ID, DATE_CHANGED, ACCOUNT_TYPE) VALUES (200, TO_DATE('05/01/2013 00:00:00','DD/MM/RRRR HH24:MI