PL/SQL :: Updating Count Data Based On Records In Another Table
Nov 6, 2013
I have 2 tables
Table 1Name Item DateJon Apples 06/11/2013 00:30:00 hrsSam OrangesNish Apples
Table 2 - Net countName Item CountNish Apples 10Nish Oranges 17Nish BananaSam Apples 10Sam Oranges 1Sam Bananas 1Jon Apples 8
I need to create a job that checks Table 1 for new records added after last run and then add the count in Table 2 accordingly.how to achieve this using PL/SQl or something similar
View 2 Replies
ADVERTISEMENT
Jun 26, 2013
I have two tables lets say TAB_A and TAB_B. I altered table B to include a new column from table A I wrote a merge statement as follows to merge the data
MERGE INTO TAB_AUSING TAB_BON (TAB_A.SECURITYPERSONKEY=TAB_B.SECURITYPERSONKEY)WHEN MATCHED THEN UPDATE SET TAB_A.PPYACCOUNT=TAB_B.PPYACCOUNT;
I know INSERT is for inserting new records UPDATE to my knowledge is to modify currently existing records (loosely) MERGE is one I rarely used, until this particular scenario. The code works perfectly fine, but I was wondering how could I write an update statement? Or in this scenario should I even be using an update statement?
View 4 Replies
View Related
Aug 27, 2013
I have more than 100 records in CSV format. I have to import these records to a particular table which already contains data. I have to do a multiple update at a time, based on the condition . ie., if field1 is '1' then update field2 as 'A0001' and if field1 is '5' then update field2 as 'A0007' . The values are not in an order. Is it possible.
View 1 Replies
View Related
Jun 1, 2010
I am trying to update records in the target table based on the records coming in from source. For instance, if the incoming record is present in the target table I would update them in the target else I would simply insert. I have over one million records in my source while my target has 46 million records. The target table is partitioned based on calendar key. I implement this whole logic using Informatica. Looking at the informatica session log I find that the informatica code is perfectly fine but its in the update part it takes long time (more than 5 days to update one million records). find the TARGET TABLE query and the UPDATE query as below.
TARGET TABLE:
CREATE TABLE OPERATIONS.DENIAL_REGRET_FACT
(
CALENDAR_KEY INTEGER NOT NULL,
DAY_TIME_KEY INTEGER NOT NULL,
SITE_KEY NUMBER NOT NULL,
RESERVATION_AGENT_KEY INTEGER NOT NULL,
LOSS_CODE VARCHAR2(30) NOT NULL,
PROP_ID VARCHAR2(5) NOT NULL,
[code].....
View 9 Replies
View Related
Apr 2, 2010
I want to retrieve the data based on the count.
Sample data
AccountSubAccountDate
11.12-Mar-10
11.23-Mar-10
11.34-Mar-10
11.42-Mar-10
11.56-Mar-10
21.67-Mar-10
21.78-Mar-10
21.82-Mar-10
3210-Mar-10
32.111-Mar-10
32.22-Mar-10
32.313-Mar-10
32.414-Mar-10
32.52-Mar-10
42.616-Mar-10
42.717-Mar-10
What i want is I want the data which account is having more than 5 subaccounts within the last one month. Also need data with other date criteria like last 100 days if more than10 sub accounts. need single query.
Output is :
3210-Mar-10
32.111-Mar-10
32.22-Mar-10
32.313-Mar-10
32.414-Mar-10
32.52-Mar-10
Having more than 8lacks in my database. i wrote the query but it is taking much time and didnt give the data even after 14 hours.
My query is :
select * from table a where account in
(select account from table b where b.subaccount=a.subaccount
and b.date>=sysdate-35
group by b.account having count(b.subaccount)>5)
union
select * from table a where account in
(select account from table b where b.subaccount=a.subaccount
and b.date>=sysdate-100
group by b.account having count(b.subaccount)>10)
how to retrieve the Subaccounts which satisfies my requirements.
View 33 Replies
View Related
Aug 1, 2012
I need to update column of a table with +,- 70,000,000 records.
If I perform an update it lasts......too much and does not finish!
View 6 Replies
View Related
Oct 29, 2012
OS:Solaris
DB:10G
I have a situation where there are multiple records for a join criteria. I am trying to find a way to update a particular column for all the records returned by the join criteria. Example :
Table A
id number
1 1000
2 2000
3 3000
4 4000
Table B
id number
1 9999
1 9999
1 9999
1 9999
1 9999
1 9999
2 8888
2 8888
3 6666
3 6666
Result after update:
Table B
id number
1 1000
1 1000
1 1000
1 1000
1 1000
1 1000
2 2000
2 2000
3 3000
3 3000
update query ? When I use a update statement with where exists it errors out because the query returns more than one row for the join condition.
View 2 Replies
View Related
Jun 28, 2011
When I run the code below It runs very Long. It updates SUSR5 in the TEMPTABLE3 that has 112000 records. If I Change it when c>m to 2 to test. It runs very fast. The value for m is always between 10000 and 12000. That How many times it must loop to update the correct records.
DECLARE
a VARCHAR(50);
c NUMBER:= 1;
m NUMBER;
[Code]....
View 23 Replies
View Related
Mar 11, 2013
We have table, which maintain log record of gl table. I don't know how much data exist in that table but problem is taking too much time while counting whole records.
View 11 Replies
View Related
Jun 15, 2012
query to count the duplicate records and to display duplicate records in a table. Iam using oracle 10g.
View 2 Replies
View Related
Mar 31, 2010
I am having a table with contents like
item id, name
100,s_enter
100,p_enter
200,s_enter
i would like the output to be
Variable name cnt_s_enter=1 (this is for 200)
cnt_s_p_enter =1 (this is becoz 100 is both in s_enter and p_enter)
I am working with basic case but thats not working.
select
sum(case when name='s_enter' then 1 else 0 end),
sum(case when name in (s_enter,p_enter) then 1 else 0 end)
from table
View 3 Replies
View Related
Nov 5, 2009
I have a table that cannot be changed with a field called transaction_reference in the transactions table. This field contains any number of some values in a look-up table called codes.
The table codes contains 'AA', 'BB', 'CC'.
A typical transaction_reference field may look like 'CC BB' or 'AA' or 'AA CC' or 'AA CC BB' - any number, any order.My goal is to get a count of records grouped by another field from the transactions table.
Transactions table example:
transaction_id | transaction_reference | family
---------------------------------------------
1 | AA BB | foo
2 | BB CC | bar
3 | BB | hello
4 | AA CC BB | foo
5 | BB AA | bar
So the results should look like:
family | code | count
foo | AA | 2
foo | BB | 2
foo | CC | 1
bar | AA | 1
bar | BB | 2
bar | CC | 1
hello | AA | 0
hello | BB | 1
hello | CC | 0
If the counts of 0 (like the third to last and last line above) don't show up I'm ok with that.I put together an explode function like this one here but I'm really not sure where to go from here. I can split the transaction_reference, but I'm not sure what to compare it to or how.
I realize that a field in the transactions table for AA, BB, and CC would be ideal, but I can't do that... the powers that be won't let me change the table.
for each exploded segment from transaction_reference
look for it in the codes table
if it exists, add 1 to the count
View 7 Replies
View Related
Nov 4, 2009
CREATE TABLE "SCOTT"."SEATALLOTMENT"
("YEAR" NUMBER(4,0),
"COLLEGECODE" CHAR(4 BYTE),
"COURSECODE" CHAR(3 BYTE),
[Code].....
Now i want to UPDATE reducing the AVAILABLE column by 1 in COURSESEATS table based on common columns collegecode,coursecode for a ROW inserted into SEATALLOTMENT table ,i am confused to what approach i have to follow whether its a procedure or a trigger
CASE:
Here in this case as i insert a row with krcl,cse as college code and course code respectively into seatallotment table the available column in courseseat table for the respective row with mentioned common column must become 59 from 60
View 5 Replies
View Related
Aug 13, 2010
I need to filter records in a datablock based on Yes or No criteria.So i created a listitem(INCLUDE_ZERO_QTY_ITEMS) for that and i am using following code in WHEN-LIST-CHANGED trigger.
BEGIN
IF :XGEC_SW_ITEM_LOAD_ITEM_DETS_V.INCLUDE_ZERO_QTY_ITEMS = 'Y'
THEN
GO_BLOCK ('XGEC_SW_ITEM_LOAD_ITEM_DETS_V');
SET_BLOCK_PROPERTY ('XGEC_SW_ITEM_LOAD_ITEM_DETS_V',
default_where,
'1=1');
[code]....
I am able to filter the records but the list item is not displaying initial value and the value that i am selecting from poplist.
View 1 Replies
View Related
Feb 20, 2012
I have a table with following values in a column
Table A
col1
10
35
20
25
I need to form a query which will take these four values in rownum part and split the records into 4 groups in Table B.
Table B- 90 records (10 + 35 + 20 + 25)
Now for example, the Table B is having emp no, order by ascending and i need to split into 4 groups,
with first group having start value -1 and end value -10
second group - start value -11 and end value-45
third group - start value -46 and end value -65
fourth group - start value - 66 and end value-90
one way i can do it by using union and count, which was a bit tedious if the no. of group goes upto 10.
note that the values in Table A is dynamically changing, so not able to hard code values.
View 2 Replies
View Related
Nov 10, 2010
I need to work on this requirement.
There are FOUR tables ( T1 , T11 & T2, T22) ALL store order information.
One of four conditions are possible for each Supply Reorder Number:
•Both table queries return no records
oPopulate all the output fields with nulls
•T1 returns a record, but T2 returns no records
oPopulate output fields with values from the join of T1 and T11.
•T1 returns no records, but T2 returns one record
oPopulate output fields with values from the join of T2 and T22.
•T1 returns a record, and T2 returns a record
oIf the latest order is in T1, then populate output fields with values from the join of T1 and T11.
oIf order dates are equal from both join results, then populate output fields with values from the join of T1 and T11 .
oIf the latest order is in T2, then populate output fields with values from the join of T2 and T22.
How do we filter the dataset based on result of table join ?
View 1 Replies
View Related
Nov 29, 2012
below requirement..
We have certain records like SQL, PL/SQL, Reports, Forms, OAF etc in a table. We wanted to capture rating for each of these criteria. So we want a form to be displayed dynamically..
SQL 1 2 3 4 (1,2,3,4 represent radio buttons)
PL/SQL 1 2 3 4
Reports 1 2 3 4
Forms 1 2 3 4
OAF 1 2 3 4
If we add another row, XMLP in that table additional radio button should be displayed automatically..
View 4 Replies
View Related
Feb 21, 2011
I have written the following PL/SQL procedure to delete the records and count the number of records has been deleted.
CREATE OR REPLACE PROCEDURE Del_emp IS
del_records NUMBER:=0;
BEGIN
DELETE
FROM candidate c
WHERE empid in
(select c.empid
from employee e,
candidate c
where e.empid = c.empid
and e.emp_stat = 'TERMINATED'
);
[code]....
View 6 Replies
View Related
Feb 1, 2011
i want to insert some data in the transactions table on after insert trigger. Which trigger should i use on form level to accomplish this task.
View 4 Replies
View Related
Mar 19, 2007
I am attempting to update a single field in one table based on a select from two tables. However, I am receiving the following error.
ORA-00933: SQL command not properly ended
The sql I am using is as follows:
update PS_TRNS_CRSE_DTL
set RQMNT_DESIGNTN = 'TRN'
FROM PS_TRNS_CRSE_DTL A, PS_STDNT_CAR_TERM B
where (SELECT A.EMPLID, A.ACAD_CAREER, A.INSTITUTION, A.MODEL_NBR, A.ARTICULATION_TERM, A.TRNSFR_EQVLNCY_GRP, A.TRNSFR_EQVLNCY_SEQ, A.TRNSFR_STAT, A.GRADING_BASIS, A.RQMNT_DESIGNTN, B.STUDY_AGREEMENT
FROM PS_TRNS_CRSE_DTL A, PS_STDNT_CAR_TERM B
[code]......
View 6 Replies
View Related
Sep 14, 2011
In my application i have a requirement as follows.I have 3 tables table1,table2,table3.I have 4 tickets for one license number which is related to client table as follows.
table1
=====
license_nbr(pk) name address
=============== ===== =======
LicNo1 test testing
Table2
=====
ticket number(pk) amountto be paid balance_amount license_nbr(fk table2)
tk1 200 200 0 LicNo1
tk2 300 300 0 LicNo1
tk3 400 400 0 LicNo1
tk4 500 500 400 LicNo1
table3
=====
payment table
ticket_number(fk table2) amount paid payment status license_nbr(fk table1)
tk1 1000 excess paid. LicNo1
so now the excess paid amount to be adjusted for the remaining tickets through tk2 to tk4.and only tk4 should remain with 400 the balance amount should be updated accordinglyand i have a license number which is a foreignkey of client table. writing a procedure for updating the table2 based on the table3.
View 14 Replies
View Related
Nov 3, 2011
I am working on forms 6i. I have one data block based on table EMP.
Datablock-A: Empno, Ename, Sal
I have FIND Screen: Empno, Ename, FIND Button.
I can search the data through FIND Screen and populate data in Datablock A.
I am using below logic to search data through FIND Screen.
When-Button-Pressed(FIND Button): calling 'EXECUTE_QUERY'.
In Pre-query trigger of DatablockA:
copy(:FIND.EMPNO,'BLOCKA.EMPNO');
copy(:FIND.ENAME,'BLOCKA.ENAME');
It's working fine. But below case is failing.
Let us say, if i enter empno 10 (which is not there in database) in FIND Screen --> press FIND Button, it's showing up 'QUERY CAUSED NO RECORDS', Till this point it's working fine;. But after this, if i press CTR+F11 in block A, it's not pulling records. only this case it's not pulling records.
But if i enter something else in FIND Screen, if it returns any data, then if i press CTR+F11,it's pulling all records.
why it's failing to pull records if i try to query data in first case only.
View 2 Replies
View Related
Jun 6, 2012
Im looking for the posibility to update some records using new id with the column values with another id
example
the table contains these records:
id gross net
========================
7 0,1 0,0507749
8 0,2 0,1015499
9 0,5 0,2538748
10 0,83 0,4214
11 0,85 0,4315873
[Code]....
and I would like insert the same gross and net column values of ids 7 to 16 into columns with the ids 40 to 49 in the same order. therefore I would like to obtain the result that I describe below:
id gross net
========================
7 0,1 0,0507749
8 0,2 0,1015499
9 0,5 0,2538748
10 0,83 0,4214
11 0,85 0,4315873
[Code]....
View 4 Replies
View Related
Jul 12, 2012
i'm using the below query to update a VOTER table with over 15million records but it's taking ages to finish. i am using 11gr2 on linux
the query:
MERGE INTO voter dst
USING (
SELECT voterid,
pollingstation || CASE
WHEN ROW_NUMBER () OVER ( PARTITION BY pollingstation
[code]........
View 6 Replies
View Related
Nov 22, 2011
I have made a correlated update statement using rowid. Find my attachment. Its updating all columns which i wanted but issue is that its not updating in 1st commit.
Suppose 6 rows is to be updated, then in 1st commit its updating 1 record, then in 2nd commit its updating 2nd record and so on. And in Toad its showing 6 rows updated in 1st commit, then 5 rows updated in 2nd commit and 1 rows updated in last record. I want that all records to be updated in first commit only.
View 4 Replies
View Related
Jun 7, 2013
Is there a way to export records based on a select distinct into different xls or csv files in oracle? I could be using SQL Developer.
The following will generate 74 unique values which each contain approx 3000 records.
select distinct(telespornr from vingelen2012
View 25 Replies
View Related
Mar 30, 2010
I have a form with two data blocks, one parent, one child block.
The parent is holds mineral lease info while the child holds the mineral owner info, such as addresses and phone numbers. One owner can be in the owner block multiple times (different owner types). The form only displays one owner at a time.
We have a separate master owner table which holds owner address. (We set it up this way because we get electronic info from mineral companies that we have to load each year).
As you tab through the owner block, it checks the FEIN against the master table and pulls updated address info from the master table.
I have a problem in which if an owner is on the lease multiple times, when you tab through the first instance, it pulls in the new address info, but when you go to the next instance, it won't update. If you requery, it seems that the first update actually updated all the owner records on that lease. How can I turn this off?
View 13 Replies
View Related
Jun 28, 2013
i have two tables one as test_master and other one limit master.
test master table structure
ct_id ct_a ct_b ct_C ct_d ct_e...... etc
1 -- -- -- -- --
1 -- -- -- -- --
2 -- -- -- -- --
limit master structure
limit_id ct_a_limit ct_b_limit ct_c_limit ct_d_limit ct_e_limt ..... etc
1 -- -- -- -- -- -- -- --
2 -- -- -- -- -- -- -- --
ct_id and limit_id is match column used for mapping.
now i want the total count of no of records in test_master in which test_master column value not exceed limit master column limit value if any one column exceeds its limit then the same row will be in my count criteria.
how to achieve the same using sql/oracle query.
View 7 Replies
View Related
Jun 19, 2012
Is there any defined record count range for the following ways of bulk insert :
INSERT INTO ABCTEMP SELECT * FROM DEFTEMP;
OR
through a cursor, bulk fetch and bulk insert under a loop.
View 6 Replies
View Related
Feb 14, 2013
i am looking to write a query that will count all NOT NULL queue values in a table that belongs to a certain group, but not sure how to write it. The following is what I have wrote, but just wanted to clarify how to implement count case based on 2 criterias.
select *
count(case when queue is not null then 1 end) over(partition by group) as queue_orders
from table_a;
For example if I have 10 jobs that belong to group 1, but I would like to count all group 1 jobs that have a queue value.
I have no data at the mo, just something that I am trying to start off.
View 10 Replies
View Related