Select time from sysdate
Hi Experts,
I have to concatenate a date(not sysdate) with the system time and store it in a column having datatype as DATE...
So I tried like this....
SELECT
TO_CHAR (C_DATE, 'DD-MON-YYYY')
|| ' '
|| TO_CHAR (SYSDATE, 'HH:MI:SS PM')
FROM DUAL;
But while inserting the output of the above query in my table it throws error like this...
ORA-01830: date format picture ends before converting entire input string
Is there any possibility to achieve this....
Thanks in advance.
Hi,
The || operator produces a string. Don't use a string where a DATE is expected; use a DATE instead. For example
INSERT INTO new_table (c_date)
SELECT TRUNC (SYSDATE) + (c_date - TRUNC (c_date))
FROM old_table;
Similar Messages
-
How to subtract Time from Sysdate
Hello,
I want to subtract time from sysdate and get the sysdate with time.
Example : = (Sysdate with time)03-mar-2002 16:40:55 - 8 (hours). The result should be like :03-mar-2002 08:40:55
How to write a query for this?.
Please let me know as soon as possible.
Thanks,
Ravi.Hi Ravi...
SYSDATE includes time, TRUNC(SYSDATE) does not include time.
If you subtract these two, you'll get a positive number of 1.00 or less which is the fraction of a day. For instance high noon would have a fraction of 0.50000. 12:01 p.m. would be 0.50000 + (1/(24*60)), or 0.50069444....
If you want to set the clock back, by calculating a "date" that is 8 hours less than the SYSDATE, then SYSDATE - (8/24) will do that. This will work even if SYSDATE was something like 2 a.m., because it will then set it to 6 p.m. of the day before the day in SYSDATE.
If you want to set a "date" to a specific time on the day of SYSDATE, then calculate the fraction for that time and add it to the TRUNC(SYSDATE). High noon would be TRUNC(SYSDATE) + 0.5.
SELECT TO_CHAR(TRUNC(SYSDATE)+0.5,'DD-MON-YY HH:MI:SS am') AS NOON FROM DUAL;Hope this helps...
Larry Johnson -
i have a doubt as will a select based on a view will take more time than a select on 2 tables with a union.
View will be:-
create view1 as
select column1 from table1
union
select column1 from table2
so, will a
select * from view1
take more time than a
select column1 from table1
union
select column1 from table2
Please help in solving the doubt as it is urgent.
regards.If it's that urgent why didn't you just rustle up a test case for yourself? You could have done that in the time it took you to post, let alone wait for my slow fingers to type one up and compose this reply. We are all volunteers here and there's no SLA.
Here is a test case. Obviously the stats are different, that's because of the data in the buffer cache, but the EXPLAIN PLAN is identical (except for the VIEW bit), so the two queries should execute in a similar timeframe.
Cheers, APC
SQL> SET autotrace TRACEONLY
SQL> SELECT col1 FROM t_10K
2 UNION
3 SELECT col1 FROM t_5k1
4 /
10000 rows selected.
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=43 Card=15000 Bytes=
60000)
1 0 SORT (UNIQUE) (Cost=43 Card=15000 Bytes=60000)
2 1 UNION-ALL
3 2 INDEX (FAST FULL SCAN) OF 'T10K_PK' (UNIQUE) (Cost=3 C
ard=10000 Bytes=40000)
4 2 TABLE ACCESS (FULL) OF 'T_5K1' (Cost=3 Card=5000 Bytes
=20000)
Statistics
750 recursive calls
0 db block gets
213 consistent gets
71 physical reads
0 redo size
132870 bytes sent via SQL*Net to client
7825 bytes received via SQL*Net from client
668 SQL*Net roundtrips to/from client
16 sorts (memory)
0 sorts (disk)
10000 rows processed
SQL> CREATE VIEW v1 AS
2 SELECT col1 FROM t_10K
3 UNION
4 SELECT col1 FROM t_5k1
5 /
View created.
SQL> SELECT * FROM v1
2 /
10000 rows selected.
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=43 Card=15000 Bytes=
195000)
1 0 VIEW OF 'V1' (Cost=43 Card=15000 Bytes=195000)
2 1 SORT (UNIQUE) (Cost=43 Card=15000 Bytes=60000)
3 2 UNION-ALL
4 3 INDEX (FAST FULL SCAN) OF 'T10K_PK' (UNIQUE) (Cost=3
Card=10000 Bytes=40000)
5 3 TABLE ACCESS (FULL) OF 'T_5K1' (Cost=3 Card=5000 Byt
es=20000)
Statistics
19 recursive calls
0 db block gets
54 consistent gets
0 physical reads
0 redo size
132870 bytes sent via SQL*Net to client
7825 bytes received via SQL*Net from client
668 SQL*Net roundtrips to/from client
3 sorts (memory)
0 sorts (disk)
10000 rows processed
SQL> -
Extract time from sysdate or some other?
Dear all,
I want to extract the Hour as a number from sysdate. Plz guide me.
Ex: SELECT EXTRACT (YEAR FROM SYSDATE) FROM DUAL;
I want like SELECT EXTRACT (Hour FROM SYSDATE) FROM DUAL;
Thanks in Advance..you can use to_char function
select to_char(sysdate, 'hh24') from dualor use a timestamp with extract function
select systimestamp, extract(HOUR from systimestamp) from dual -
Select time from date type without to_char
I have table T(myDate date, + about 15 columns). When I insert values into it, i also insert the time of a date.
If I wanna see all the data in the table, I need to call to_char on column myDate. So need to write all the 15 column names in the select.
I'd like to simply write a select * from T, but see the time for myDate as well. Is this possible?
ThanksYou can use alter session in a SQLPlus session
See this example:
SQL>
SQL> select * from emp
2 where rownum <=2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
SQL>
SQL> alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS';
Session altered.
SQL>
SQL> select * from emp
2 where rownum <=2;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20-FEB-1981 00:00:00 1600 300 30Regards.
Al -
URGENT: Selecting only 25 records at a time from a table
URGENT !!!!
Hi,
Im having a RFC which selects records from a table (say table_A) and depending on these selected records, further processing is done within that RFC.
Now my problem is, this table_A contains around 200 matching records. Due to this entire logical processing consumes lot of time. Hence my RFC is taking huge time to produce result. (apprx 10 mins).
Can i select these matching records in batch of 25 and display result for these 25 records??
I'll give this batch size as input to RFC?
Do anybody have any idea about how to tackle this situation and reduce response time?
If u hav any better solution than this then pls pls let me know ASAP..
Regards,
AmeyAmey Mogare ,
Do One thing , create a new importing parameter in your RFC , say current_trans_id. NOw on the first call pass the initial value for current_trans_id.
then inside the logic .. change the select to
select upto 25 rows where trnascation id > current_trans_id.
next time when u call teh rfc.. send the last selected id as a value for current_trans_id.
i think you can some how use this logic
Regards
Sarath -
computer was infected by virus rebuilt after save but bookmark favorites saved as html files in folders not bookmark format
Yes, I tried that. The files were ordered by their original numbers as imported from the camera, but I batched them through Phocoshop to downsize all of them into a more manageable file size. I opened that destination folder from quick time from where it said select image sequence. I clicked on the first one and opened it. The result was a large image with an arrow indicating a movie was ready to go. When I pressed the arrow, though, I realized it had only imported that one frame so there was no movie. The files are Jpgs and are about 450 KB each.
To your knowledge are there any links to iMovie tutorials or quick time tutorials that may address this situation? Maybe there will be one I haven't looked at yet.
Thanks -
Insert/select one million rows at a time from source to target table
Hi,
Oracle 10.2.0.4.0
I am trying to insert around 10 million rows into table target from source as follows:
INSERT /*+ APPEND NOLOGGING */ INTO target
SELECT *
FROM source f
WHERE
NOT EXISTS(SELECT 1 from target m WHERE f.col1 = m.col2 and f.col2 = m.col2);There is a unique index on target table on col1,col2
I was having issues with undo and now I am getting the follwing error with temp space
ORA-01652: unable to extend temp segment by 64 in tablespace TEMPI believce it would be easier if I did bulk insert one million rows at a time and commit.
I appriciate any advice on this please.
Thanks,
Ashok902986 wrote:
NOT EXISTS(SELECT 1 from target m WHERE f.col1 = m.col2 and f.col2 = m.col2);
I don't know if it has any bearing on the case, but is that WHERE clause on purpose or a typo? Should it be:
NOT EXISTS(SELECT 1 from target m WHERE f.col1 = m.COL1 and f.col2 = m.col2);Anyway - how much of your data already exists in target compared to source?
Do you have 10 million in source and very few in target, so most of source will be inserted into target?
Or do you have 9 million already in target, so most of source will be filtered away and only few records inserted?
And what is the explain plan for your statement?
INSERT /*+ APPEND NOLOGGING */ INTO target
SELECT *
FROM source f
WHERE
NOT EXISTS(SELECT 1 from target m WHERE f.col1 = m.col2 and f.col2 = m.col2);As your error has to do with TEMP, your statement might possibly try to do a lot of work in temp to materialize the resultset or parts of it to maybe use in a hash join before inserting.
So perhaps you can work towards an explain plan that allows the database to do the inserts "along the way" rather than calculate the whole thing in temp first.
That probably will go much slower (for example using nested loops for each row to check the exists), but that's a tradeoff - if you can't have sufficient TEMP then you may have to optimize for less usage of that resource at the expense of another resource ;-)
Alternatively ask your DBA to allocate more room in TEMP tablespace. Or have the DBA check if there are other sessions using a lot of TEMP in which case maybe you just have to make sure your session is the only one using lots of TEMP at the time you execute. -
Select count(*) from table in oracle 11g with direct path read takes time
select count(*) from table takes long time, even more than couple of hours..
direct path read is the wait event which is almost is at 99%..
can u someone provide some info on this.. on solution.. thankxknowledgespring wrote:
table has millions of records... 130 millions..
select count(*) from BIG_SIZE_TABLE; --- executed in sql plus command prompt.
Rows Execution Plan
0 SELECT STATEMENT MODE: ALL_ROWS
0 SORT (AGGREGATE)
0 TABLE ACCESS MODE: ANALYZED (FULL) OF 'BIG_SIZE_TABLE' (TABLE)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 1 0.00 0.00
enq: KO - fast object checkpoint 1 0.01 0.01
Disk file operations I/O 18 0.00 0.00
direct path read 58921 0.34 418.54direct path read time waited is : 58921 total time waited: 418.54
That 418 seconds - not the hours you reported earlier. Is it possible that your connection to the database broke ?
On a typical system, by the way, you can usually turn one direct read for tablescan into 1MB, so your scan seems to have covered about 59 GB, which seems to be in the right sort of ballpark for 130M rows.
we have another query and when we test the query execution using v$sql, is_bind_sensitive =N, how to make is_bind_sensitive=Y all the time.. There is a hint /*+ bind_aware */ - I'd have to check whether or not it's documented at present. It might help.
I would be interested in hearing why you think the hint should be bind sensitive when the optimizer doesn't.
Regards
Jonathan Lewis -
Select extract(month from sysdate)+6 = returns 13 and not 1(jan)
Hi
I am using the following query to get the month 6 months from now.
select extract(month from sysdate)+6
from dualHow can I say that the month should be 6 months from todays month? It worked all these days because this month + 6 was always a valid month. Now it returns 13.When I run the following, I get '1'. I am expecting '01'. What am I doing wrong here?
SELECT substr(lpad(to_number(to_char(ADD_MONTHS(SYSDATE, 6),'MM')),2),1,2) FROM DUAL;
I need number - so using to_number. I need to extract the month, so using to_char. If someone could help me get 2 digits for the month and simplify the query if possible - would be great.
The table has month and date stored as number (bad idea I know but thats how it is). Now for January 31, it is stored as 131. For 15 Feb it is 215. What I need is give me records where the month is 6 months from now. Something like:
to_number(substr(lpad(tbl1.monthdt, 4, '0'), 1, 2)) in
substr(lpad(to_number(to_char(ADD_MONTHS(SYSDATE, 6),'MM')),2),1,2)Message was edited by:
bpel -
I replaced the original hdd in my early 2008 iMac. I can't move my files that were backed up with Time Machine to my new hdd using Migration Assistant. When prompted to select the "from drive", the ext. hhd does not appears as a selection. Please help!!
I'd recommend staring over, Pondini has created an excellent guide on how to use Setup Assistant. I'd recommend begin reading Pondini Setup Assistant tips where he talks about "Second Chance." Assuming your Time Machine backup is sound the restore should be very smooth.
Roger -
Time capsule newMac book pro,how do I retreive selected files from time capsule?
My old MacBook crashed recentlyandIjust purchased a new MacBook pro. I want to transfer selected files from my TimeCapsule but don't know how to do it. I used Migration Assistant but it would only allow me to transfer all of the files or apps and not individual ones. If I transfered the whole info over I would have minimal memory on my new computer (got a solid state 128 GB). Is there a way to see the contents of the Time machine and pullover the files I want andnot theones I dont? Thanks in advance
It says to plug in the drive in the other computer, but my old computer is dead, it wont even start up the hard drive was physicaly damaged. I tried control clicking on time machine and there are no discs to choose from.
Also when I try to enterthe time machine I get an error code -6584 -
How can I get the selected rows from two ALV grids at the same time?
I have a program that uses two ALV grids in one dialog screen. I'm using the OO ALV model (SALV* classes).
The user can select any number of rows from each grid. Then, when a toolbar pushbutton is pressed, I'd have to retrieve the selected rows from both grids and start some processing with these rows.
It is no problem to assign event handlers to both grids, and use the CL_SALV_TABLE->GET_SELECTIONS and CL_SALV_SELECTIONS->GET_SELECTED_ROWS methods to find out which rows were marked by the user. Trouble is, this only works when I raise an event in each grid separately, for instance via an own function that I added to the grid's toolbar. So, I can only see the selected rows of the same grid where such an event was raised.
If I try to do this in the PBO of the dialog screen (that contains the two grids), the result of CL_SALV_SELECTIONS->GET_SELECTED_ROWS will be empty, as the program does not recognize the marked entries in the grids. Also, an event for grid1 does not see the selected rows from grid2 either.
As it is right now, I can have an own button in both grid's toolbar, select the rows, click on the extra button in each grid (this will tell me what entries were selected per grid). Then, I'd have to click on a third button (the one in the dialog screen's toolbar), and process the selected rows from both grids.
How can I select the rows, then click on just one button, and process the marked entries from both grids?
Is it somehow possible to raise an event belonging to each grid programmatically, so that then the corresponding CL_SALV_SELECTIONS->GET_SELECTED_ROWS will work?
Thanks.Hello Tamas ,
If I try to do this in the PBO of the dialog screen (that contains the two grids), the result of CL_SALV_SELECTIONS->GET_SELECTED_ROWS will be empty, as the program does not recognize the marked entries in the grids. Also, an event for grid1 does not see the selected rows from grid2 either.--->
is it possible to have a check box in each grid & get the selected lines in PAI of the screen ?
regards
prabhu -
Performance issue in selecting data from a view because of not in condition
Hi experts,
I have a requirement to select data in a view which is not available in a fact with certain join conditions. but the fact table contains 2 crore rows of data. so this view is not working at all. it is running for long time. im pasting query here. please help me to tune it. whole query except prior to not in is executing in 15 minutes. but when i add not in condition it is running for so many hours as the second table has millions of records.
CREATE OR REPLACE FORCE VIEW EDWOWN.MEDW_V_GIEA_SERVICE_LEVEL11
SYS_ENT_ID,
SERVICE_LEVEL_NO,
CUSTOMER_NO,
BILL_TO_LOCATION,
PART_NO,
SRCE_SYS_ID,
BUS_AREA_ID,
CONTRACT,
WAREHOUSE,
ORDER_NO,
LINE_NO,
REL_NO,
REVISED_DUE_DATE,
REVISED_QTY_DUE,
QTY_RESERVED,
QTY_PICKED,
QTY_SHIPPED,
ABBREVIATION,
ACCT_WEEK,
ACCT_MONTH,
ACCT_YEAR,
UPDATED_FLAG,
CREATE_DATE,
RECORD_DATE,
BASE_WAREHOUSE,
EARLIEST_SHIP_DATE,
LATEST_SHIP_DATE,
SERVICE_DATE,
SHIP_PCT,
ALLOC_PCT,
WHSE_PCT,
ABC_CLASS,
LOCATION_ID,
RELEASE_COMP,
WAREHOUSE_DESC,
MAKE_TO_FLAG,
SOURCE_CREATE_DATE,
SOURCE_UPDATE_DATE,
SOURCE_CREATED_BY,
SOURCE_UPDATED_BY,
ENTITY_CODE,
RECORD_ID,
SRC_SYS_ENT_ID,
BSS_HIERARCHY_KEY,
SERVICE_LVL_FLAG
AS
SELECT SL.SYS_ENT_ID,
SL.ENTITY_CODE
|| '-'
|| SL.order_no
|| '-'
|| SL.LINE_NO
|| '-'
|| SL.REL_NO
SERVICE_LEVEL_NO,
SL.CUSTOMER_NO,
SL.BILL_TO_LOCATION,
SL.PART_NO,
SL.SRCE_SYS_ID,
SL.BUS_AREA_ID,
SL.CONTRACT,
SL.WAREHOUSE,
SL.ORDER_NO,
SL.LINE_NO,
SL.REL_NO,
SL.REVISED_DUE_DATE,
SL.REVISED_QTY_DUE,
NULL QTY_RESERVED,
NULL QTY_PICKED,
SL.QTY_SHIPPED,
SL.ABBREVIATION,
NULL ACCT_WEEK,
NULL ACCT_MONTH,
NULL ACCT_YEAR,
NULL UPDATED_FLAG,
SL.CREATE_DATE,
SL.RECORD_DATE,
SL.BASE_WAREHOUSE,
SL.EARLIEST_SHIP_DATE,
SL.LATEST_SHIP_DATE,
SL.SERVICE_DATE,
SL.SHIP_PCT,
0 ALLOC_PCT,
0 WHSE_PCT,
SL.ABC_CLASS,
SL.LOCATION_ID,
NULL RELEASE_COMP,
SL.WAREHOUSE_DESC,
SL.MAKE_TO_FLAG,
SL.source_create_date,
SL.source_update_date,
SL.source_created_by,
SL.source_updated_by,
SL.ENTITY_CODE,
SL.RECORD_ID,
SL.SRC_SYS_ENT_ID,
SL.BSS_HIERARCHY_KEY,
'Y' SERVICE_LVL_FLAG
FROM ( SELECT SL_INT.SYS_ENT_ID,
SL_INT.CUSTOMER_NO,
SL_INT.BILL_TO_LOCATION,
SL_INT.PART_NO,
SL_INT.SRCE_SYS_ID,
SL_INT.BUS_AREA_ID,
SL_INT.CONTRACT,
SL_INT.WAREHOUSE,
SL_INT.ORDER_NO,
SL_INT.LINE_NO,
MAX (SL_INT.REL_NO) REL_NO,
SL_INT.REVISED_DUE_DATE,
SUM (SL_INT.REVISED_QTY_DUE) REVISED_QTY_DUE,
SUM (SL_INT.QTY_SHIPPED) QTY_SHIPPED,
SL_INT.ABBREVIATION,
MAX (SL_INT.CREATE_DATE) CREATE_DATE,
MAX (SL_INT.RECORD_DATE) RECORD_DATE,
SL_INT.BASE_WAREHOUSE,
MAX (SL_INT.LAST_SHIPMENT_DATE) LAST_SHIPMENT_DATE,
MAX (SL_INT.EARLIEST_SHIP_DATE) EARLIEST_SHIP_DATE,
MAX (SL_INT.LATEST_SHIP_DATE) LATEST_SHIP_DATE,
MAX (
CASE
WHEN TRUNC (SL_INT.LAST_SHIPMENT_DATE) <=
TRUNC (SL_INT.LATEST_SHIP_DATE)
THEN
TRUNC (SL_INT.LAST_SHIPMENT_DATE)
ELSE
TRUNC (SL_INT.LATEST_SHIP_DATE)
END)
SERVICE_DATE,
MIN (
CASE
WHEN TRUNC (SL_INT.LAST_SHIPMENT_DATE) >=
TRUNC (SL_INT.EARLIEST_SHIP_DATE)
AND TRUNC (SL_INT.LAST_SHIPMENT_DATE) <=
TRUNC (SL_INT.LATEST_SHIP_DATE)
AND SL_INT.QTY_SHIPPED = SL_INT.REVISED_QTY_DUE
THEN
100
ELSE
0
END)
SHIP_PCT,
SL_INT.ABC_CLASS,
SL_INT.LOCATION_ID,
SL_INT.WAREHOUSE_DESC,
SL_INT.MAKE_TO_FLAG,
MAX (SL_INT.source_create_date) source_create_date,
MAX (SL_INT.source_update_date) source_update_date,
SL_INT.source_created_by,
SL_INT.source_updated_by,
SL_INT.ENTITY_CODE,
SL_INT.RECORD_ID,
SL_INT.SRC_SYS_ENT_ID,
SL_INT.BSS_HIERARCHY_KEY
FROM (SELECT SL_UNADJ.*,
DECODE (
TRIM (TIMA.DAY_DESC),
'saturday', SL_UNADJ.REVISED_DUE_DATE
- 1
- early_ship_days,
'sunday', SL_UNADJ.REVISED_DUE_DATE
- 2
- early_ship_days,
SL_UNADJ.REVISED_DUE_DATE - early_ship_days)
EARLIEST_SHIP_DATE,
DECODE (
TRIM (TIMB.DAY_DESC),
'saturday', SL_UNADJ.REVISED_DUE_DATE
+ 2
+ LATE_SHIP_DAYS,
'sunday', SL_UNADJ.REVISED_DUE_DATE
+ 1
+ LATE_SHIP_DAYS,
SL_UNADJ.REVISED_DUE_DATE + LATE_SHIP_DAYS)
LATEST_SHIP_DATE
FROM (SELECT NVL (s2.sys_ent_id, '00') SYS_ENT_ID,
cust.customer_no CUSTOMER_NO,
cust.bill_to_loc BILL_TO_LOCATION,
cust.early_ship_days,
CUST.LATE_SHIP_DAYS,
ord.PART_NO,
ord.SRCE_SYS_ID,
ord.BUS_AREA_ID,
ord.BUS_AREA_ID CONTRACT,
NVL (WAREHOUSE, ord.entity_code) WAREHOUSE,
ORDER_NO,
ORDER_LINE_NO LINE_NO,
ORDER_REL_NO REL_NO,
TRUNC (REVISED_DUE_DATE) REVISED_DUE_DATE,
REVISED_ORDER_QTY REVISED_QTY_DUE,
-- NULL QTY_RESERVED,
-- NULL QTY_PICKED,
SHIPPED_QTY QTY_SHIPPED,
sold_to_abbreviation ABBREVIATION,
-- NULL ACCT_WEEK,
-- NULL ACCT_MONTH,
-- NULL ACCT_YEAR,
-- NULL UPDATED_FLAG,
ord.CREATE_DATE CREATE_DATE,
ord.CREATE_DATE RECORD_DATE,
NVL (WAREHOUSE, ord.entity_code)
BASE_WAREHOUSE,
LAST_SHIPMENT_DATE,
TRUNC (REVISED_DUE_DATE)
- cust.early_ship_days
EARLIEST_SHIP_DATE_UnAdj,
TRUNC (REVISED_DUE_DATE)
+ CUST.LATE_SHIP_DAYS
LATEST_SHIP_DATE_UnAdj,
--0 ALLOC_PCT,
--0 WHSE_PCT,
ABC_CLASS,
NVL (LOCATION_ID, '000') LOCATION_ID,
--NULL RELEASE_COMP,
WAREHOUSE_DESC,
NVL (
DECODE (MAKE_TO_FLAG,
'S', 0,
'O', 1,
'', -1),
-1)
MAKE_TO_FLAG,
ord.CREATE_DATE source_create_date,
ord.UPDATE_DATE source_update_date,
ord.CREATED_BY source_created_by,
ord.UPDATED_BY source_updated_by,
ord.ENTITY_CODE,
ord.RECORD_ID,
src.SYS_ENT_ID SRC_SYS_ENT_ID,
ord.BSS_HIERARCHY_KEY
FROM EDW_DTL_ORDER_FACT ord,
edw_v_maxv_cust_dim cust,
edw_v_maxv_part_dim part,
EDW_WAREHOUSE_LKP war,
EDW_SOURCE_LKP src,
MEDW_PLANT_LKP s2,
edw_v_incr_refresh_ctl incr
WHERE ord.BSS_HIERARCHY_KEY =
cust.BSS_HIERARCHY_KEY(+)
AND ord.record_id = part.record_id(+)
AND ord.part_no = part.part_no(+)
AND NVL (ord.WAREHOUSE, ord.entity_code) =
war.WAREHOUSE_code(+)
AND ord.entity_code = war.entity_code(+)
AND ord.record_id = src.record_id
AND src.calculate_back_order_flag = 'Y'
AND NVL (cancel_order_flag, 'N') != 'Y'
AND UPPER (part.source_plant) =
UPPER (s2.location_code1(+))
AND mapping_name = 'MEDW_MAP_GIEA_MTOS_STG'
-- AND NVL (ord.UPDATE_DATE, SYSDATE) >=
-- MAX_SOURCE_UPDATE_DATE
AND UPPER (
NVL (ord.order_status, 'BOOKED')) NOT IN
('ENTERED', 'CANCELLED')
AND TRUNC (REVISED_DUE_DATE) <= SYSDATE) SL_UNADJ,
EDW_TIME_DIM TIMA,
EDW_TIME_DIM TIMB
WHERE TRUNC (SL_UNADJ.EARLIEST_SHIP_DATE_UnAdj) =
TIMA.ACCOUNT_DATE
AND TRUNC (SL_UNADJ.LATEST_SHIP_DATE_Unadj) =
TIMB.ACCOUNT_DATE) SL_INT
WHERE TRUNC (LATEST_SHIP_DATE) <= TRUNC (SYSDATE)
GROUP BY SL_INT.SYS_ENT_ID,
SL_INT.CUSTOMER_NO,
SL_INT.BILL_TO_LOCATION,
SL_INT.PART_NO,
SL_INT.SRCE_SYS_ID,
SL_INT.BUS_AREA_ID,
SL_INT.CONTRACT,
SL_INT.WAREHOUSE,
SL_INT.ORDER_NO,
SL_INT.LINE_NO,
SL_INT.REVISED_DUE_DATE,
SL_INT.ABBREVIATION,
SL_INT.BASE_WAREHOUSE,
SL_INT.ABC_CLASS,
SL_INT.LOCATION_ID,
SL_INT.WAREHOUSE_DESC,
SL_INT.MAKE_TO_FLAG,
SL_INT.source_created_by,
SL_INT.source_updated_by,
SL_INT.ENTITY_CODE,
SL_INT.RECORD_ID,
SL_INT.SRC_SYS_ENT_ID,
SL_INT.BSS_HIERARCHY_KEY) SL
WHERE (SL.BSS_HIERARCHY_KEY,
SL.ORDER_NO,
Sl.line_no,
sl.Revised_due_date,
SL.PART_NO,
sl.sys_ent_id) NOT IN
(SELECT BSS_HIERARCHY_KEY,
ORDER_NO,
line_no,
revised_due_date,
part_no,
src_sys_ent_id
FROM MEDW_MTOS_DTL_FACT
WHERE service_lvl_flag = 'Y');
thanks
asnAlso 'NOT IN' + nullable columns can be an expensive combination - and may not give the expected results. For example, compare these:
with test1 as ( select 1 as key1 from dual )
, test2 as ( select null as key2 from dual )
select * from test1
where key1 not in
( select key2 from test2 );
no rows selected
with test1 as ( select 1 as key1 from dual )
, test2 as ( select null as key2 from dual )
select * from test1
where key1 not in
( select key2 from test2
where key2 is not null );
KEY1
1
1 row selected.Even if the columns do contain values, if they are nullable Oracle has to perform a resource-intensive filter operation in case they are null. An EXISTS construction is not concerned with null values and can therefore use a more efficient execution plan, leading people to think it is inherently faster in general. -
Extracting 24 hour timestramp from sysdate
Hi All,
I have some 24 hour times stored as strings in a table eg 16:00, 18:30 , 04:00 ect
I'm trying to extract the 24 timestamp from SYSDATE so that I can do a comparision such as:
IF (just need timestamp from sysdate in 24 hour format here) > TO_DATE(r.wave_finish_time,'HH24:MI') THEN...
ANy ideas on how to extract the timestamp from sysdate in 24 hour format?
Cheers in advance!
Regards
SatThis will give you an idea (apart from the suggestions already offered).
If not, let us know.
SQL> with some_time_strings as (
2 select '01:00' my_time from dual union all
3 select '02:00' from dual union all
4 select '03:00' from dual union all
5 select '04:00' from dual union all
6 select '05:00' from dual union all
7 select '06:00' from dual union all
8 select '07:00' from dual union all
9 select '08:00' from dual union all
10 select '09:00' from dual union all
11 select '10:00' from dual union all
12 select '11:00' from dual union all
13 select '12:00' from dual union all
14 select '13:00' from dual union all
15 select '14:00' from dual union all
16 select '15:00' from dual
17 )
18 select *
19 from some_time_strings
20 where my_time > to_char(to_date('01-01-2009 04:50', 'dd-mm-yyyy hh24:mi'), 'hh24:mi');
05:00
06:00
07:00
08:00
09:00
10:00
11:00
12:00
13:00
14:00
15:00
11 rijen zijn geselecteerd.Explanation in short:
to_char(to_date('01-01-2009 04:50', 'dd-mm-yyyy hh24:mi'), 'hh24:mi');
means
=> to_date('01-01-2009 04:50', 'dd-mm-yyyy hh24:mi') = the date part, could also be sysdate or any DATE
=> to_char( the date part, 'hh24:mi'); = the VARCHAR2 FORMAT part, you really need to use that, since your 'time' is in fact a string.
Edited by: hoek on Apr 17, 2009 6:51 PM added some extra words, because of the weather
Maybe you are looking for
-
Installation program start and end date
My requirement is to capture both start and finish dates for an installation program. Will likely require 2 new fields at order line item level. I was thinking about using USEREXIT_MOVE_FIELD_TO_VBAP. But where do I find the install information to mo
-
Air travel with iMac (21")
I will be traveling by air with my iMac and have already checked with the airline that it will fit into the overhead and that it is ok to bring onboard. However, I wonder whether I can just use the box the iMac came in (which I understand how iMacs a
-
Computer will not install itunes 10.5
I have downloaded the new iTunes 10.5 to my computer, but it will not install. I have never had any problems with any of the other iTunes downloads. If I can't get this to install I won't be able to use the backed up info I have to add to my phone si
-
How to enter values for newly inserted field for maintenace view table
Hi , I have inserted new field for custom table which consits of maintance view.. I want to put some values in to this newly inserted field.. When i try to insert values bu useing se16,iam unable to view this newely inserted field.. Can you please le
-
How to avoid specified is out of bounds error in flex 4 mxml web application
how to avoid specified is out of bounds error in flex 4 mxml web application hi raghs, i want to add records in cloud.bt while adding the records if we enter existing record details and try to save again na it wont allow to that record. that time