Using Oracle date function
Hi allI need to write a function under scenario
I need to pass two parameters from_date and to_date
I want to get all the dates between from_date and to_date except Saturday and also include from_date and to_date.
Please help me.
Thank you
Published by: carmac on 29 January 2013 17:04
Hello
Carmac says:
I want to get all the dates between from_date and to_date except Saturday and also include from_date and to_date
You can change the Manik solution like this:
WITH t AS
(SELECT TO_DATE (:dt1, 'YYYYMMDD') startdt,
TO_DATE (:dt2, 'YYYYMMDD') enddt
FROM DUAL)
SELECT *
FROM ( SELECT DECODE ( TO_CHAR (startdt + ROWNUM - 1 -- *** CHANGED ***
, 'DY'),
'SAT', NULL,
startdt + ROWNUM - 1 -- *** CHANGED ***
)
dt
FROM t
CONNECT BY ROWNUM <= (enddt + 1 -- *** CHANGED ***
- startdt))
WHERE dt IS NOT NULL;
Tags: Database
Similar Questions
-
Using Oracle analytic function
Hi all
I use Oracle 10 g Release 10.0.2
Here's the situation:
I visited in my table of looks like this:
Cust_id beg_dt end_dt sg_cd
264321502 1 MAY 97 19 MARCH 98 1
264321502 21 MAY 98 15 OCTOBER 98 6
264321502 20 OCTOBER 98 22 APRIL 99 6
264321502 23 APRIL 99 25 APRIL 00 6
264321502 27 APRIL 00 20 JANUARY 02 6
264321502 25 JANUARY 02 15 MAY 02 6
264321502 MAY 21 02 27 MAY 02 6
264321502 31 MAY 02 17 FEBRUARY 03 6
264321502 21 FEBRUARY 06 03-7.-04 1
264321502 25 FEBRUARY 03 25 FEBRUARY 03 1
264321502 31 MARCH 03 30 APRIL 03 1
264321502 07 - SEP - 04 26 DECEMBER 04 6
264321502 29 DECEMBER 04 3 JANUARY 06 6
264321502 4 JANUARY 06 3 JANUARY 07 12
264321502 4 JANUARY 06 3 JANUARY 07 12
264321502 4 JANUARY 06 3 JANUARY 07 12
I need the results of the query as
Cust_id beg_dt end_dt sg_cd
264321502 1 MAY 97 19 MARCH 98 1
264321502 21 MAY 98 17 FEBRUARY 03 6
264321502 21 FEBRUARY 03 30 APRIL 03 1
264321502 07 - SEP - 04 3 JANUARY 06 6
264321502 4 JANUARY 06 3 JANUARY 07 12
Basically, I need take a min max (end_dt) of sg_cd for this cust id (beg_dt).
Any help is very much appreciated:
My query is like that
Select cust_id, end_dt, beg_dt, sg_cd,
min (beg_dt) more (partition of cust_id, sg_Cd) as new_beg_dt,
Max (end_dt) more (partition of cust_id, sg_cd) as end_Dt_nw
of cust_tab.
can be like that?
1 data
() 2
3 select Cust_id 264321502, to_date('01-MAY-97','dd-mon-rr') beg_dt, to_date('19-MAR-98','dd-mon-rr') end_dt, 1 sg_cd of all the double union
4. Select 264321502, to_date('21-MAY-98','dd-mon-rr'), to_date('15-OCT-98','dd-mon-rr'), 6 Union double all the
5 select 264321502, to_date('20-OCT-98','dd-mon-rr'), to_date('22-APR-99','dd-mon-rr'), 6 Union double all the
6. Select 264321502, to_date('23-APR-99','dd-mon-rr'), to_date('25-APR-00','dd-mon-rr'), 6 Union double all the
7. Select 264321502, to_date('27-APR-00','dd-mon-rr'), to_date('20-JAN-02','dd-mon-rr'), 6 Union double all the
8 select 264321502, to_date('25-JAN-02','dd-mon-rr'), to_date('15-MAY-02','dd-mon-rr'), 6 Union double all the
9. Select 264321502, to_date('21-MAY-02','dd-mon-rr'), to_date('27-MAY-02','dd-mon-rr'), 6 Union double all the
10. Select 264321502, to_date('31-MAY-02','dd-mon-rr'), to_date('17-FEB-03','dd-mon-rr'), 6 Union double all the
11. Select 264321502, to_date('21-FEB-03','dd-mon-rr'), to_date('06-SEP-04','dd-mon-rr'), 1 Union double all the
12 select 264321502, to_date('25-FEB-03','dd-mon-rr'), to_date('25-FEB-03','dd-mon-rr'), 1 Union double all the
13 select 264321502, to_date('31-MAR-03','dd-mon-rr'), to_date('30-APR-03','dd-mon-rr'), 1 Union double all the
14 select 264321502, to_date('07-SEP-04','dd-mon-rr'), to_date('26-DEC-04','dd-mon-rr'), 6 Union double all the
15 select 264321502, to_date('29-DEC-04','dd-mon-rr'), to_date('03-JAN-06','dd-mon-rr'), 6 Union double all the
16 select 264321502, to_date('04-JAN-06','dd-mon-rr'), to_date('03-JAN-07','dd-mon-rr'), 12 Union double all the
17 select 264321502, to_date('04-JAN-06','dd-mon-rr'), to_date('03-JAN-07','dd-mon-rr'), 12 Union double all the
18 select 264321502, to_date('04-JAN-06','dd-mon-rr'), to_date('03-JAN-07','dd-mon-rr'), 12 of the double
(19) - select * from data
20. Select Cust_id, beg_dt, max (end_dt) as end_dt, min (beg_dt), sg_cd
21 of
(22)
23 select x.*, sum (flg) over (order by end_dt Cust_id partition) as grp
24 of
(25)
26 select
27 wagneur, case when lag (sg_cd, 1-9) over (order by end_dt Cust_id partition)! sg_cd = 1 END so that flg
28 from data d
x 29)
x 30)
Group 31 by Cust_id, sg_cd, grp
32 * order of Cust_id, end_dt
CUST_ID BEG_DT END_DT SG_CD
---------- --------- --------- ----------
264321502 1 MAY 97 19 MARCH 98 1
264321502 21 MAY 98 17 FEBRUARY 03 6
264321502 21 FEBRUARY 06 03-7.-04 1
264321502 07 - SEP - 04 3 JANUARY 06 6
264321502 4 JANUARY 06 3 JANUARY 07 12
-
Time series by using Oracle Data Mining? Is there any equivalent of ARIMA in the MDGS?
Hello
I followed the extraction of data from Oracle Press book. I applied regression models to predict continuous variables.
My use case is to predict the market price of stocks based on historical data.
I see there R packages to do. Some popular methods that are widely used are ARIMA (Autoregressive integrated mobile average).
Is there such an offer out-of-the-box in the MDGS?
Pointers / whitepapers, or do we use component regression?
Thank you
Chrystelle
Hey Lulu,
MDG does not have an implementation of time series which is precisely part of the SQL in the algorithms of db.
But AAO (Oracle Advanced Analtyics, ODM is a part of) has an implementation of time-series Oracle which may be useful for you:
See ore.esm model, documented with examples here: https://docs.oracle.com/cd/E57012_01/doc.141/e56973/procs.htm#BEIEGCDG
We also have the preparation of data for time series capabilities, listed here: https://docs.oracle.com/cd/E57012_01/doc.141/e56973/procs.htm#BEIJHHCG
May also be interested to Marcos Campos blog on time series using the current characteristics of ODM/DB: Oracle Data Mining and Analytics: time series Revisited
Hope it will be useful.
THX, mark
-
import schema data using oracle data pump
Hi all
I want to import a schema on a single server using IMPDP. But on this server, the user does not exists.is it is possible to import all the objects that break including the creation of the schema. In exp/imp, it may be possible. But in data pump I can't do the same. Its giving error that the user does not exist. For your reference, I'll give you the code below the import.
Impdp system directory = DIR_DUMP logfile = expdp_tsadmin_tcgadmin_11182013_2_2.log
dumpfile = expdp_tsadmin_tcgadmin_11182013_2.dmp PATTERNS = TS_ADMIN version = 10.1.0.2.0
Pls help and thanks in advance.
Thank you
Piku
Hello
All errors are due to the fact that the tablespace that ts_data does not exist, everything else is hit because of this.
create tablespace ts_data datafile 'xxxxxx' size xM;
then try again
See you soon,.
Harry
-
using the R function on the Oracle database
for the use of R, I can only use Oracle data mining algorithms, or I can use the R function as social network in the Oracle database?Could you please be more specific about the R functions/packages you are interested in. The ODM and ore are part of the unique option of OAA.
-
How to use the add_months() function in a mapping?
Hello
I have a variable in ODI with a date and I need to add another variable to add 'x' months...
How can do that?
Thank you
If you say you have variable1 organise a date for example 01/01/2015 and variable 2 holding a certain number of months for example 7?
If so in your mapping expression simply use the date functions available to your database technology (step/target) and replace the variable in the function
that is for Oracle your mapping would be ADD_MONTHS (#Variable1,Variable2of #)
-
can I use create valude function for MSSql scalar and table.
Hello
(1) can I use create scalar function for MSSql and function table?
(2) is there how many type of function defined by the user in oracle 11 g express?
(3) and I can reture 'type' any form user defined function?
Attract sincerely944768 wrote:
the answer lies in a few cases only,
The response illustrates the basic concept of how customers need to use cursors created using PL/SQL as a layer of abstraction - SQL and this concepts adapts to ALL cases where the customer wants to Oracle via PL/SQL cursor.
a case is,
If my function returns only a single value, then I can use oracle 'create function' with the return type as types predefined as a whole, varchar2 etc?
with regard to performance.With regard to this performance problem? And why now suddenly change the question to want to use a function to return data type number or string? How does this relate to PL/SQL to return a cursor now?
A function can return scalar values, not scalar. A function may return atomic values (such as a unique number, or a non-scalar list of numbers). A function can return a complex data structure consisting of scalar values, not scalar.
However, in PL/SQL function must NOT be used to read the lines of the database to cache lines in a memory of the server PL/SQL (PGA), then back to the client.
He does not. It does not fit. It is too bloody dangerous to the overall health of the server as such code plays silly blighters with very expensive server memory.
A PL/SQL function can also be used as guideline, returning data via expensive PGA, but via the SQL engine instead and using its slider interface (which allows output data to be "gradual" and not to return all data with a single copy of croustilleur mass of the call stack) directly. IT IS, HOWEVER, AN EXCEPTION. There is very rarely the need to make the functions PL/SQL pipeline table - and is often victims of abuse and bad demonstrated with examples of absurd code here.
-
How to get the column provided out of the Oracle Data Miner?
Hi all!
I use Oracle Data Miner provided with Oracle SQL Developer to predict the loss of customers. If I plan on the table column lets say X (as a target column) of table say T, so how can I get the corresponding values under my model?
Here is the simplified model for the reference.
Thanks in advance!
Hello
Simply connect a node that accepts data to the node to apply it.
For example, if you want to create a view or table table using the prediction of outputs generated by the node to apply it, and then add a Create Table node and connect the node to apply it.
For more information, try the Oracle by example tutorials for ODMr.
You must use the node apply Publisher to revise prediction outputs models to generate as well as the additional columns to include, for example columns id.
There are a set of predictor columns added by default that may be acceptable.
THX, mark
-
ODI LKM Oracle for Oracle Data Pump question
Hi all
I have a weird problem, ODI.
I associate myself with per_all_people_f, fnd_user to load the w_user_ds using Oracle Data Integrator. The used LKM is LKM Oracle for Oracle Data Pump.
Fine when I run the interface. I am getting below error
ODI-1227: task failed USER_DATA_SET (load) on the source of connection ORACLE EBS.
Caused by: java.sql.SQLSyntaxErrorException: ORA-00923: KEYWORD not found where expected
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:462)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:931)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:481)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:548)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:217)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1115)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1488)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3769)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3954)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1539)
at oracle.odi.runtime.agent.execution.sql.SQLCommand.execute(SQLCommand.java:163)
at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:102)
at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:1)
at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:577)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:468)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2128)
to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ 2.doAction(StartSessRequestProcessor.java:366)
at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$ 0 (StartSessRequestProcessor.java:292)
to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ StartSessTask.doExecute (StartSessRequestProcessor.java:855)
at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
to oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$ 2.run(DefaultAgentTaskExecutor.java:82)
at java.lang.Thread.run(Thread.java:662)
The generated code is
create the table 780021 X
(
C1_FIRST_NAME,
C2_MID_NAME,
C3_LAST_NAME,
C4_FULL_NAME,
C5_NAME_SUFFIX,
C6_SEX_MF_CODE,
C7_SEX_MF_NAME,
C8_COUNTRY_NAME,
C9_LOGIN,
C10_CREATED_BY_ID,
C11_CHANGED_BY_ID,
C12_CREATED_ON_DT,
C13_CHANGED_ON_DT,
C14_AUX1_CHANGED_ON_DT,
C15_SRC_EFF_TO_DT,
C16_INTEGRATION_ID,
C17_EFFECTIVE_START_DATE
)
(EXTERNAL) ORGANIZATION
TYPE oracle_datapump
Dat_dir default DIRECTORY
LOCATION ("X780021.exp")
)
PARALLEL
in SELECT
ALL_PEOPLE_F.FIRST_NAME,
ALL_PEOPLE_F.MIDDLE_NAMES,
ALL_PEOPLE_F.LAST_NAME,
ALL_PEOPLE_F.FULL_NAME,
ALL_PEOPLE_F.SUFFIX,
ALL_PEOPLE_F.SEX,
ALL_PEOPLE_F.SEX,
ALL_PEOPLE_F.NATIONALITY,
USER. USER_NAME,
ALL_PEOPLE_F.CREATED_BY,
ALL_PEOPLE_F.LAST_UPDATED_BY,
ALL_PEOPLE_F.CREATION_DATE,
ALL_PEOPLE_F.LAST_UPDATE_DATE,
ALL_PEOPLE_F.CREATION_DATE,
ALL_PEOPLE_F.EFFECTIVE_END_DATE,
USER. USER_ID,
ALL_PEOPLE_F.EFFECTIVE_START_DATE
from APPS. FND_USER USER, APPS. PER_ALL_PEOPLE_F ALL_PEOPLE_F
where (1 = 1)
And (ALL_PEOPLE_F.PERSON_ID = USER. EMPLOYEE_ID)
I don't see what is the problem here.
Someone can help me.
Thank you and best regards,
Krishna Prasad
I found the problem, its with the way ODI generated alias for the FND_USER table, by default it produces USER as an alias, which is a keyword from oracle. We just need to rename it to something else, and it worked.
-
Using the data logged in an interface with the aggragate function
Hello
I'm trying to use logged data from a source table in one of my interfaces in ODI. The problem is that one of the mappings on the columns target implies a function (sum) overall. When I run the interface, I get an error saying not "a group by expression. I checked the code and found that the columns jrn_subscriber, jrn_flag, and jrn_date are included in the select statement, but not in the group by statement (the statement group contains only remiaining two columns of the target table).
Is there a way to get around this? I have to manually change the km? If so how would I go to do it?
Also I'm using Oracle GoldenGate JKM (OGG oracle for oracle).
Thanks and really appreciate the help
Ajay"ORA-00979"when the CDC feature (logging) using ODI with Modules of knowledge including the aggregate SQL function works [ID 424344.1]
Updated 11 March 2009 Type status MODERATE PROBLEMIn this Document
Symptoms
Cause
Solution
Alternatives:This document is available to you through process of rapid visibility (RaV) of the Oracle's Support and therefore was not subject to an independent technical review.
Applies to:
Oracle Data Integrator - Version: 3.2.03.01
This problem can occur on any platform.
Symptoms
After successfully testing UI integration ODI using a function of aggregation such as MIN, MAX, SUM, it is necessary to implement change using tables of Journalized Data Capture operations.However, during the execution of the integration Interface to retrieve only records from Journalized, has problems to step load module loading knowledge data and the following message appears in the log of ODI:
ORA-00979: not a GROUP BY expression
Cause
Using the two CDC - logging and functions of aggregation gives rise to complex problems.
SolutionTechnically, there is a work around for this problem (see below).
WARNING: Problem of engineers Oracle a severe cautioned that such a type of establishment may give results that are not what could be expected. This is related to how ODI logging is applied in the form of specific logging tables. In this case, the aggregate function works only on the subset that is stored (referenced) in the table of logging and on completeness of the Source table.We recommend that you avoid this type of integration set ups Interface.
Alternatives:1. the problem is due to the JRN_ * missing columns in the clause of "group by" SQL generated.
The work around is to duplicate the knowledge (LKM) loading Module and the clone, change step "Load Data" by editing the tab 'Source on command' and substituting the following statement:
<%=odiRef.getGrpBy()%>with
<%=odiRef.getGrpBy()%>
<%if ((odiRef.getGrpBy().length() > 0) && (odiRef.getPop("HAS_JRN").equals("1"))) {%>
JRN_FLAG, JRN_SUBSCRIBER, JRN_DATE
<%}%>2. it is possible to develop two alternative solutions:
(a) develop two separate and distinct integration Interfaces:
* The first integration Interface loads the data into a temporary Table and specify aggregate functions to use in this initial integration Interface.
* The second integration Interfaces uses the temporary Table as Source. Note that if you create the Table in the Interface, it is necessary to drag and drop Interface for integration into the Source Panel.(b) define the two connections to the database so that separate and distinct references to the Interface of two integration server Data Sources (one for the newspaper, one of the other Tables). In this case, the aggregate function will be executed on the schema of the Source.
Display related information regarding
Products* Middleware > Business Intelligence > Oracle Data Integrator (ODI) > Oracle Data Integrator
Keywords
ODI; AGGREGATE; ORACLE DATA INTEGRATOR; KNOWLEDGE MODULES; CDC; SUNOPSIS
Errors
ORA-979Please find above the content of the RTO.
It should show you this if you search this ID in the Search Knowledge BaseSee you soon
Sachin -
How to use a date such as 'Today' in a function without listening for the moment on that date?
I create a todo list. I know I shouldn't but I'm so stuck on this point that I really want to know the answer. At the bottom of my table, I have a footer line in which I want to show the total number of tasks to be accomplished today and every time that I have "TIC TAC" a box in one of the columns used for checking out my todos, I would like to see it reduced by 1. But apparently from what I found through experimentation is that the keyword 'Today' or a grammatical Word uses the date AND time and only if the time is 00:00:00 AM. So, how can I avoid the time to be included when you filter? I would use today, because then every day he restarts you automatically. Thank you for your time and effort in advance.
Version numbers: 3.5.3.
OS X: El Capitan 10.11
Hi BassPlaya,
What formula do you use in table leg?
The NOW function would do what you want?
Kind regards
Ian.
-
Using the comparison function where 2 data tables various types
Is it possible to use the comparison function in Labview you to compare 2 arrays of types of different data (e.g. Boolean and double-precision)?
Would this work? Nested for loops of index on the TRUE values of the Boolean table.
-
Using Oracle Partition Exchange with Oracle Data Integrator (ODI) 11g
Hello
I'm trying to follow http://www.ateam-oracle.com/configuring-oracle-data-integrator-odi-with-oracle-partition-exchange/
But impossible to get the same options in 11g.
Can I use the Exchange Partition Oracle 11g ODI.
Thank you.
Yes, exchange of partition is certainly possible in ODI 11 g
-
What is the use of "JKM consistent Oracle (Date of update)" in ODI 11 G
Hello
You can filter the Journalized data in the knowledge 'JKM Oracle' compatible module in which the condition on updated_date or Last_date column it self.
So, what is the use of the module knowledge "JKM consistent Oracle (Date of update)" in ODI 11 G.
Please let me know if the necessary clarifications.
Thank you for your cooperation in advance.
Kind regards
NananYou can close the thread (mark it as "answered" and mark useful messages)
-
Download a data sheet excel using Oracle APEX 3.2
Hi all
Please help me out to download the data in the worksheet excel using oracle APEX 3.2.
Follow the steps mentioned in the link below, but even after I get a error saying no data found
http://avdeo.com/2008/05/21/uploading-Excel-sheet-using-Oracle-Application-Express-apex/
Please help me to go further.
Kind regards
SantiniHello
Try the Jarola.
Maybe you are looking for
-
ICloud on one phone deleting erase others the same account delete on others
My mother asks if delete iCloud on a delete on others? I want to know.
-
Why firefox 3.6.13 when I click on a link put little dots all around him?
When I installed the new version of firefox, it started putting small dots around links when I click on them. It bothers me because on my webpage, it's ugly.Thanks for your replies.Dario
-
Basic question MATLAB/LabVIEW
I'm very new to LabVIEW and MATLAB and have had problems making my LabVIEW code compatible with MATLAB scripts I wrote. In my LabVIEW program, I have simulated two channels one NOR 9237 USB - DAQ and recorded outgoing data in an ASCII .txt file (usin
-
Cannot start Windows &; startup repair does not work!
I have Windows 7 Home Premium installed on the HP DM4t laptop. My laptop can not restart. I tried using the reapir drive system but it shows some loading filed and I got a black screen with the pointer (arrow). It remains like this for hours and hour
-
Dv6500 laptop - no Standard disc HARD SATA/power connectors
Hi - I decided to upgrade my 80 GB Western Digital Scorpio 2.5 inches with a Seagate Momentus 2.5 inch 250 GB. The Seagate as I thought, were the standard SATA power connectors. The connectors slide on, the same thing as what I saw on all SATA 3.5 De