SQL & PL/SQL :: Perform Math Calculation Upon Dates?

Feb 9, 2011

I got 4 fields:

event_date (01/01/1900 hh:mm:ss)
team_count (number)
interview_count (number)
duration (01/01/1900 hh:mm:ss) - duration of each interview

The calculation is:

(interview_count * team_count * duration(hh:mm)) + event_date
i.e.:
(3 * 2 * 02:30) + 01/01/1900 08:00:00
= 15:00:00 + 01/01/1900 08:00:00
= 01/01/1900 23:00:00.

all I care about is the hh:mm in the result.How can I preform this calculation in pl/sql?

View 7 Replies


ADVERTISEMENT

Balance Calculation And Subtracting / Displaying Dates?

Sep 3, 2010

My problem is that I am working with a balance (Infor/WorkBrain - Time & Attendance) I have a balance called Bank Holiday(bal_id 10044). Every holiday that an employee works, he is allowed to take another day off in lieu of the day he worked. The employee has up to twelve months to take that holiday.

My job is to figure out when he worked that holiday (not a problem) and send an email/note at the 11 month mark and notify the employee and supervisors that said employee has 1 month to use his banked holiday.

Here is what the employee_balance log looks like.

EBLOG_IDEMP_IDBAL_IDEBLOG_DELTAWRKS_WORK_DATEWRKS_IDEBLOG_MESSAGE
51200128537100441 10/15/2010 5281229TCODE_NAME:FR_HWS
51150828537100441 7/1/2010 5136881TCODE_NAME:FR_HWS
51150928537100441 7/27/2010 5136942TCODE_NAME:FR_HWS
51150528537100441 8/1/2010 5137137TCODE_NAME:FR_HWS
5294372853710044-1 8/31/2010 5137173TCODE_NAME:FR_HWO
52947828537100441 6/3/2010 5001014TCODE_NAME:FR_HWS

My problem is the data/constraints I am working with. I can tell what day the holiday was based on a time code (EBLOG_MESSAGE) and EBLOG_DELTA shows a positive 1. I can also tell when the employee has used a bank holiday (EBLOG_DELTA is -1) and EBLOG_MESSAGE = FR_HWO.

But how to I perform the deduction so that I get four most current dates. Meaning since my first date that the employee gets for a holiday wokred is 6/3/2010 but the employee used a bank holiday on 8/31/2010. So I want to display the dates 7/1/2010, 7/27/2010, 8/1/2010 and 10/15/2010.

My preference would be not to add anything new to this table as it is a core table for Infor/WorkBrain.

View 2 Replies View Related

SQL & PL/SQL :: Evaluate Dynamic Math Expression?

Jun 22, 2008

I have a user interface where the user can enter a formula using a set of parameters and operators. For eg , the user is given a list of parameters, say : Width, Height , Gauge. The list of operators include standard math functions : + - / * ^

He can select and create a formula like gauge * width. This is stored in a table. At a later time a job is scheduled to evaluate the formula based on parameters for width, gauge and height.

I can evaluate the expression by substituting each parameter.

I can do this using dynamic sql. However I'm not sure how to evaluate the ^ symbol. The equivalent of this is power function.

So if a user enters (height * 2) + (width^2) . How do i evaluate this. I am doing this in pl/sql.

View 6 Replies View Related

SQL & PL/SQL :: Date Math And Daylight Savings Time

May 25, 2010

I am trying to get the number of seconds between March 3 2010 and march 31 2010 in Oracle. I am in Eastern time in the US. Everything I try just keeps coming up with 30 days * 86400 seconds per day = 2592000. 1 hour was lost when we switched to daylight savings time so the correct answer is 2588400.

How do a create a function in Oracle that will give me the number of seconds between 2 dates or timestamps that is aware of the loss of an hour in March and the gain of an hour in November?

View 8 Replies View Related

Finding Individual Dates Having Dates Plus 2 Days

Jan 26, 2011

I want to find the dates which have a date plus with in 2 days after this date. I mean group by 3 days each even the date i missing between two days. Actualy I want to find the start date where the employ was missing on job.

Basic concept is employes have allowed to use 10 personal leaves of a year. Each leave can be use for maximum 3 days.

If employ did not come on the job for one day or two days or three days, it shoul be count as ONE personal leave. And If employ is missing at job for four or five days, it should be count as 2 personal leaves.

seq date
------------------------------
101.01.10

205.01.10
306.01.10

410.01.10
512.01.10

613.01.10
714.01.10
815.01.10

916.01.10
1018.01.10

1119.01.10
1220.01.10
1321.01.10

1423.01.10

1526.01.10
1627.01.10

1729.01.10
1831.01.10

The result should be (Don't use Pl/Sql)

seq date
------------------------------
101.01.10
205.01.10
310.01.10
413.01.10
516.01.10
619.01.10
723.01.10
826.01.10
929.01.10

After finding these days I want to select the starting date of 5th personal leave. (which is 16.01.10).

I am not a expert of using SQL, but I think it could be possible with using partitioning a table on the givin reslult and further partition the reslut on rownum() as rn and the using case statement where rn = 5.

View 2 Replies View Related

SQL & PL/SQL :: Split A Date Into New Dates According To Black Out Dates?

Mar 10, 2011

Split a date into new dates according to black out dates!

Here is my tables:

CREATE TABLE travel
(
start_date,
end_date
)
AS
SELECT DATE '0000-01-01', DATE '9999-12-31' FROM DUAL;

[code]....

I have lets say a "travel date" and black out dates. I will split the travel date into pieces according to the black out dates.

Note: Travel Date can be between 0000-01-01 - 9999 12 31

Sample:

Travel Date:

Travel | START DATE | END DATE
T | 2011 01 04 | 2011 12 11

Black Out Dates:

BO | START DATE | END DATE
A | 2010 11 01 | 2011 02 11
B | 2011 01 20 | 2011 02 15
C | 2011 03 13 | 2011 04 10
D | 2011 03 20 | 2011 06 29

Excepted Result:

New Travel | START DATE | END DATE
X1 | 2011 02 16 | 2011 03 12
X2 | 2011 06 30 | 2011 12 11

Visually:

Travel Date : -----[--------------------------]--

A : --[------]-------------------------
B : ------[---]------------------------
C : --------------[---]----------------
D : ----------------[------]-----------

Result :

X1 : -----------[--]--------------------
X2 : -----------------------[--------]--

Sample 2:

Travel Date : -[--------------------------------]--

BO Date A : ----[------]-------------------------
BO Date B : -------------------------[---]-------
BO Date C : ----------------[---]----------------
BO Date D : ------------------[------]-----------

Result X1 : -[-]-------------------------------
Result X2 : -----------[--]--------------------
Result X3 : -----------------------------[--]--

How can I do it using PL SQL ?

View 5 Replies View Related

JDeveloper, Java & XML :: Using Java.lang.Math In Oracle / ORA-31011 / Parsing Failed

Apr 26, 2013

I am trying to execute an xslt (for XML transformation) using xmltype.transform function.

I can't paste XSLT code here, but below is similar what I am doing.

[URL]

I have used a reference of random() method of java.lang.Math in xslt file, and it's giving me below error.

ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00607: Invalid reference: 'random'.

I doubt, it's because of "Math" class, which is not present in Oracle, how to load standard java classes.

View 1 Replies View Related

Select All Dates Between Two Dates

Oct 22, 2003

How can I select all of the dates between two dates? For example, given the start date 12/2/2003 and the end date 12/5/2003 I want to return:

12/2/2003
12/3/2003
12/4/2003
12/5/2003

Is there a built in function for this? Is there a way for a function to return multiple rows? It has to be a function because I need to use it within other SQL statements.

View 14 Replies View Related

SQL & PL/SQL :: Gratuity Calculation?

Mar 16, 2012

i have attached the .csv file for gratuity calculation.

In the given criteria you can see if number of years 1 then he can get 1 salary if years 1.5 then 2 salary and so on also we need to take care about the leap year.

View 2 Replies View Related

SQL & PL/SQL :: For Ratio Calculation?

Sep 14, 2011

,i had given the sample data below

create table ex (sno number,ename varchar2(10),job_code char(4),sal number);
insert into ex values(101,'John','Java',21000,'IT');
insert into ex values(102,'Michel','BI',25000,'IT');
insert into ex values(103,'Johny','Java',30000,'IT');

[code]...

My expected output is attached in a text file

View 12 Replies View Related

Perform SELECT INTO In SQLPlus Script

Apr 11, 2007

I'm trying to perform a SELECT INTO in a SQL*Plus script.the script i'm working towards to, looks something like this;

set term on
set echo off
set serveroutput off
set verify off
ACCEPT ReportName PROMPT 'Please enter a report name; '
PROMPT
PROMPT retrieving current settings for &ReportName:
select STARTDATE, ENDDATE, SUFFIX
into pStart, pEnd, pSuffix
from MyTable
where NAME = '&ReportName';
[code]....

I'm basically trying to perform a select into based in user input and then put the retrieved data back to the console with a prompt. Is this possible within a sql script running on SQL*Plus?

View 3 Replies View Related

SQL & PL/SQL :: Perform SUM On Two Columns Based On Level?

Oct 21, 2011

Below is the code that i tried to perform the sum operation.

CREATE TABLE TEST11
(
FISCAL_TIME_ID NUMBER,
data_id number,
M_VALUE NUMBER,
Y_VALUE NUMBER
);

[code].....

The result I got is

SQL> SELECT FISCAL_TIME_ID, DATA_ID, M_VALUE,
2 SUM(m_value) OVER (PARTITION BY fiscal_time_id, data_id
3 ORDER BY FISCAL_TIME_ID) AS YTD_VALUE
4 from test11;

[code].....

But what I am actually want to get is.

FISCAL_TIME_ID DATA_ID M_VALUE YTD_VALUE
-------------- ---------- ---------- ----------
20110500 3 2 2
20110700 3 50 52
20110800 3 52
20111000 3 250 352
20111100 3 300 652

That is, the YTD_Value column is nothing but sum of M_VALUE column + previous fiscal_month_id's ytd_value column.

Test case:

The YTD_VALUE for fiscal_time_id 20110700 is obtained as current M_VALUE + previous fiscal_time_id's ytd_value => 50 + 2

I tried with the SQL but i could not get the result.

View 5 Replies View Related

PL/SQL :: Perform DML Or DDL When Select Query Is In Progress?

Aug 27, 2012

Is it possible to perform a DML or DDL when a select query is in progress?

View 8 Replies View Related

To Perform A Reorganization Of The Partition Table

May 6, 2010

I would like to perform a reorganization of the partition table. The table contains 144 partitions and 2038 indexes partitions with that. I would like to ask you to make me understand the best possible way to perform the reorg with cascade options in one attempt.

Also, am not sure how to get the information of the index type is Globally / Local index partition. Is there any document for reference that details about the reorg of partition tables?

View 7 Replies View Related

SQL & PL/SQL :: Field Name Based On Calculation

Apr 19, 2010

I want to display Week No as the heading.So, I have these:

define week_no=number
column week_col new_value week_no
select to_number(to_char(sysdate, 'ww')) week_col from dual;

I have tested it and it is working as the way I expected: select 'to display week no as column' "Week &week_no" from dual;

The output:
Week 16
----------------------------
to display week no as column ...So how do I display Week 15, Week 17 etc based on the calculation of &week_no e.g. &week_no+1?

View 19 Replies View Related

SQL & PL/SQL :: Calculation On A Time Field?

Jul 5, 2012

I have time fields that have been converted from a 12hr clock to a 24hr clock and these fields hold only the time...no date.

I need to be able to determine the difference between column A and B eg.

Column A: Column B:
11:00 14:00

I can remove the ':' by using the replace command, but as I need to run on a actual 24hr clock I am not sure how to tackle the calculation as it is not the full oracle datetime format.

View 8 Replies View Related

SQL & PL/SQL :: Cumulative Calculation In Oracle?

Feb 24, 2011

Is it possible to calculate cumulatively in oracle sql queries, i.e. using the results of the last row for calculating the values in the current row?For example I want my query to return the following:

Month col1 _ col2 _ col3
jan 1 _ 100 _ 100 * 1
feb 2 _ 200 _ 100 * 2 + 200
mar 3 _ 300 _ 400 * 3 + 300
apr 4 _ 400 _ 1500 * 4 + 400
may 5 _ 500 _ 6400 * 5 + 500

In col3 above, for feb I want to use the result returned for jan ((100 * 1)*2+200), for mar I am using the result returned for feb((100 * 2 + 200) * 3 + 300) and so on.

i.e. I want to use the previous value of column3 to derive the current value of column3. Like using the LAG function but on the analytically derived column itself.

View 16 Replies View Related

SQL & PL/SQL :: Time Zone Calculation

May 30, 2010

Check the following

SELECT FROM_TZ(CAST(TO_DATE('1999-12-01 11:00:00',
'YYYY-MM-DD HH:MI:SS') AS TIMESTAMP), 'gmt')
AT TIME ZONE '+05:30' "Time at Time zone"
FROM DUAL;

Time at Time zone
01-DEC-99 04.30.00.000000 PM +05:30

My requirement is that

I want to add 2 hours to DateTime i get here i.e. add two hours in result and display the resultant date and tine in time zone '+05:30'. I also want to check that the resultant time falls in business hours (9 am to 6 pm).

View 11 Replies View Related

SQL & PL/SQL :: Number Of Years Calculation

Mar 16, 2012

for making the query for following data,when we give start and end date then query need to calculate number of years.

if less than one year then return 0
if exact one year then return 1
if exact 1.5 years (18 months) then return 2
if exact 2 years (24 months) then also return 2
if exact 2.5 years (30 months) then return 3
if exact 3 years (36 months) then also return 3
if exact 3.5 years (42 months) then return 4
if exact 4 years (48 months) then also return 4
and so.

also we need to add leap year 1 day if exist in start and end date.

YearSalary
11
1.52
22
2.53
33
3.54
44
4.55
55
[code]....

View 15 Replies View Related

Forms :: Calculation When Add Numbers

Feb 5, 2011

I am developing a form where I need to add Numbers.In fact we have a bag of Cones that contain 24 cones.In normal calculation when I add numbers for example

5.24 Plus 5.24 it will give the result 10.48

I Need the appropriate method to calculate if I add these two numbers it should give the result 5.24 Plus 5.24 the result should be 12

View 7 Replies View Related

Forms :: Time Calculation

Oct 20, 2011

Currently I am working on payroll system where I have to calculate employees working hours/late coming hours/early going hours against its roster which is defined in the beginning of every month/week.

In roster form user define shift of every employee like

Code Name Shift
7 Saad Nafees A - 09:00 17:00
492 Muhammad Nasir Shahzad B - 17:00 01:00
243 Muhammad Tahir C - 01:00 09:00

Roster table structure

code varchar2
name varchar2
Shift date
Remarks varchar2

shift table structure

code varchar2
timein date
timeout date
latetime date
Hdaytime date

Oracle stores both date and time information in date data type, suppose today user change shift timings from 17:00 to 17:30 or user change timein/timeout in attendance form then oracle will store current date with user define timings.

Now this is the main problem which I am facing because whenever you calculate difference between timein and timeout or compare with its roster then output comes wrong because oracle returns total no of hours whenever you minus two dates.

View 11 Replies View Related

SQL & PL/SQL :: FIFO Method Calculation

Jun 11, 2010

I have three table for the stock calculations. The structure are like this

Product_master
product_id number,
product_name varchar2(30),
company_id number(3),
rate_per_unit number(14,4)

Purchase_master
trans_date date
product_id number,
company_id number(3),
quantity number(14,4),
rate_per_unit number(14,4)

Sales_master
trans_date date
product_id number,
company_id number(3),
quantity number(14,4),
rate_per_unit number(14,4)

Purchase_return_master
trans_date date
product_id number,
company_id number(3),
quantity number(14,4),
rate_per_unit number(14,4)

Sales_return_master
trans_date date
product_id number,
company_id number(3),
quantity number(14,4),
rate_per_unit number(14,4)

I need to find out the valuation on particular sales date at FIFO method.

View 22 Replies View Related

SQL & PL/SQL :: Date And Time Calculation

Jun 10, 2011

T1 = 06-Jun-2011 4:00PM
T2 = 10-Jun-2011 11:AM

Calculation is Required.

If at the end of Day Hours of T1 > 6 hours then it should calculate 1 Day.

same with T2. hours of T2(from begining of Day till end Time (11AM), it should again caculate if >6 hours then 1 Day.

remaining will be date calculation. this is how T2 - T1 should give us 5 Days.

Detail
06-Jun-2011 4:00PM to 06-Jun-2011 12:00AM (8 hours > 6 = 1 Day)
06-Jun-2011 12:00AM to 07-Jun-2011 12:00AM = (1 Day)
07-Jun-2011 12:00AM to 08-Jun-2011 12:00AM = (1 Day)
08-Jun-2011 12:00AM to 09-Jun-2011 12:00AM = (1 Day)
09-Jun-2011 12:00AM to 10-Jun-2011 12:00AM = (1 Day)
10-Jun-2011 12:00AM to 10-Jun-2011 11:00AM (11 hrs > 6 = 1 Day)

this is how 5Days calculation is required.

View 1 Replies View Related

SQL & PL/SQL :: Annual Leave Calculation

May 29, 2012

We want to calculate Annual leave the scenerio is as follows

1. Employee service more the one year
2. if joining date is 07-04-2008 than on 07-04-2009 completed one year and on 07-04-2010 completed two years and so on. day and month of date must be the same.

so we need YEAR*14. e.g. if 1 year completed then 1*14 if two years completed then 2*14 and so on. by this we will get the opening of Annual leaves.

We have another table where we entered the leave day by day in whole year, if he avail 10 leaves in first year then 4 will be remaining and we can say it is the closing of first year and opening of second year. so on second year he will entitled 14 more leaves so 14 + 4 = 18 should be opening of next year.In year Caclulation Day and Month must be the same for example 07 day, 04 month for every year. 14 Annual leaves are fix for each year

following are columns for output.

empid, ename, date of joining, sysdate, leave opening, leave avail, closing balance,
1, jone, 29-05-2009, 29-05-2012
2, herry,29-05-2008, 29-05-2012
3, bell, 29-05-2006, 29-05-2012

between two dates (date of joining and system date)

View 1 Replies View Related

PL/SQL :: Calculation On Sql Column Layer

Aug 31, 2012

V: 10.2.0.3

I want to calculate on column-layer of a sql-query:

select a "column1", "column1" + 1

from ...but it does not work...

View 9 Replies View Related

SQL & PL/SQL :: ORA-14551 - Cannot Perform DML Operation Inside Query

Dec 9, 2010

Attempted to execute the Procs below with

Select OTMP_TCIS_RS.Get_UserInfo('EN') from dual; but i get the following error:
ORA-14551: cannot perform a DML operation inside a query.

The intention of the code is to perform an insert into my table based on passing in values via an object into Stored Procedure Apply_Users_Update

Package Definition
create or replace
PACKAGE OTMP_TCIS_RS AS
--1 PROCEDURE Get_UserInfo
PROCEDURE Get_UserInfo(
o_OutCode OUT INT,
i_language IN VARCHAR2);
FUNCTION Get_UserInfo(
i_language IN VARCHAR2)
RETURN NUMBER;
[code]....

View 5 Replies View Related

Server Administration :: How To Perform Database Refresh

Mar 3, 2012

How to perform db refresh.

View 1 Replies View Related

Forms :: WEBUTIL_C_API Perform Functions Of A DLL Coupon

Aug 16, 2011

I'm using WEBUTIL_C_API, to perform functions of a DLL coupon issuer and I try to tax problems.

problems:
1) performs the function and the application closes. The code that does this is below:
FUNCTION FUN_REDUCAO_Z (impressora varchar2) RETURN pls_integer IS
DLL_FUNCAO webutil_c_api.FunctionHandle;
lv_plist webutil_c_api.ParameterList;
param1 webutil_c_api.ParameterHandle;
ret PLS_INTEGER:=0;
BEGIN
[code]....

I am running these functions in the web client.

View 4 Replies View Related

Forms :: How To Perform Search Detail Block

Dec 26, 2011

I have detail block in my form and i need to give option to user to search item in that block.

For example I display 100 items from item master and user need to search particular item by either code or name.

View 6 Replies View Related

PL/SQL :: How To Perform A Pattern Check - Regular Expression

Oct 16, 2012

Is there a way to perform a pattern check on a value ?

For example: 654321HD9

The pattern is 6 numbers, followed by 2 letters, followed by 1 number. The data type for the attribute is a string.

Examples of right or wrong
654321HD9 - correct value
654321HD - wrong value
654321111 - wrong value
HD1111111 - wong value

The pattern has to be as i mentioned above (6 number, 2 letters, 1 number) otherwise its wrong. My pattern does not cover all cases.

select REGEXP_SUBSTR('654321HD9', '[0-9]+[A-Za-z]+[0-9]+') from dual;

View 6 Replies View Related







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