To get the dates between a month
Hi,
i'm working in forms 6i and database 10g.
i have a table named attendance which contains only the dates on which the employees are present.
i need the dates on which the employees are absent when i give the date range.
So how will I get the other days in a month if I give the start and end date of a month.
I think u understood what I mean.
Pls help..
Rereading your post my guess is you're after something like below
NOT TESTED ! I don't have database access
select employee,the_date absent
from (select x.employee,x.the_date,a.present_on
from (select a.employee,md.the_date
from (select to_date(:yyyymm,'yyyymm') + level - 1 the_day
from dual
connect by level <= to_number(to_char(last_day(to_date(:yyyymm,'yyyymm')),'dd'))
) md, /* generating dates for a year_month given */
(select distinct employee
from attendance
) a /* retrieving all employees */
) x, /* cartesian join between employees and days in a month */
attendance a
where x.employee = a.employee(+)
and x.the_date = a.present_on(+)
where present_on is nullRegards
Etbin
Similar Messages
-
How to get the data between two dates?
Hi all,
I am facing a problem of getting the data betwwen two dates.
I have written a query as
"select * from table1 a where a.dt between trunc(sysdate) and trunc(sysdate)-30"
It is not showing any errors or warnings.But the data is not coming though the data is in the table1 between these two dates.
Regards,
KumarYour ordering is probably wrong:
SELECT *
FROM table1 a
WHERE a.dt BETWEEN TRUNC (SYSDATE) - 30 AND TRUNC (SYSDATE) -
Getting the data for last month of every year
Hi,
How to declare the date if we want to pull the data from the December of every year.
For example if the query is run in march 2015 and they want the historical data it should pull only the data from dec 2014.
In the same way if they ran the query in future jun 2016 and if they want to historical data it should pull only data from dec 2015.
It should not coded manually. Please help me with date format that need to used.
BALUSUSRIHARSHAPlease follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for:
https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
A table has to have a key to be table. Here is my guess at a repair job:
CREATE TABLE Test_Data
(pu_id INTEGER NOT NULL
REFERENCES PU(pu_id),
pu_date DATE DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (pu_id, pu_date),
x_count INTEGER,
y_count INTEGER);
Identifiers are not numeric in a good schema. What math do you do with them? They are also the key in the table that models the entity they identify. Where is the PU table (and what is a PU anyway)?
INSERT INTO Test_Data
VALUES
(28, '2014-01-01', 10, 20), -- crap! No key in this mess!!
(28, '2015-01-01', 30, 20), --
(28, '2014-12-12', 10, 20),
(28, '2015-02-02', 10, 20);
A PIVOT is not a query and not even part of SQL. It is how Microsoft programmers who do not know RDBMS or have a report writer violate the tiered architecture of SQL. We also do not use XML mixed in SQL. It is a bitch to maintain, has poor performance and again
violates the tiered architecture principle.
A query is not sorted because it is a table. A file in COBOL can be sorted and that seems to be what you really want to write.
Old COBOL love the Sybase CONVERT() string function to avoid SQL temporal data.
We never use SELECT * in production code; Google it. Not only are you generating code, you are generation bad code.
Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements in the DML.
The report period table gives a name to a range of dates that is common to the entire enterprise.
CREATE TABLE Month_Periods
(month_name CHAR(10) NOT NULL PRIMARY KEY
CHECK (month_name LIKE <pattern>),
month_start_date DATE NOT NULL,
month_end_date DATE NOT NULL,
CONSTRAINT date_ordering
CHECK (month_start_date <= month_end_date),
etc);
These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the ISO-8601
data format required by Standard SQL and it is language independent. The pattern for validation is '[12][0-9][0-9][0-9]-00-00' and '[12][0-9][0-9][0-9]-[01][0-9]-00'
This will port and waste time calling string function row by row.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
How to get the dates between Two dates excluding Saturaday and Sunday
Dear All,
select to_date('25-04-2012', 'DD-MM-YYYY') + rownum -1 dt
from dual
connect by level <= to_date('05-05-2012', 'DD-MM-YYYY') - to_date('25-04-2012', 'DD-MM-YYYY') + 1;The above query returning the following output,
DT
DT
04/25/2012
04/26/2012
04/27/2012
04/28/2012
04/29/2012
04/30/2012
05/01/2012
05/02/2012
05/03/2012
05/04/2012
05/05/2012here I need to exclude the Dates which comes on 'saturday' and 'sunday' and also the common holiday
Here it is '01-May-2012' and I need the output like the following,
04/25/2012
04/26/2012
04/27/2012
04/30/2012
05/02/2012
05/03/2012
05/04/2012I need the common query to calculate between any two dates.
Can anyone suggest me?
Thank you,
Regsrds,
gurujothiHi Frank,
Sorry for my fault,
The following is my table description,
CREATE TABLE "DATES"
( "FROMDATE" DATE,
"TODATE" DATE,
"LEAVE_ID" Number(5)
Insert into dates values('05-02-2012','05-05-2012',1);
Create table holiday_dates(holidays date);
insert into holiday_dates values('01-05-2012');Now when I used this query,
select count(*) from (select dt
from(
select to_date(fromdate, 'DD-MM-YYYY') + rownum -1 dt
from dates
connect by level <= to_date(todate, 'DD-MM-YYYY') - to_date(fromdate, 'DD-MM-YYYY') + 1
where to_char(dt,'fmday') not in ('sunday','saturday') minus (select holidays from holiday_dates)) dual;
Count(*)
64
Insert into dates values('01/05/2012','05/05/2012',2);
/Now my table has 2 rows,
select * from dates;
FROMDATE TODATE LEAVE_ID
01/05/2012 05/05/2012 1
05/02/2012 05/05/2012 2Now when I used this query,
select count(*) from (select dt
from(
select to_date(fromdate, 'DD-MM-YYYY') + rownum -1 dt
from dates
connect by level <= to_date(todate, 'DD-MM-YYYY') - to_date(fromdate, 'DD-MM-YYYY') + 1
where to_char(dt,'fmday') not in ('sunday','saturday') minus (select holidays from holiday_dates)) dual;The output is ,
COUNT(*)
1987How to get the output using the max(leave_id) like the following,
select..........from... where leave_id=(select max(leave_id) from dates);where to add "WHERE" clause in the above query?
Thank you,
Regards,
Gurujothi.
Edited by: Gurujothi on May 3, 2012 8:43 PM
Edited by: Gurujothi on May 3, 2012 8:44 PM -
Getting the data between Sunday and Saturday of last week.(DAYS NOT DATES)
I have a stored procedure (that has no parameters right now) and does some extraction of data from different tables. One of the table has a column called 'DeliveryDate'.
Based on the requirements, I have to create an SSRS 2008 R2 Report out of that stored procedure, so that users can see the data of last week from Sunday(Start DAY) to Saturday(End DAY). Even if it is Wednesday today, they should be able to see the data
from Last Sunday to this Saturday. I don't want to get data of Monday, tuesday or wednesday. Also, these values shouldn't be STATIC. Meaning, if one user wanted to see deliveries on 04-15-2011, then he shoud see the values of the previous week (and NOT
CURRENT week)
1. Do I need to create parameters in my stored proc. Are they needed at all ?
2. Should I use DateAdd, Datediff functions (If someone can explain, how will they be calculated!)to get last week sunday and saturday use below. I prefer to use parameters.
set @startdate = DATEADD(wk,
DATEDIFF(wk,
0,
getdate()),
-2) --for
sunday
set @enddate = DATEADD(wk,
-1,
DATEADD(wk,
DATEDIFF(wk,
0,getdate()),
-1))-- for saturday
also
refer the following link
http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/
ESHANI. Please click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you
If I run the query on 5/4/2014, will it give me 4/27/2014 for Sunday and 5/3/2014 for Saturday? Meaning if I run it on a Sunday, it will give me the previous Sunday and not the current Sunday's date. -
Getting the data based on dates
Hi All,
In my application i am not able to retrieve the data from database between two dates.
while entering the dates i am entring using :
+ "',to_date('+ fromdate+ "','DD-Mon-YYYY HH24:MI:SS'),"
as in database i have kept my fromdate type as "varchar2"
So while selecting data i have written the query as :
String sqlQuery =
"select SID,SERVER_NAME,DOWNTIMETYPE,FROMDATE,TODATE,FROMTIME,TOTIME,TIMETAKEN,DOWN_REASON from SS_UPDOWNTIME where (FROMDATE >='"
+ frmdate
+ "' OR (FROMDATE between '"
+ frmdate
+ "' and '"
+ todate
+ "')) ";
but i am not able to get the data between the two selected dates
Regards,
AnupamaHi Anupama,
'between' wont work because you have taken dates as varchar2.
Just try like this.
Take "Date" type in database and in java take java.sql.Date
java.sql.Date sqlDefaultDate = new java.sql.Date(System.currentTimeMillis());
System.out.println("sqlDate: "+sqlDefaultDate);
// this will be in the format 2008-11-13 , So we can pass sqlDefaultDate variable to backend
Regards,
Lakshmi Prasad. -
Getting the difference between 2 dates
Hi,
I am creating a Date object (using today;s day, month and year. hours and minutes come from a config file) and getting the difference between this date and the current date and time.
My code is as follows:
I am passing 07:30 into the method as the parameter aSstart_time.
Calendar newCalendar = Calendar.getInstance(Locale.UK);
SimpleDateFormat dtformat = new SimpleDateFormat("dd-MM-yy HH:mm");
int lIYear = newCalendar.get(newCalendar.YEAR);
int lIMonth = newCalendar.get(newCalendar.MONTH);
int lIDay = newCalendar.get(newCalendar.DAY_OF_MONTH);
String lSstartHrs = aSstart_time.substring(0,aSstart_time.indexOf(":"));
//System.out.println(">>>>>>>>> THE HOURS IS: " + lSstartHrs);
String lSstartMins = aSstart_time.substring(aSstart_time.indexOf(":")+1,aSstart_time.length());
//System.out.println(">>>>>>>>> THE MINS IS: " + lSstartMins);
java.util.Date ldStartTime = new java.util.Date(lIYear,lIMonth,lIDay, Integer.parseInt(lSstartHrs),Integer.parseInt(lSstartMins));
System.out.println("Year: " + lIYear);
System.out.println("Month: " + lIMonth);
System.out.println("Day: " + lIDay);
System.out.println("Hour: " + Integer.parseInt(lSstartHrs));
System.out.println("Min: " + Integer.parseInt(lSstartMins));
System.out.println("The number of milliseconds for current time is: " + newCalendar.getTime().getTime());
System.out.println("The number of milliseconds for 07:30 is: " + ldStartTime.getTime());
System.out.println("calendar time: " + dtformat.format(newCalendar.getTime()).toString());
System.out.println("created time: " + dtformat.format(ldStartTime).toString());
if(newCalendar.getTime().getTime() < ldStartTime.getTime()){
System.out.println("The current time is less than the config time (07:30)");
else{
System.out.println("The time is greater than 07:30");
}When I run this program at 10:06am I get the following output:
Year: 2006
Month: 1
Day: 15
Hour: 7
Min: 30
The number of milliseconds for current time is: 1139997962321
The number of milliseconds for 07:30 is: 61098132600000
calendar time: 15-02-06 10:06
created time: 15-02-06 07:30
The current time is less than the config time (07:30)
The Date.gettime() method should measure the number of milliseconds after 01-01-1970 so the number of milliseconds for the current time (10:06am) should be greater than the number of milliseconds for 07:30. A you can see in the above output this is not the case.
Anybody have any idea why this is happening. Am I using the .gettime() method for the correct purpose.
Any ideas or suggestions would be greatly appreciated.
ThanksIt is beacause Calendar use fully defined year as parameter, so Calendar.set(year + 1900, month, date, hrs, min) is (almost) equivalent to new Date(year, month, date, hrs, min)Example: int year = 85; // old way of specifying a year in a Date
int month = 3;
int date = 12;
int hrs = 12;
int min = 0;
Calendar cal = Calendar.getInstance();
cal.set(year + 1900, month, date, hrs, min);
Date d = new Date(year, month, date, hrs, min);
System.out.println(d);
System.out.println(cal.getTime());You will obtain the same date (except seconds and miliseconds in this case, as they probably won't be zero with Calendar.getInstance(); ) -
How to get the date for the first monday of each month
Dear Members,
How to get the date for the first monday of each month.
I have written the following code
SELECT decode (to_char(trunc(sysdate+30 ,'MM'),'DAY'),'MONDAY ',trunc(sysdate+30 ,'MM'),NEXT_DAY(trunc(sysdate+30 ,'MM'), 'MON')) FROM DUAL
But it look bith complex.
Abhishek
Edited by: 9999999 on Mar 8, 2013 4:30 AMUse IW format - it will make solution NLS independent. And all you need is truncate 7<sup>th</sup> day of each month using IW:
select sysdate current_date,
trunc(trunc(sysdate,'mm') + 6,'iw') first_monday_the_month
from dual
CURRENT_D FIRST_MON
08-MAR-13 04-MAR-13
SQL> Below is list of first monday of the month for this year:
with t as(
select add_months(date '2013-1-1',level-1) dt
from dual
connect by level <= 12
select dt first_of_the_month,
trunc(dt + 6,'iw') first_monday_the_month
from t
FIRST_OF_ FIRST_MON
01-JAN-13 07-JAN-13
01-FEB-13 04-FEB-13
01-MAR-13 04-MAR-13
01-APR-13 01-APR-13
01-MAY-13 06-MAY-13
01-JUN-13 03-JUN-13
01-JUL-13 01-JUL-13
01-AUG-13 05-AUG-13
01-SEP-13 02-SEP-13
01-OCT-13 07-OCT-13
01-NOV-13 04-NOV-13
FIRST_OF_ FIRST_MON
01-DEC-13 02-DEC-13
12 rows selected.
SQL> SY. -
How can I get extract the data between two cursors on an XY graph
How can I get extract the data between two cursors on an XY graph
Well, you say xy graph, so this might be a more complicated problem.
For a waveform graph it's trivial. Simply get the two cursor indices (property: cursor index) and apply them to array subset of the data. Is that all you need?
Here's how the above code would look like. using cursor.index instead of cursor.x elimnates the need to include scaling information.
For an xy graph, there could be multiple segments (e.g. imagine a spiral that passes the desired x range multiple times from both sides). This would neeed significantly more code for a general solution.
Message Edited by altenbach on 11-24-2009 07:53 AM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
cursorsubset.png 17 KB -
How to get the difference between these two dates
Hello Friends,
I need to get the difference between these two fields which store dates but with varchar2 data types
SELECT pac.segment1, pac.segment2 emp_no, pac.segment3 NAME,
pac.segment4 POSITION, pac.segment5 start_date, pac.segment6,
pac.segment7
FROM per_analysis_criteria pac, fnd_id_flex_structures_vl ffs
WHERE ffs.id_flex_structure_code = 'Employee Rejoin'
AND ffs.id_flex_num = pac.id_flex_num
AND TO_CHAR (TO_DATE (pac.segment7, 'YYYY/MM/DD HH24:MI:SS'))
- TO_CHAR (TO_DATE (pac.segment6, 'YYYY/MM/DD HH24:MI:SS')) > 1;
my query is something like this...
am trying to find the difference between the last two columns but with not much luck..
can some one suggest me a solution pleaseSELECT pac.segment1, pac.segment2 person_id, pac.segment3 NAME,
papf.employee_number, paaf.supervisor_id, pac.segment4 POSITION,
pac.segment5 start_date, pac.segment6, pac.segment7,
papf2.email_address,
( TO_DATE (TO_CHAR (pac.segment7), 'DD-MON-YYYY HH:MI:SS AM')
- TO_DATE (pac.segment6, 'DD-MON-YYYY HH:MI:SS AM')
+ 1
) difference,
POST.email_address
FROM per_analysis_criteria pac,
apps.fnd_id_flex_structures_vl ffs,
per_all_people_f papf,
per_all_assignments_f paaf,
per_all_people_f papf2,
(SELECT email_address, person_id
FROM per_all_people_f
WHERE person_id IN (
SELECT person_id
FROM per_all_assignments_f
WHERE position_id IN (SELECT position_id
FROM per_positions
WHERE NAME LIKE 'HR Manager.704.')
AND TRUNC (SYSDATE) BETWEEN effective_start_date
AND effective_end_date)
AND TRUNC (SYSDATE) BETWEEN effective_start_date AND effective_end_date
AND business_group_id = fnd_profile.VALUE ('PER_BUSINESS_GROUP_ID')) POST
WHERE ffs.id_flex_structure_code = 'Employee Rejoin'
AND TO_CHAR (papf.person_id) = pac.segment2
AND ffs.id_flex_num = pac.id_flex_num
AND TRUNC (SYSDATE) BETWEEN papf.effective_start_date
AND papf.effective_end_date
AND papf.current_employee_flag = 'Y'
AND papf.person_id = paaf.person_id
AND TRUNC (SYSDATE) BETWEEN paaf.effective_start_date
AND paaf.effective_end_date
AND papf.person_id = paaf.person_id
AND papf2.person_id = paaf.supervisor_id
AND paaf.primary_flag = 'Y'
AND TRUNC (SYSDATE) BETWEEN papf2.effective_start_date
AND papf2.effective_end_date
AND papf2.current_employee_flag = 'Y'
and ( TO_DATE(to_char(pac.segment7), 'DD-MON-YYYY HH:MI:SS AM')-TO_DATE (pac.segment6, 'DD-MON-YYYY HH:MI:SS AM')+1) >1
last line is giving me the error pls suggest a solution -
Java code to get the difference between two dates in days
Hi ppl,
I need to write a user defined function to get the difference between two date nodes, in days.Please help me out
regards,
PrashanthHi,
have a look at those two:
(How do I calculate the difference between two dates?)
http://joda-time.sourceforge.net/faq.html
Calculating the Difference Between Two Datetime Stamps
http://www.xmission.com/~goodhill/dates/deltaDates.html
Get difference in days
http://javaalmanac.com/egs/java.util/CompDates.html
Regards,
michal -
When I look up the creation date for files on my Macbook (using "get info", or the information window in Iphoto) I get the date and month in brackets, but not the year. Why is this and how can I look up the year?
Does the Date Modified column in a window set to List view show the date correctly, or does it also display it incorrectly?
To add additional columns to a Finder (folder) window, with that window open and active open the View Options for it. You can do that by pressing Command-J or by selecting View Options from the View menu in the main menubar. -
How to get the number of years, months with two sysdate()
Hi All,
Sorry for posted another question regarding the conversion.
I have the hiring day and current day in date format like : '2005-10-01' and '2006-09-14'
How to get the differences between current date is ('2006-09-01') and
hiring date is ('2004-10-01' )
in the format number of years and number of month without using the Mod
function . For this example the result is : 2 years 1 month
Thanks
JPHow to get the differences between current date is ('2006-09-01') and
hiring date is ('2004-10-01' )
in the format number of years and number of month without using the Mod
function . For this example the result is : 2 years 1 monthshould not it be 1 year 11 months???
SQL> select (date '2006-09-01' - date '2004-10-01') year to month diff from dual;
DIFF
+01-11 -
Not able to get the data from synchronous Webservice To BPEL process
Hi All,
My requirement is : Third party has some webservice.They are pushing data to that Webservice(Wsdl).
Third part WSDL example : http://ipaddress:port/name/Service.svc?wsdl ( This is just example format of their WSDL)
After that I need to get that data into my BPEL process and update my system.
When I built My Snchronous BPEL process I imported third party WSDL(http://ipaddress:port/name/Service.svc?wsdl) through 'import WSDL' in dialog.After that I automatically got the (request and response schema elements) parameters from that WSDL.I gave input and output of the BPEL process from those elements.
I pasted that third party URL iin SOAPUI and I got their operations and schemas.Based on that I had choosen the elements for 'input' and 'output' of the BPEL processes.I am also getting the schema structures in 'Assign' or 'Transform' activity.
I built the whole process.
I have the Process.
Now Client is pushing data to their WSDL(http://ipaddress:port/name/Service.svc?wsdl) as it is their data pushing interface.But that data is not coming to my BPEL process and instance is not being created in EM console.
As I have imported their WSDL into my BPEL process,I need to get the data.But I am not getting the data.
Is there any problem in MY BPEL process?
(or)
DO I need to use 'Webservice' Adapter in 'Exposed Services' Swimlane in Composite Editor to have the third party URL, so that they Can push the data to that WSDL in turn that data comes into my BPEL process?
Can anybody help me this case?
once again my requirement is :
Client pushes the data through their WSDL url -----> I need to get that data into MY BPEL process --> I have my own WSDl to take that details into my system.I will explain the requirement in small paragraph:
There are two applications.One is our application(X) and another one is third party application(Y).
I need to update in my application(X) based on data coming from application(Y).
I am using SOA as a middle tier to have communication between Y and X.
(Ex: if they send some info like event type 'event1' from Y ,I need to update that 'event1' data in my X application)
The work at third party application is :
According their info,They will push data from their end to their WSDL( http://ipaddress:port/name/Service.svc?wsdl ).
They are telling they can only send the data to their WSDL( http://ipaddress:port/name/Service.svc?wsdl ).
They will not consume our BPEL process(I think they might be wrong at this point of time).They have one WSDL to send or push the data from their end.
The work at from our side(SOA & X application)
From that point ,our BPEL process has to receive that data and update that data into my application(X).
I hope You understand my requirement.
Can you guide me through how to achieve this task as they are telling they have to use their WSDL to push the data?
(or)
Do I need to take 'Webservice' adapter into Exposed Services Swimlane in Jdeveloper to have their webservice(third party WSDL),If it is So Can you tell me the details how to take 'input' and 'output' for BPEL process?
(or)
Can YOu suggest me to talk to them to consume my BPEL process directly?
Thanks
Edited by: 899283 on Aug 17, 2012 4:55 AM -
Unable to get the data from the stored procedure
Hello Folks,
I have this stored procedure and am trying to get the data from the table stage_bill but for some reason i am not sure its not pulling the data.Am a beginner in pl/sql Can any one please help to find out. I can give the code below.
create or replace procedure Load_FADM_Staging_Area_TEST(p_data_load_date date) is
-- local variables
v_start_date date;
v_end_date date;
-- cursor starting
CURSOR c_get_data
IS
SELECT
a.batch_id
,a.beginning_service_date
,a.bill_id
,a.bill_method
,a.bill_number
,a.bill_received_date
,a.bill_status
,a.bill_type
,a.change_oltp_by
,a.change_oltp_date
,a.client_datafeed_code
,a.client_id
,a.created_date
,a.date_of_incident
,a.date_paid
,a.deleted_oltp_by
,a.deleted_oltp_date
,a.duplicate_bill
,a.ending_service_date
,a.event_case_id
,a.event_id
,a.from_oltp_by
,a.oltp_bill_status
,a.review_status
,'HRI' schema_name
, sysdate Load_date
,'ETLPROCESS001' Load_user
,v_start_date as Row_Effective_Date
,null Row_End_date
from stage_bill a
where
--created_date >= to_date('20101031 235959', 'YYYYMMDD HH24MISS')
created_date >= v_start_date
and
--created_date <= to_date('20101111 235959', 'YYYYMMDD HH24MISS')
created_date <= v_end_date
and not exists
(select
b.batch_id
,b.beginning_service_date
,b.bill_id
,b.bill_method
,b.bill_number
,b.bill_received_date
,b.bill_status
,b.bill_type
,b.change_oltp_by
,b.change_oltp_date
,b.client_datafeed_code
,b.client_id
,b.created_date
,b.date_of_incident
,b.date_paid
,b.deleted_oltp_by
,b.deleted_oltp_date
,b.duplicate_bill
,b.ending_service_date
,b.event_case_id
,b.event_id
,b.from_oltp_by
,b.oltp_bill_status
,b.review_status,
b.schema_name,
b.Load_date,
b.Load_user,
b.Row_Effective_Date,
b.Row_End_Date
from STG_FADM_HRI_STAGE_BILL_TEST b)
-- cursor o/p variables
v_batch_id stage_bill.batch_id%TYPE;
v_beginning_service_date stage_bill.beginning_service_date%TYPE;
v_bill_id stage_bill.bill_id%TYPE;
v_bill_method stage_bill.bill_method%TYPE;
v_bill_number stage_bill.bill_number%TYPE;
v_bill_received_date stage_bill.bill_received_date%TYPE;
v_bill_status stage_bill.bill_status%TYPE;
v_bill_type stage_bill.bill_type%TYPE;
v_change_oltp_by stage_bill.change_oltp_by%TYPE;
v_change_oltp_date stage_bill.change_oltp_date%TYPE;
v_client_datafeed_code stage_bill.client_datafeed_code%TYPE;
v_client_id stage_bill.client_id%TYPE;
v_created_date stage_bill.created_date%TYPE;
v_date_of_incident stage_bill.date_of_incident%TYPE;
v_date_paid stage_bill.date_paid%TYPE;
v_deleted_oltp_by stage_bill.deleted_oltp_by%TYPE;
v_deleted_oltp_date stage_bill.deleted_oltp_date%TYPE;
v_duplicate_bill stage_bill.duplicate_bill%TYPE;
v_ending_service_date stage_bill.ending_service_date%TYPE;
v_event_case_id stage_bill.event_case_id%TYPE;
v_event_id stage_bill.event_id%TYPE;
v_from_oltp_by stage_bill.from_oltp_by%TYPE;
v_oltp_bill_status stage_bill.oltp_bill_status%TYPE;
v_review_status stage_bill.review_status%TYPE;
v_schema_name varchar(50);
v_Load_date date;
v_Load_user varchar(50);
v_Row_Effective_Date date;
v_Row_End_Date date;
Begin
if p_data_load_date is null then
select (sysdate - 7), (sysdate - 1) into v_start_date, v_end_date from dual;
elsif p_data_load_date is not null then
select (p_data_load_date - 7), (p_data_load_date - 1) into v_start_date, v_end_date from dual;
else
raise_application_error('-20042', 'Data control - GetDataControlAuditData : Date parameter must be a date of this or a previous week.');
end if;
-- cursor c_get_data loop begin
OPEN c_get_data;
LOOP -- cursor c_get_data loop begin
FETCH c_get_data
INTO
v_batch_id,
v_beginning_service_date,
v_bill_id ,
v_bill_method ,
v_bill_number,
v_bill_received_date,
v_bill_status,
v_bill_type,
v_change_oltp_by,
v_change_oltp_date,
v_client_datafeed_code,
v_client_id,
v_created_date,
v_date_of_incident,
v_date_paid,
v_deleted_oltp_by,
v_deleted_oltp_date,
v_duplicate_bill,
v_ending_service_date ,
v_event_case_id ,
v_event_id,
v_from_oltp_by,
v_oltp_bill_status,
v_review_status,
v_schema_name,
v_Load_date,
v_Load_user,
V_Row_Effective_Date,
v_Row_End_Date;
EXIT WHEN c_get_data%NOTFOUND;
insert into STG_FADM_HRI_STAGE_BILL_TEST
batch_id
,beginning_service_date
,bill_id
,bill_method
,bill_number
,bill_received_date
,bill_status
,bill_type
,change_oltp_by
,change_oltp_date
,client_datafeed_code
,client_id
,created_date
,date_of_incident
,date_paid
,deleted_oltp_by
,deleted_oltp_date
,duplicate_bill
,ending_service_date
,event_case_id
,event_id
,from_oltp_by
,oltp_bill_status
,review_status
,schema_name
,Load_date
,Load_user
,Row_Effective_Date
,Row_End_Date
values(
v_batch_id,
v_beginning_service_date,
v_bill_id ,
v_bill_method ,
v_bill_number,
v_bill_received_date,
v_bill_status,
v_bill_type,
v_change_oltp_by,
v_change_oltp_date,
v_client_datafeed_code,
v_client_id,
v_created_date,
v_date_of_incident,
v_date_paid,
v_deleted_oltp_by,
v_deleted_oltp_date,
v_duplicate_bill,
v_ending_service_date ,
v_event_case_id ,
v_event_id,
v_from_oltp_by,
v_oltp_bill_status,
v_review_status,
v_schema_name,
v_Load_date,
v_Load_user,
v_Row_Effective_Date,
v_Row_End_Date ) ;
COMMIT;
END LOOP;
CLOSE c_get_data;Maybe you need something else, like
CREATE OR REPLACE PROCEDURE load_fadm_staging_area_test (
p_data_load_date DATE
) IS
v_start_date DATE;
v_end_date DATE;
BEGIN
SELECT NVL (p_data_load_date, SYSDATE) - 7,
NVL (p_data_load_date, SYSDATE) - 1
INTO v_start_date,
v_end_date
FROM DUAL;
MERGE INTO stg_fadm_hri_stage_bill_test b
USING (SELECT *
FROM stage_bill
WHERE created_date BETWEEN v_start_date AND v_end_date) a
ON (b.bill_id = a.billl_id)
WHEN NOT MATCHED THEN
INSERT (batch_id,
beginning_service_date,
bill_id,
bill_method,
bill_number,
bill_received_date,
bill_status,
bill_type,
change_oltp_by,
change_oltp_date,
client_datafeed_code,
client_id,
created_date,
date_of_incident,
date_paid,
deleted_oltp_by,
deleted_oltp_date,
duplicate_bill,
ending_service_date,
event_case_id,
event_id,
from_oltp_by,
oltp_bill_status,
review_status,
schema_name,
load_date,
load_user,
row_effective_date,
row_end_date
VALUES (a.batch_id,
a.beginning_service_date,
a.bill_id,
a.bill_method,
a.bill_number,
a.bill_received_date,
a.bill_status,
a.bill_type,
a.change_oltp_by,
a.change_oltp_date,
a.client_datafeed_code,
a.client_id,
a.created_date,
a.date_of_incident,
a.date_paid,
a.deleted_oltp_by,
a.deleted_oltp_date,
a.duplicate_bill,
a.ending_service_date,
a.event_case_id,
a.event_id,
a.from_oltp_by,
a.oltp_bill_status,
a.review_status,
'HRI',
SYSDATE,
'ETLPROCESS001',
v_start_date,
NULL
END load_fadm_staging_area_test;Whenever you code a cursor and a loop, ask yourself. Do I need that?
Regards
Peter
Maybe you are looking for
-
How to keep the ".mac" version email address from showing up in Mail?
I was a .Mac guy way back. MobileMe came out. Now I have two emails, the difference being the domain. One .mac and one .me. I just want to use the .me. I had several aliases and they all have the same issue. When I choose which email address to send
-
WD ABAP: logon via HTTPS
Hi, next question... on logon to my WD application I get the logon screen with the following text: No switch to HTTPS occurred, so it is not secure to send a password but I have to enter a password on this screen although it is not save to send a pas
-
I have a select statemnet like below.. it currently returns 3 rows. I want the the last value from this query below. so i want only "4" returned from this query. How to achieve it ? Thanks for the help. SQL SELECT col6 FROM TableA WHERE col1=12 AN
-
Hi gurus, When posting goods via trcode mb1c I get error as material has status in plant xx. How can I correct the error? Thanks&Regards
-
Enable the Ethernet Port on the STB ?
Hi I have a PC right next to the Verizon STB (the HD one w/o DVR) and I was wondering if Verizon can enable the ethernet on the back of the STB so I can plug in the PC and get it networked w/ the rest of the net ? Thanks, HC