Oracle

Sub-select in oracle

≯℡__Kan透↙ 提交于 2021-01-27 05:35:33
问题 I'm trying to select the newest price from another table in a sub select. But I can't figure out how to get it working. This is what I've tried: select something, somthingelse, ( select * from ( select QUOTE_PRICE as old_price from price_history where price_history.part_no= article_table.part_no order by valid_from desc ) where rownum=1 ) from article_table where rownum < 5 The subselect works by itself, but it can't find article_table.part_no : SQL Error: ORA-00904: "article_table "."part_no

Sub-select in oracle

假如想象 提交于 2021-01-27 05:34:12
问题 I'm trying to select the newest price from another table in a sub select. But I can't figure out how to get it working. This is what I've tried: select something, somthingelse, ( select * from ( select QUOTE_PRICE as old_price from price_history where price_history.part_no= article_table.part_no order by valid_from desc ) where rownum=1 ) from article_table where rownum < 5 The subselect works by itself, but it can't find article_table.part_no : SQL Error: ORA-00904: "article_table "."part_no

Suggested method of handling non-overlapping ranges (e.g. scheduling)

梦想的初衷 提交于 2021-01-27 05:16:18
问题 I've seen this sort of problems a few times and am trying to decide the best way of storing ranges in a non-overlapping manner. For example, when scheduling some sort of resource that only one person can use at a time. Mostly what I've seen is something like this: PERSON ROOM START_TIME END_TIME Col. Mustard Library 08:00 10:00 Prof. Plum Library 10:00 12:00 What's the best way of preventing new entries from overlapping an existing schedule, like say if Miss Scarlet wants to reserve the

Trigger alternatives for two tables that have to mutually update each other

余生颓废 提交于 2021-01-27 05:15:51
问题 (Sorry for the long post, but I guess all the information is really necessary) We have two tables - task and subtask. Each task consists of one or more subtasks, and each of these objects has a start date, end date and duration. Additionally, subtasks have a ordering. Tables create table task ( pk number not null primary key, name varchar2(30) not null, start_date date, duration_in_days number, end_date date, needs_recomputation number default 0 ); create table subtask ( pk number not null

Suggested method of handling non-overlapping ranges (e.g. scheduling)

試著忘記壹切 提交于 2021-01-27 05:15:28
问题 I've seen this sort of problems a few times and am trying to decide the best way of storing ranges in a non-overlapping manner. For example, when scheduling some sort of resource that only one person can use at a time. Mostly what I've seen is something like this: PERSON ROOM START_TIME END_TIME Col. Mustard Library 08:00 10:00 Prof. Plum Library 10:00 12:00 What's the best way of preventing new entries from overlapping an existing schedule, like say if Miss Scarlet wants to reserve the

Oracle DB to EF not working correctly for NUMBER(2,0)

时光总嘲笑我的痴心妄想 提交于 2021-01-27 05:14:52
问题 I have a table column defined like this: ENTRY_STATUS NUMBER(2, 0) And in my EntityFramework class the respective field is defined like this: [Column("ENTRY_STATUS")] public int Status { get; set; } When checking the value to get an entry it works perfectly fine: var order = testDbContext.Orders.FirstOrDefault(o => o.Status > 1); But when I check the order entity after this statement it is always zero: if (order != null) { if (order.Status == 3) //Always Zero!!! { //Do something... } } What

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

Oracle: What does 'execute immediate' mean?

爱⌒轻易说出口 提交于 2021-01-27 05:07:24
问题 What is the significance of execute immediate in PL/SQL when used with DML and DDL statements? Does execute immediate implicitly commit to a database like DDL statements do ? The following is an example I have encountered: SELECT 'TRUNCATE TABLE BD_BIDS_APPR_DET' INTO V_SQL1 FROM DUAL; EXECUTE IMMEDIATE V_SQL1; SELECT 'TRUNCATE TABLE BD_BIDS_SYS_DET' INTO V_SQL1 FROM DUAL; EXECUTE IMMEDIATE V_SQL1; SELECT 'TRUNCATE TABLE BD_BIDS_EXT_DET' INTO V_SQL1 FROM DUAL; EXECUTE IMMEDIATE V_SQL1; 回答1:

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