PL/SQL :: Break Down Each Member Range By Record Per Month?

Mar 28, 2013

have a req like below

CREATE TABLE TEST_BRK
( EMP_ID VARCHAR2(20),
  BEG_DT DATE,
  END_DT DATE,
  DEPT_CODE VARCHAR2(10),
 
[code]...

  COMMIT;i need to break down the each member range by record per month and make a record as first day of that month . and dept and branch should have the same value as what the value it was in the range of source.

excepted ouput like below

  EMP_ID      MONTH_DAY_1    DEP_CODE    BRANCH
  AAAA        01-JAN-2010      02          A
  AAAA        01-FEB-2010      02          A
  AAAA        01-MAR-2010      02          A
  AAAA        01-APR-2010      02          A
  AAAA        01-MAY-2010      02          A
  AAAA        01-JUN-2010      05          B
  AAAA        01-JUL-2010      05          B
 
  .how can i code the logic to get my expected output above

View 3 Replies


ADVERTISEMENT

PL/SQL :: Code Erases Previous Month Record While Updating Current Month Record

May 16, 2013

Using 11gR2, windows 7 client machine. I need to update the table missing_volume (below), where I need to calculate the estimated_missing column. The calculation of estimated_missing column for current month needs previous month numbers (as commented inside the code below). I want the output like the first table. Notice the records start from January, hence estimated_missing for January can't be calculated, but for the the rest of the months it can be done by simply changing 'yr' and 'mnth' (commented inside the code towards the end).

yr          mnth          location     volume          actual_missing          expected_missing     estimated_missing
---------------------------------------------------------------------------------------------------------------------------------
2013            January          loc1          48037          24               57                         
2013             February     loc1          47960          3660               53                      24
2013             March          loc1          55007          78               57                      28
2013             April          loc1          54345          72               58                  77The code:

UPDATE missing_volume g

[Code]....

The code does calculate correct number for 'estimated_missing' as I run the code for each month, but the problem is while updating the current month it also erases the record for previous month. E.g. as can be seen below, after I updated April the column only has the record for April, previous month record is gone, similarly updating March removed February, etc. I can't understand why it's happening!! Here is the output I get:

yr          mnth          location     volume          actual_missing          expected_missing     estimated_missing
---------------------------------------------------------------------------------------------------------------------------------
2013            January          loc1          48037          24               57                         
2013             February     loc1          47960          3660               53
2013             March          loc1          55007          78               57
2013             April          loc1          54345          72               58                   77

why it's happening (I mean where is the flaw in the code) and how to get the desired output (first table).

View 5 Replies View Related

PL/SQL :: Month Wise Break

May 4, 2013

I have a requirement as follows :-

The user will submit the start date and end date. Based on the date parameters, the customized procedure should do some calculations month-wise.

For eg : start date - 01-Dec-2012 to end date - 31-Mar-2013

I want the break up as
Start date End date
01-dec-2012 31-dec-2012
01-jan-2013 31-jan-2013
01-feb-2013 28-feb-2013
01-mar-2013 31-mar-2013

How can i achieve this month-wise break ?

View 6 Replies View Related

SQL & PL/SQL :: Range By Day And Month

Sep 20, 2010

I have table :TABLE_X and want to select some data locate into specific range of Day/Month. But so far i couldn't find out the way to.

For example, i want to select people born within specific range of date(range : sysdate to (sysdate+7months ahead) Year here should not be consider, only the day and month.

e.g. a range could be from today:Sept,20 to Apr,18.

so what i was trying is to select doing the following.

select TABLE_X_ID, TABLE_X_BIRTH_DATE
from TABLE_X
where to_date(TABLE_X_BIRTH_DATE, 'DD/MM')
between to_date (to_char(SYSDATE, 'DD/MM'), 'DD/MM')
and to_date (to_char(SYSDATE+210, 'DD/MM'), 'DD/MM')

first am not sure if BETWEEN & AND will work for this case, bt it was the most logical way i could think about to get such range.

View 13 Replies View Related

Script To Add Range Partition Automatically - Every Month

Mar 3, 2012

Script to add range partition automatically. This script should be running every month and add the partitions for next 3 months

View 3 Replies View Related

SQL & PL/SQL :: How To Get Last Month Record

Jun 10, 2010

i want to get the last month starting from today onwards.

1) select the record of last month that is if this month is june then select the record for 1st may to 31st of may

View 7 Replies View Related

SQL & PL/SQL :: Fetch Record On The Basis Of Month In Where Clause

Jan 6, 2011

i want to fetch records of emp whose hiredate between 1 sep to 30 sep of any year. i am using the below query but it show me wrong results.

select * from tran where to_char(timestamp,'DD-MM') between '01-SEP' and '30-SEP'

View 2 Replies View Related

SQL & PL/SQL :: How To List Data Dynamically Month Wise Picking Month From The Same Table

Jun 4, 2013

I have a requirement to list the data month wise dynamically where month data is also in the same table, hopefully the below posts should bring more clarity to my requirements.

1. Table creation:
Create table T1 (account_no varchar2(15), area_code varchar2(2), bill_month date, consumption number);

2. List table content:
select * from T1;

account_no area_code bill_month consumption

Q00001Q31-Jan-12125
Q00002Q31-Jan-1265
Q00003Q28-Feb-12219
Q00004Q28-Feb-12805
Q00005Q28-Feb-1254
Q00001Q31-Mar-12234
Q00002Q31-Mar-12454
Q00003Q31-Mar-12232
Q00004Q30-Apr-1221
Q00005Q30-Apr-12218
Q00001Q30-Apr-1254
Q00002Q31-May-1219
Q00003Q31-May-1287
Q00004Q30-Jun-12187
Q00005Q30-Jun-1278
so on......so on......so on......so on......

3. Expected output:
account_no area_code Jan-12 Feb-12 Mar-12 Apr-12 May-12Jun-12Jul-12Aug-12Sep-12Oct-12Nov-12Dec-12

Q00001 Q 125 548 2345487423154821518738721512
Q00002 Q 65 127 45487819357831585683152878
Q00003 Q 545 219 2328738735188745897313
Q00004 Q 78 805 1221218187885718387389787138
Q00005 Q 541 54 2621878778386538698182

With the conventional query I hope this is impossible,

View 2 Replies View Related

How To Use Member Procedures

Dec 13, 2009

create type employee is object(
name varchar2(30),
member procedure change_name(new_name varchar2)
)

[Code]....

Now how to use the change_name procedure to change the name of the employees in the table?

View 1 Replies View Related

REDO Log Member Multiplex

Jun 13, 2012

I wanna know if the redo log members are mirror copies.All member files from a same redo group have the same data?Are there any different in mirror or multiplex a file?

View 4 Replies View Related

How To Get Youngest And Oldest Member In The Table

Sep 3, 2008

select
a.first_name,
a.agent_id,
a.birth_date
from
agents a
[code]........

from the above i cannot get the youngest one! this is giving me some mid age.

View 14 Replies View Related

SQL & PL/SQL :: Numbering On Break

Mar 24, 2010

I have a query with output as:

CUST PROD
Customer1Product1
Customer1Product2
Customer1Product3
Customer2Product1
Customer2Product2
Customer3Product1The output required is

Number CUST PROD
1 Customer1Product1
Customer1Product2
Customer1Product3
2 Customer4Product1
Customer4Product2
3 Customer5Product1

For every change in customer i need to put a new serial number.

View 2 Replies View Related

Page 2 - Get Youngest And Oldest Member In Table?

Sep 5, 2008

Do u want to get the youngest & oldest member at each location?

View 1 Replies View Related

How Newly Added Log Member Get Sync With Existing One

Jun 29, 2011

If one of the redolog member corrupted and overcome this problem, I had removed the corrupted redolog member. Later I had added a new member to this group.

I would like to know, is the newly added log member will get sync with existing log member? How the newly added log member get sync with existing log member?

View 1 Replies View Related

SQL & PL/SQL :: Member Procedure Insert With Subtype Info?

Mar 2, 2012

Im trying to generate a member procedure that allows the user to manual enter the required information via substitution variables. The manual INSERT INTO statements work but I cant seem to get it to work within a procedure.

Here is the code for the type, table andstandard insert:

CREATE TYPE toy_typ AS OBJECT
(toy_id NUMBER ( 5),
toy_name VARCHAR2 (20),
toy_cost NUMBER ( 4),

[code]...

the procedure complies but i get a warning error. When i also try to execute the code with either set values or substitutions i get either not enough or to many values error.

View 39 Replies View Related

Server Administration :: Increasing Size Of Redolog Member

Feb 27, 2008

The size of redolog member is 12m . Can I increase the size of that member dynamically, without adding a new member to that group and dropping the old one.

View 8 Replies View Related

SQL & PL/SQL :: Query To Replace Command (break On Column Name)

Apr 29, 2010

I dosn't want to use the command break on <column name> / how to write sql to replace the break command.

View 8 Replies View Related

SQL & PL/SQL :: ENTER (line Break) In Name Field Column?

Jun 12, 2013

There is a problem with name field like ex:

ENTER(line break) between 'HHD DDD PRIVATE' and 'LTD.

how to put a check in code to avoid these type of scenarios.

View 4 Replies View Related

Reports & Discoverer :: Page Break On A Group?

Jun 5, 2003

I have a report with 4 groups one above the other and there is data such that each group has certain number of records for a particular value. Now what I want is, to have a page break after each set of data for all the groups. Can this be achieved using format triggers ?

View 3 Replies View Related

Reports & Discoverer :: Break RTF Page After Every 8 Records?

Aug 6, 2010

how can i break my rtf page after every 8 record.

View 2 Replies View Related

SQL & PL/SQL :: Query To Break Date And Connect By Level

Nov 7, 2012

I have following table

CREATE TABLE MAMALIK.DTE
(
FRM_DTE DATE,
TOO_DTE DATE
)
Insert into DTE
(FRM_DTE, TOO_DTE)
Values
[code]........

Result is

FRM_DTE TOO_DTE

01/07/201201/07/2012
03/07/201207/07/2012
11/07/201215/07/2012
31/07/201201/08/2012

i want to write query which should return data as

01-jul-2012
03-jul-2012
04-jul-2012
05-jul-2012
06-jul-2012
07-jul-2012
11-jul-2012
12-jul-2012
13-jul-2012
14-jul-2012
15-jul-2012
31-Jul-2012
01-Aug-2012

i want to generate dates between frm_Dte and too_dte in single column

View 4 Replies View Related

SQL & PL/SQL :: Access Attributes Of Objects Of Nested Table In Member Function Of Oracle Database

Nov 17, 2011

I have created two types and a list of the first type:

create type type1;
/
create type type1_list as table of ref type1;
/
create type type2;
/

I have now just created the two types as follows:

create type type1 as object(
id# number
);
/
create type type2 as object(
attribute1 type1_list,
MEMBER FUNCTION function1 RETURN NUMBER
);
/

Ok, I've created the tables (I don't know if it's necessary to point out my problem)

CREATE TABLE type1_table OF type1;
/
CREATE TABLE type2_table OF type2
NESTED TABLE attribute1 STORE AS nested_type1_list_table;
/

And what I wanted to do now is to implement the member function1 and check something of the attributes of type1 in the list of attribute1... And that's where my question occurs, how does it work, I can't figure it out. I tried something like this:

Quote:
create or replace
TYPE BODY type2 AS
MEMBER FUNCTION function1 RETURN NUMBER AS

[Code]....

But I don't get the right way, it doesn't work

View 4 Replies View Related

PL/SQL :: Create View Which Is Aggregate Count Of Member Records / Grouped By Business_unit / Gender / Age Per Year

Oct 13, 2012

Using Oracle 11g...We have a table in our database of data with the following information:

MASTER_RECORD,
MEMBER_RECORD,
BUSINESS_UNIT,
GENDER,
DOB (date),
age [at time of month_record],
MONTH_RECORD (date) [31-MON-YEAR for recorded active month]

The table has ~55 million records. Existing index is only on MASTER_RECORD.There is now a need to create a view which is an aggregate count of member records, grouped by business_unit,gender, age per year. eg:

business_unit, gender, age, month_record, num_of_members -> for every combination
unit5, F, 25, 31-JUN-2011, 622
unit3, M, 18, 31-MAY-2011, 573

The view can be created now, but, is not fast enough to be reasonably considered a view. This table is re-created every month from a procedure, so there is flexibility on how it is created. Use interval partitioning by year( something I have not experienced using), create an index on the month_record,then create view.

View 2 Replies View Related

Application Express :: Interactive Report - Break Formatting Style?

Nov 14, 2013

,Is there a way to make Interactive reports break format work/look like classic reports break format? i.e.1st,2nd,3rd column option. The way IR breaks is that is reserves a whole row for the column used in the break, which is not what I want, I want the report to look like the following:

 city               emp           sal 
Chicago     John Miller  1500                
Mark Horton 2000
Denver       Rob Martino 1200 

I tried to use rollup queries which work fine except that it does not do exactly what I want when I sort columns through the front end , I am basically displaying a check box for grouped records ( and I want it to display at the first record of each group), so the order is important. for example: 

checkbox   City               emp           sal[ ]              
Chicago     John Miller    1500         
Mark Horton  2000[ ]             
Denver       Rob Martino  1200 

View 2 Replies View Related

Reports & Discoverer :: Oracle Report 10g - Sorting In Break Order

Nov 30, 2010

Is there a way to short a Matrix report? The query shorts correctly in PLSQL but not in the generated report file.

There are columns like Date,Device,Operator Id etc and the report should be able to short depending on the requirement. For example,

it should be able to short by device, or by Date or both. I tried sorting in the 'Break order' but doesn't come out as required.

View 6 Replies View Related

Application Express :: Control Break Appearance In Interactive Report

Sep 4, 2013

I'm using a control break on 3 columns in my report, but when doing this Apex shows the columns comma-separated, like: Column A: value, Column B: value, Column C: value But I would like it to look like:

Column A: value
Column B: value
Column C: value 

Is there any way of achieving this? I am currently working with the test environment Oracle supplied us, because we are testing if we can use APEX at our company. The version is Application Express 4.2.2.00.11 and it's running on Oracle 11g. Im using Firefox but it's just the same in IE. 

View 10 Replies View Related

SQL & PL/SQL :: For Each Month Sum Values From Month Before?

Nov 25, 2010

I need for each date sum the values from the begin of the year to present date. In January I will have the value of this month, on February I must sum the value of this month and the value of the month before, and so on, at the end of the year.

Date input

SELECT ID_CLIENT, DT_REG, VAL
FROM (
SELECT 1 as ID_CLIENT, TO_DATE('20100101', 'YYYYMMDD') as DT_REG, 200 as VAL FROM DUAL UNION
SELECT 1 as ID_CLIENT, TO_DATE('20100201', 'YYYYMMDD') as DT_REG, 100 as VAL FROM DUAL UNION
SELECT 1 as ID_CLIENT, TO_DATE('20100301', 'YYYYMMDD') as DT_REG, 200 as VAL FROM DUAL UNION
SELECT 1 as ID_CLIENT, TO_DATE('20100401', 'YYYYMMDD') as DT_REG, 150 as VAL FROM DUAL UNION
SELECT 1 as ID_CLIENT, TO_DATE('20100501', 'YYYYMMDD') as DT_REG, 100 as VAL FROM DUAL UNION
SELECT 2 as ID_CLIENT, TO_DATE('20100101', 'YYYYMMDD') as DT_REG, 100 as VAL FROM DUAL UNION
SELECT 2 as ID_CLIENT, TO_DATE('20100301', 'YYYYMMDD') as DT_REG, 220 as VAL FROM DUAL UNION
SELECT 2 as ID_CLIENT, TO_DATE('20100501', 'YYYYMMDD') as DT_REG, 500 as VAL FROM DUAL UNION
SELECT 3 as ID_CLIENT, TO_DATE('20100201', 'YYYYMMDD') as DT_REG, 150 as VAL FROM DUAL UNION
SELECT 3 as ID_CLIENT, TO_DATE('20100501', 'YYYYMMDD') as DT_REG, 100 as VAL FROM DUAL);

Result

ID_CLIENTDT_REGVAL
101/01/2010200
101/02/2010300
101/03/2010500
101/04/2010650
101/05/2010750
201/01/2010100
201/03/2010320
201/05/2010820
301/02/2010150
301/05/2010250

View 17 Replies View Related

Client Tools :: Break And Compute Command Usage To Modify Output

Oct 14, 2010

I tried BRK and COMPUTE commands myself after reading the documentation but its not working...The output of my script is correct but What I want is the information to be displayed on a different way:

Original script for the report:

set serveroutput on size 1000000
set pages 10000
set lines 1000
set arraysize 1
set trimspool on
set heading off
[code]....

The output should be exactly as above as the requirement is this should be in this particular order and how many is the count in each thoroughfare or locality, as shown in the final output, above.

View 3 Replies View Related

Client Tools :: Different Charactersets Show Line-break In Select Result

Mar 22, 2010

i have a little curiosity in result of a select statement.

One database has following characterset settings:

NLS_CHARACTERSET WE8ISO8859P15
NLS_NCHAR_CHARACTERSET AL16UTF16

and the following select statement results in multiple lines:

SQL> select INSTANCE_NAME,STATUS from v$instance;
INSTANCE_NAME
------------------------------------------------
STATUS
------------------------------------
BUP
OPEN

Another database has following characterset settings:

NLS_CHARACTERSET UTF8
NLS_NCHAR_CHARACTERSET AL16UTF16

and the same select shows only a 2 line result:

SQL> select INSTANCE_NAME,STATUS from v$instance;
INSTANCE_NAME STATUS
---------------- ------------------------------------
HPSMP OPEN

Both databases are version 10.2.0.4 and both are running on HPUX 11.31.Why do we get this differents in showing the result?

Our problem is that the package-start scripts from HP, to start a database, check the result of the select statement above and if we have the multiline result the check gives an error and stops the package again.

View 3 Replies View Related

JDeveloper, Java & XML :: Section Break Conflicts With Dynamic Header In RTF File

Jun 26, 2012

I have dynamic header in my rtf file. I have section break on start group of body. but it does not display dynamic header value. If i remove section break then it display dynamic header.

I have to display dynamic header and section break is also required there.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved