SQL & PL/SQL :: Going Through Record Set In Oracle And Doing Calculations

Jan 10, 2013

I have a set of records what looks similar like this

Caller Friend Call_type Start_time Duration
12345 54321 sms 1/JAN/2013 09:25:11 0
54321 12345 sms 1/JAN/2013 09:35:12 0
13579 97531 sms 1/JAN/2013 09:37:12 0
97531 13579 voice 1/JAN/2013 09:39:12 3:25
12345 54321 sms 1/JAN/2013 09:42:32 0
12345 54321 sms 1/JAN/2013 09:52:45 0
12345 11111 sms 1/JAN/2013 09:53:45 0
54321 12345 sms 1/JAN/2013 10:25:36 0
12345 54321 sms 1/JAN/2013 11:25:34 0
...

What i need to do is to go trough the record set and get output similar to this for every relationship

Caller Friend Call_no avg_sms_response_time
12345 54321 0 15.5min
54321 12345 0 0.5min
12345 11111 0 120.30min
...

The biggest problem at the moment I have is that I don't know how to go trough all record set having to read it in only once. And other is my calculations doesn't work and im not really sure why.

I have attached code as far as I have gotten.

View 7 Replies


ADVERTISEMENT

Get Percentage Calculations?

Jan 21, 2012

I am fairly new to Oracle SQL developer and I am having an issue that may very simple but I just cannot work it out logically for some reason.I am trying to calculate the percentage of sales each employee has made form the total of trades. I have been trying to use the COUNT function but it obviously splits the counts for each employee. I then tried a inline view but couldn't get it to work and also a sub-query and had an issue with "not a single group function" and then "not a GROUP BY expression".

how I can do this? I will also need to add the syntax to another inline view

View 1 Replies View Related

SQL & PL/SQL :: Update New Records - Arithmetic Calculations On Some Variables

Jun 17, 2013

I have a table which is updated with new records in each 15minutes from network. In order to get the accurate information I must do some arithmetic calculations on some variables.

For example, if the value for column A is 10 @9.45AM and 15 for @10AM the real result should be 15-10=5 for 10AM; because the values are cumulative so I need to subtract. Similar to this I have same operations for 9 more attributes in my table as well.

In order to handle this I used view and did necessary operations by using joining table like this (table name is Operations lets say and id is Primary Key)

create view ....
...
from Operations current, Operations prev
where current.datetime(+) = prev.datetime - 1 / 96
and current.id = prev.id

When I use this view, the simple select query takes about 15min since I have 25GB record for this table. What can I use instead of this join and solve cumulative values issue?

View 3 Replies View Related

Application Express :: DateTime Calculations On A Form

Jul 19, 2012

Version of the database you are using: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
Version of Application Express: 4.1.1.00.23

I have a requirement that is driving me stark raving bonkers.

I have a form that a user fills out, it sets the Status to 'Open' and I capture the Date Created On in a hidden field. When someone goes back in to the Form and sets the Status to 'Closed' I capture the Date Closed On in a hidden field. I need to calculate how many hours that it took to close the issue and display it on the form.

I found some javascript that does this

<Code>
<script type="text/javascript">
var msecPerMinute = 1000 * 60;
document.write("msecPerMinute -" + msecPerMinute + "<br />")
var msecPerHour = msecPerMinute * 60;
[code].......

While I can get it to work from dreamweaver I cannot get it to work from APEX. Both of my date fields in my database are defined as:

Type: TIMESTAMP
Fractional Precision: 6
Time Zone: LOCAL TIME ZONE

View 17 Replies View Related

SQL & PL/SQL :: Calculations - Get Same Month From Previous Year Of Selected Date

Sep 20, 2011

i have a requirement to create a query which gets the same month from the previous year of the selected date .

Example : i select SEP-2011 ( as sysdate )

it will return the SEP-2010 as well .

here is the code which works fine with sysdate, dual :

SELECT
TO_CHAR(ADD_MONTHS(SYSDATE,-12),'MON-YYYY') TMLY, TO_CHAR(SYSDATE,'MON-YYYY') TMTY FROM DUAL;

in my schema table Ive got a filed named PERIOD_NAME (varchar2) , which holds date values in ( Mon-YYYY ) format (e.g Sep-2011)

am unable to apply the above code on it , i guess its the data type pf the field .

View 5 Replies View Related

Application Express :: DML Not Updating Fields With Post Calculations?

Jan 9, 2013

I am running APEX 4.0.2.I am having an issue where I have a page item that has a post calculation

My source used is "Always..."
My source type is "Database Column"

I have tried putting the code in the page item under "Post Calculation Computation", as a dynamic action, and as a Computation Process. It displays properly on the form no matter where I put the code, but when I select Apply Changes it is not updating the database. What am I doing wrong? I have provided a sample of the code, and yes the column name is in the database.

CASE
WHEN :P12_NUM_OF_BOOKED_DEALS>0 AND :P12_DATE_1ST_COMPLETE IS NULL THEN '(2) In Process'
ELSE '(D1) Open Draft'
END

View 2 Replies View Related

Forms :: Populating Values To Record Group From Multi Record Datablock

Jul 26, 2012

My procedure proc_ex is in when_validate_item trigger

I have one Multi Record data block in my form with values in its items

I need to Populate multi record block values to one Record Group using

add_group_row,
add_group_column,
set_group_char_cell to populate values to record group

Let us suppose my multi record data block looks like

item1 item2 item3 item4
10 20 50 70
25 15 30 45
45 90 47 38
75 25 85 90
30 56 78 80

how to populate these multi record datablock values to Record Group ???..Eagerly waiting for your Replies

View 3 Replies View Related

Forms :: How To Print Next Record Value In Oracle 10g

Jun 28, 2010

I am using oracle forms10g here i have next button. So when i click the next button it will show the total volumn of record count and each record value for example 1/10 like that.

View 9 Replies View Related

Server Utilities :: How To Associate Header Record To Its Corresponding Detail Record

May 16, 2012

I am loading data file using SQL Loader in TOAD 10.5.1.3 in Oracle 10g using the control file below and loading data into 2 tables post1.thead and post1.tdetl. THEAD contains item level transaction and TDETL is detail level when a transaction has a discount or promo attached to for that item. When the

LOAD DATA
APPEND
INTO TABLE post1.thead
WHEN (1:5) = 'THEAD'
TRAILING NULLCOLS
(file_type POSITION(1:5)CHAR,

[code]....

A particular THEAD value may have 0, 1 or many TDETL corresponding values.below is a sample data file. When the position 21 in the TTAIL has a value of 1 or 2, then we know that there is a promo or discount applicable to the ITEM (THEAD).

THEAD0000000002201109142011091400000000000002091 1 0 -1
TTAIL0000000003000000
THEAD0000000012201109142011091400000000000002091 1 0 -1 20110914-1
TDETL0000000013CMPSPL1004 0 000000010000P0000000000000019990000000000000000200000
TTAIL0000000014000001
THEAD0000000021201109142011091400000000000002091 1 0 -1
TDETL0000000022EMPDSC1005 0 000
TDETL0000000023SCOUP 1006 0 973452 000
TTAIL0000000024000002

What I want to acheive is to accurately reflect a TDETL to its corresponding THEAD, as both THEAD and TDETL are loaded into separate tables. How can we have the 2 records correlated?

View 11 Replies View Related

PL/SQL :: Selecting Single Record From Multiple Record Based On Date?

Aug 26, 2013

I have a table which contains the multiple records for single ID No. Now i have to select single record which contains the latest date. here is the structure Name  

Null Type  ------ ---- ------------ ID_P        NUMBER       NAME_P      VARCHAR2(12) DATE_P      TIMESTAMP(6) Records---------------------1 loosi     22-AUG-13 01.27.48.000000000 PM1 nammi  26-AUG-13 01.28.10.000000000 PM2 kk        22-AUG-13 01.28.26.000000000 PM2 thej      26-AUG-13 01.28.42.000000000 PM 

now i have to select below 2 rows how can write select qurie for this?

1 loosi 26-AUG-13 01.27.48.000000000 PM2 thej  26-AUG-13 01.28.42.000000000 PM

View 4 Replies View Related

Forms :: How To Focus On Current Record In Oracle

Jul 4, 2011

How to focus on current record in oracle forms.

for ex:- I have 10 records in line level.i want to focus my cursor on particular like (5th record) how to possible in form.

Is there any built-in like current_record?

View 4 Replies View Related

Forms ::create History Record For Each Record Whether Updated Or Not

Sep 13, 2011

I have a fairly standard Purchase Order form which contains pre-loaded data (been uploaded from an XML file).When the Purchase Order is processed, the form updates a Price History table only if the Price on the PO_Details changes.The code for updating the price history table is contained in a PRE_UPDATE trigger on the PO_Details Data Block.

No other data changes on the PO_Details table.I now want to change this so that the Price History table is updated even if the price does not change i.e I want to create a history record for each record on the PO_Details irrespective of whether it was updated or not.

Is there an alternative trigger that I can move my code to (ie move it from PRE_UPDATE) to some other trigger that is fired for each PO_Details record even if there is no change.

View 4 Replies View Related

SQL & PL/SQL :: Create A Query That Returns Record By Record A Field

Apr 21, 2010

I have the following case to solve:

Example Table:

Nr_ordPos1Pos2Itemqty
O4018510000107 170,00
O4018520000107 30,00
O40651010000107 500,00
O40651020000107 50,00
O4114510000107 300,00
O31141010000107 50,00
O3114520000107 50,00

I need to create a query that returns record by record a field qty_progr with the cumulate qty considering previous records. The result should be the following:

Nr_ordPos1Pos2Itemqty qty_progr
O4018510000107 170,00 170,00
O4018520000107 30,00 200,00
O40651010000107 500,00 700,00
O40651020000107 50,00 750,00
O4114510000107 300,00 1050,00
O31141010000107 50,00 1100,00
O3114520000107 50,00 1150,00

View 8 Replies View Related

Forms :: Only New Record Have Saved Last Record No Longer Exist

Jun 29, 2013

I create a data block on a table when I am inserting new record only one record have been saved. Last record no longer exist.

View 4 Replies View Related

Forms :: Choose Lov In First Record That Won't Be Display In Second Record Lov

Sep 10, 2012

I have one multi record block in that i have one LOV..If i choose lov in first record that won't be display in second record lov...

View 4 Replies View Related

Forms :: FRM-40508 / ORACLE Error / Unable To INSERT Record

Jan 14, 2013

I have an interface composed of five elements:

1.display_item (primary key)
2-list_item (foreign key) / / dynamic list :this is the cause of the error
3-lis_item (foreign key) / / dynamic list
4-text_item
5-button (insert commit)

when I click the button, an error is displayed:

FRM-40508: ORACLE error: unable to INSERT record.in detail: ora-02291 integrity constraint Violated - parent key not found

Note:

-the elements of two lists already exist in the parent table!!

-I use a block based.

-button

commit_form();

View 17 Replies View Related

Forms :: Oracle Unable To Update Record - Unique Key Violation Error

May 10, 2011

I have the search screen in my form so after searching if i select the row by using the button it will navigate the first tab page that is "gas" screen here if i tried to change the value like update and save the form it is not allowing me to update the value raising the error message "oracle unable to insert the record". if i see the "display error" in menu it is having the select statement with error "unique key violation error ora-00001".

In save button containe "commit_form"

View 15 Replies View Related

Reports & Discoverer :: Multiple Record Printing On Same Line Number In Oracle 10g?

Jun 28, 2013

I want to print two record of emp table in same line number in tabular format report.

For example if i have emp table and I want to print empno,ename,sal columm only,In tabular format report, Two record should print per line. so If emp table have 14 record report should be printed on 7 rows.

so the output in print preview should be like this

EMPNO ENAME SAL EMPNO ENAME SAL
------ ---------- ----------------------------------------------
7369 SMITH 800 7499 ALLEN 1600
7521 WARD 1250 7566 JONES 2975
7654 MARTIN 1250 7698 BLAKE 2850
.
.
.
.

View 1 Replies View Related

Installation :: Can't Record Response File For Oracle Client 11.2.0.3 Windows 32bit

Jan 14, 2013

We are going to upgrade our Oracle client on our clients to 11.2.0.3. But I can not record a resopnsfile with setup.exe. Have Oracle removed this feature?

Here's a dump from setup.exe

There is no possibility to run setup.exe witch -record -destinationfile option:

Preparing to launch Oracle Universal Installer from C:UsersTestAppDataLocal
TempOraInstall2013-01-14_02-12-48PM. Please wait ... Usage:
setup [-options] [(<CommandLineVariable=Value>)*]

Where options include:

-clusterware oracle.crs,<crs version>

Version of Cluster ready services installed.

-crsLocation <Path>

Used only for cluster installs, specifies the path to the crs home locat ion. Specifying this overrides CRS information obtained from central inventory.

-invPtrLoc <full path of oraInst.loc>

Unix only. To point to a different inventory location. The orainst.loc f
ile contains:
inventory_loc=<location of central inventory>
inst_group=<>

-jreLoc <location>

Path where Java Runtime Environment is installed. OUI cannot be run with out it.

-logLevel <level>

To filter log messages that have a lesser priority level than <level>. V alid options are: severe, warning, info, config, fine, finer, finest, basic, gen eral, detailed, trace. The use of basic, general, detailed, trace is deprecated.

-paramFile <location of file>

Specify location of oraparam.ini file to be used by OUI.

-responseFile <Path>

Specifies the response file and path to use.

-attachHome

For attaching homes to the OUI inventory.

-cfs

Indicates that the Oracle home specified is on cluster file system (shared). This is mandatory when '-local' is specified so that Oracle Universal Installer can register the home appropriately into the inventory.

[code]....

Session/Installer variables are specified using:

[session:]varName=value
Ex 1: session:ORACLE_HOME_NAME="OraHome"
Ex 2: ORACLE_HOME_NAME="OraHome"
The lookup order is session:varName then just varName. The session prefix is
used to avoid ambiguity.

Component variables are specified using:

[compInternalName:[Version:]]varName
Ex 1: oracle.comp1:1.0.1:varName="VarValue"
Ex 2: oracle.comp1:varName="VarValue"
The lookup order is compInternalName:Version:varName, then compInternalName:
varName, then just varName.

View 2 Replies View Related

Oracle 11g - Record Query And Time To Fetch Results For A Specific User ID

Jul 22, 2013

I have an application connected to Oracle 11g that sends its own querys to the db based on what the user is clickng on. The applicaiton is connected via one user id and I was wondering, is there a way that I can capture the tiem each query starts, the sql itself, and the amount of time it took to fetch the data?

View 7 Replies View Related

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

Forms :: Insert Record Into Lov Through Oracle Custom Forms?

Oct 8, 2013

I have a LOV in a custom oracle forms.this lov is linked to a record group.

Presently the column on which lov is created does not contain any value.

I want to insert value into the lov through the forms.

I am not able to insert data into it through forms

View 12 Replies View Related

SQL & PL/SQL :: Record Between Seconds

Nov 9, 2011

I have a date column in a table, I need to fetch records from 27:11:11 00:00:10 to 30:11:11 00:00:10 (DD:MM:YY HH:MI:SS). i.e between seconds/min/hrs.

expecting Something like this,

SELECT * FROM TABLENAME WHERE MODEDATE BETWEEN
TO_CHAR('27/11/11 00:00:10','DD-MN-YY HH24:MI:SS') AND
TO_CHAR('30/11/11 01:10:10','DD-MN-YY HH24:MI:SS')

View 6 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 :: Going To Next Record In Loop

May 25, 2011

I have a cursor which I am opening and then looping through. Within this loop I am comparing attributes within this cursor with attributes from another loop that this one is within.

you will see in the IF statements (there are several distinct IF statements within the loop) that there is a check which assesses if the attributes are not equal.

If they are NOT, the value of v_mismatch is set to 1

What I need to do instead of setting this to 1, is to go to the next record in the loop. How can I achieve this?

OPEN c_distMatrix;
LOOP
FETCH c_distMatrix INTO r_dist;
EXIT
WHEN c_distMatrix%NOTFOUND;
--compare each field and update the counter
[code].....

View 5 Replies View Related

SQL & PL/SQL :: Select Record As Specified

May 30, 2012

Based on ACCOUNT_NUMBER column we have to check the GUID data in test table.

for example ACCOUNT_NUMBER =11 as duplicate it has 2 values then only, we need to check the corresponding GUID if any occurence ("9f680174-cb87-4f71-887a-92" and "9f680174-cb87-4f71-887a-91"),
we should select,if not leave it.

CREATE TABLE test
(
GUID VARCHAR2(32 BYTE),
ACCOUNT_NUMBER NUMBER(30),
INDIVIDUAL_ID NUMBER(13)
)

[Code]...

it tried as like as below it's working.

select t2.* from (select distinct t1.guid
from test t1,( select ACCOUNT_NUMBER from test
group by ACCOUNT_NUMBER having count(ACCOUNT_NUMBER

[Code]...

View 15 Replies View Related

PL/SQL :: Last Inserted Record

Aug 7, 2012

I need select last added/inserted records where value = 'test1' and = 'test2' and = 'test3' in column 'NAME' should be one record for each 'test1','test2' ...

aslo..table have column 'DATE_USR' with data_type = timestamp(6)

View 12 Replies View Related

PL/SQL :: How To Get The Record Before Updated

Sep 3, 2012

I have a problem where my record is updated yesterday. How to get the record before updated?

View 4 Replies View Related

PL/SQL :: LAST Record In A Loop?

Aug 27, 2012

in my loop with cursor in a procedure body i am displaying some field values to create a report and after every record i am displaying horizontal line(-------) but i don t want this line to appear after the last record displayed like below,

gfsfsf gsgfsfds gsdgfdg
------------------------------------
edyet gdgtdgt gtdfdfdgd
------------------------------------
dfds hedhgg idudhdh

how can i achieve this within pls/sql procedure body.

View 20 Replies View Related

Limiting Subquery To First Record?

Oct 1, 2007

restricting a subquery's results to the first record. If I use the following:

SELECT WU.DISCREP, M.PART, M.ETA
FROM DB.MICAP M
LEFT JOIN DB.WRITEUPS WU ON M.WRITEUPID=WU.WRITEUPID
LEFT JOIN DB.WUC WUC ON WU.WUCID=WUC.WUCID
WHERE (WU.AIRCRAFTID=205) AND (WU.CORRECTED=0)
ORDER BY WU.PACER DESC, WUC.WUCCODE

I get

-------------------------------------------------------
#5 GEN KICKED OFFLINECABLE02-MAR-08
#5 IDG HARNESS REQUIRES WIREWIRE24-MAY-08
#1 GEN WENT OFFLINECABLE02-MAR-08
AERIAL REFUEL DOORS W/N OPENLINEAR DEL29-SEP-07
AERIAL REFUEL DOORS W/N OPENCHECK VLV30-SEP-07
WEATHER RADAR TILT KNOB HASRADAR COMP05-OCT-07

But I need the highlighted line eliminated. I've tried DISTINCT subqueries in the WHERE M.WRITEUPID IN (SELECT DISTINCT... various experiments with joins, etc.

View 4 Replies View Related







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