How to manipulate data in multiple rows without using cursor??
Hi all,
I have a form in which there is a push button & 4 text fields.
Push button : Process
Text fields: Year, Month, Financial_To_Year, Financial_From_Date.
In database , there are tables like, CUSTOMER_MASTER, FD_ACCOUNT_MASTER, FD_ACCOUNT_DTL, CUSTOMER_YEARLY_INTEREST, etc.
In table FD_ACCOUNT_MASTER, there are columns, like CUST_CODE, FD_ACCT_NO, FD_AMOUNT, ACCT_OPEN_DT, ACCT_CLOSE_DATE, ACCT_TYPE, INTEREST_RATE, etc.
There are thousands of records in the table.
For Push button : Process , TRIGGER: When button pressed,
I have to do all the process of FD for all the FD_ACCOUNTS at once. Process means i have to calculate Interest for all the accounts, calculate interest monthly, quarterly, yearly and make the FD_Accounts disable after the date of ACCT_CLOSE_DATE is reached, make the accounts renewed , etc all the process.
But to do this process for multiple rows at once, we use cursor, but i don't want to use cursor as i feel its too tedious to do.
Is there any other way , where i do process of multiple records at once without using cursor??
Help me, Thank You.
Oracle Forms Builder 6i.
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
An Update statement certainly can update sets of data instead single row updates:
UPDATE Statement
if you can't do it in a single statement you can use bulk processing as well:
PLSQL 101
cheers
Similar Messages
-
SELECT n. row without using cursors
For example, I retrieved 100 rows after executing a SELECT statement but I want to list only 20th row. How can I do this without using cursors?
The general approach to getting a set of rows would be to do something like
SELECT *
FROM (SELECT a.*, rownum rn
FROM (<<query with ORDER BY clause>>) a
WHERE rownum <= <<max>>)
WHERE rn >= <<MIN>>Depending on the particular requirements, you could also do something like
SELECT *
FROM (SELECT a.*, RANK() OVER (<<ORDER BY clause>>) rnk
FROM <<table>> a
WHERE <<rest of statement>>)
WHERE rnk = 20Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Merging multiple rows without using max group by
Hi guys,
Is there any better way to convert
with
test as
select '001' as id, 'Apple' as name, 'A' as segment1,null as segment2,null as segment3 from dual union all
select '001' as id, 'Apple' as name,null as segment1, 'P' as segment2,null as segment3 from dual union all
select '001' as id, 'Apple' as name,null as segment1,null as segment2, 'L' as segment3 from dual
select * from test
to
select '001' as id, 'Apple' as name, 'A' as segment1,'P' as segment2,'L' as segment3 from dual
without using max and group by?
There are about 5 million records and using max group by is slowing it down by a lot.
It is needed to be done by SQL.
Thank Youwith
test as
select '001' as id, 'Apple' as name, 'A' as segment1,null as segment2,null as segment3 from dual union all
select '001' as id, 'Apple' as name,null as segment1, 'P' as segment2,null as segment3 from dual union all
select '001' as id, 'Apple' as name,null as segment1,null as segment2, 'L' as segment3 from dual
select distinct id, name
, last_value(segment1 ignore nulls) over (partition by id, name order by segment1) as seg1
, last_value(segment2 ignore nulls) over (partition by id, name order by segment2) as seg2
, last_value(segment3 ignore nulls) over (partition by id, name order by segment3) as seg3
from test
;No max or group by, but not necessarily any faster. If you post your actual query, some sample data with expected results, and the additional information requested in the following posts, then someone may be able to provide better suggestions.
When your query takes too long
When your query takes too long ...
How to Post a SQL statement tuning request
HOW TO: Post a SQL statement tuning request - template posting
Regards,
Bob -
How to store data in a file without using DB
Hi all
I want to develop a small application that could contain at most 10000 records, so if it is possible I want to store the data in a file, therefore the installation of the application can be simplified and the users don't need to add a ODBC dataSource in the control panel before running the program.
If the above is not possible. Does anyone know how to use Java to programmatically add a ODBC dataSrouce in the control panel in the Windows Platform?
Thank you very much !
Kind Regards
Edmond1 ) Save the records into a vector and write it to a file. You will have to load all the records when you read the file though.
2 ) Use a dsn-less connection. You do not need to have a dsn set up and you can access a file using the bridge driver:
url = "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ="+file.getPath();
//Obtain the driver for the
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Create the connection
con = DriverManager.getConnection(url, "", "");
//Ensure that the connection allows two way commands
if (con.isReadOnly()) con.setReadOnly(false);
//Create the statement to be executed
stmt = con.createStatement();
//execute the select statement
ResultSet rs = stmt.executeQuery("SELECT * FROM \"Sheet1$\"");
This should work, let me know if it dwosnt -
How to restore data on new iphone without using the initial setup
I bought a new iphone 5s today but the guy in the shop skipped the initial setup to activate the sim meaning I didn't get to restore the data through iCloud from my old phone as the wifi in the shop wasn't working. I have now got home to a wifi connection and have signed into my iCloud account but how do I restore my data? Or how do I get back to the initial setup?
On your phone: Settings>General>Reset>Erase All Content & Settings. You can now restore your previous phone's backup to your new phone.
-
How to Insert data in 3 table without use of join 1table mapped rule define
1.Table SOL_K
A B C D – Columns Name
C D A B –Coulmns Values Defined (Rule --- Defined)
2.SECOND table SIC_K
SIC_ K
A B C D
Kamal Micky NULL MANOJ
3 Table SIC_Mapping
Same Columns A B C D based On Table SOL_K defined rule
I want to insert values(from table SIC K) into table SICMapping Table with the help of first table(SOL_K)(mapped rule)
Required Result SIC_Mapping Table
The output will be come like this.
A B C D — Columns Name
NULL MANOJ Kamal Micky ---- Came based on defined Mapping RuleThis is the forum for issues with the SQL Developer tool. You will get better answers in the SQL and PL/SQL forum.
-
Count the no.of rows without using count function
Hi,
How to count the no.of rows without using the count function?
Thanks,they won't be 100% accurate. You're correct, Bluefrog, but the same goes for doing a count(*) (depending on the size of the table, ofcourse):
the table being queried might be under DML (deletes/inserts), and the next count(*) might give different results.
Both approaches will never be 100% accurate.
But simply selecting num_rows will be much much faster than doing a count(*).
Counting the number of rows always reminds me of this ongoing discussion, by the way:
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:127412348064#14136093079164 ;)
Usually knowing the number of records by approximatly is sufficient, imo. 1000000 or 1000007 records: I don't care, don't need to know that.
I've never needed to know the exact number of records in a table in my code, or been given a requirement that forced me to. -
Splitting comma seperated column data into multiple rows
Hi Gurus,
Please help me for solving below scenario. I have multiple value in single column with comma seperated values and my requirement is load that data into multiple rows.
Below is the example:
Source Data:
Product Size Stock
ABC X,XL,XXL,M,L,S 1,2,3,4,5,6
Target Data:
Product Size Stock
ABC X 1
ABC XL 2
ABC XXL 3
ABC M 4
ABC L 5
ABC S 6
Which transformation we need to use for getting this output?
Thanks in advance !Hello,
Do you need to do this tranformation through OWB mapping only? And can you please tell what type of source you are using? Is it a flat file or a table?
Thanks -
How to insert one table data into multiple tables by using procedure?
How to insert one table data into multiple tables by using procedure?
Below is the simple procedure. Try the below
CREATE OR REPLACE PROCEDURE test_proc
AS
BEGIN
INSERT ALL
INTO emp_test1
INTO emp_test2
SELECT * FROM emp;
END;
If you want more examples you can refer below link
multi-table inserts in oracle 9i
Message was edited by: 000000 -
Procedure to insert data in multiple rows
Hi,
I need a stored procedure which inserts data into multiple rows..
Ex: I need to have 3 columns in Procedure, where col3 has limit in size let's say 500.
If user insert about 1500 in col3, i has to insert first 500 in row1 and 501 - 1000 in row 2 and 1001 - 1500 in row 3.
Can any one help in creating procedure for above scenario.
Thanks in Advance...
Sreecreate table #t (id int, id1 int)
WITH [1-20]
AS
SELECT row_number() over (order by number) rn,number
FROM master..spt_values
WHERE type = 'P'
AND number BETWEEN 1 AND 20
[21-30]
AS
SELECT row_number() over (order by number) rn,number
FROM master..spt_values
WHERE type = 'P'
AND number BETWEEN 21 AND 30
) INSERT INTO #t
SELECT A.number,B.number FROM
[1-20] A JOIN [21-30] B ON A.rn=B.rn
SELECT * FROM #t
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Regarding reading the data from the files without using Stremas
hai to all of u...
here i have a problem where i have to read the data from the files without using any streams.
please guide me how to do this one,if possible by giving with an example
Thanks & Regard
M.RamakrishnaSimply put, you can't.
By why do you need to? -
How to exctract data from a report to use it in a process
Hi! I would like to know how to exctract data from a report to use it in a process. Let's say that I have a report which have following fields: id_person, name_person. And then, I want to make a process which introduce the id_person (from report) into an associative tabel. How can I reffer to the fields from my report?
I was thinking about something like that( this should be the code from my process)
insert into associative_table(id_person)
values(id_person) or
insert into associative_table(id_person)
values(Report_name.id_person) but it doesn't work....
Thank you very much.Another option, use collections.
Create an on load process that loads all the rows you would have in your report into a collection:
begin
HTMLDB_COLLECTION.CREATE_OR_TRUNCATE_COLLECTION(
p_collection_name => 'ASSIGNED_CALENDAR_CONTACTS' );
for x in (SELECT CONTACT_ID, CONTACT_FNAME, CONTACT_LNAME
FROM CONTACT
WHERE InStr( pkg_CalendarMgr.f_FetchContactIDsForDay( TO_DATE( :P3_CALENDAR_DT, 'YYYYMMDD' ), 'OF' ), CONTACT_ID ) > 0 )
loop
htmldb_collection.add_member(p_collection_name => 'ASSIGNED_CALENDAR_CONTACTS',
p_c001 => x.CONTACT_ID,
p_c002 => x.CONTACT_FNAME,
p_c003 => x.CONTACT_LNAME);
end loop;
end;
Then, instead of your report selecting from the table, have it select from the collection, this way your display will match what's in the collection:
SELECT c001, c002 || Chr(32) || c003 CONTACT_NAME, 'Remove' remove
FROM htmldb_collections
WHERE collection_name = 'ASSIGNED_CALENDAR_CONTACTS'
ORDER BY c003, c002
Then you can have a button on the form that steps through the collection, one element at a time and does whatever you want it to. -
How to update and insert the records without using Table_comparison and Map_operation?
Use either join or MERGE see this Inserting, Updating, and Deleting Data by Using MERGE
-
Select extra row without using UNION ALL in pl/sql
Hi,
Can anyone tell me how to select extra row without using UNION or UNION ALL in pl/sql. Actually I want to have my o/p of query as partitioned by designation and ordered by salary and than one extra row which will contain the highest salary in a particular salary. My table has first_name,emp_id,designation and salary column. And I wnt the o/p as.
Mohinish,12212,SI,46000
Ram,11212,SSI,47000
Shyam,12133,SI,48000
Rick,9898,SI,46000
Rocky,12312,SSI,56000
Sariq,23948,SI,43000
Suman,12789,HR,49000
Sampy,12780,SI,46000
Parna,11111,HR,50000
Now the o/p should be.
Mohinish,12212,SI,46000
Rick,9898,SI,46000
Sariq,23948,SI,43000
Shyam,12133,SI,48000
Shyam,12133,SI,48000
Ram,11212,SSI,47000
Rocky,12312,SSI,56000
Rocky,12312,SSI,56000
Suman,12789,HR,49000
Parna,11111,HR,50000
Parna,11111,HR,50000
Thanks in AdvanceYou don't have to do a UNION or UNION ALL in PL/SQL but you would need to in SQL to get the desired output:
with data_recs
as (select 'Mohinish' first_name,12212 emp_id,'SI' designation,46000 salary from dual union
select 'Ram',11212,'SSI',47000 from dual union
select 'Shyam',12133,'SI',48000 from dual union
select 'Rick',9898,'SI',46000 from dual union
select 'Rocky',12312,'SSI',56000 from dual union
select 'Sariq',23948,'SI',43000 from dual union
select 'Suman',12789,'HR',49000 from dual union
select 'Sampy',12780,'SI',46000 from dual union
select 'Parna',11111,'HR',50000 from dual)
select first_name, emp_id, designation, salary from data_recs union all
select s.first_name, s.emp_id, s.designation, s.salary
from (select first_name,
emp_id,
designation,
salary,
row_number() over (partition by designation order by salary desc) high_salary
from data_recs
order by designation, salary) s
where s.high_salary = 1
order by designation, salary;
FIRST_NAME EMP_ID DESIGNATION SALARY
Suman 12789 HR 49000
Parna 11111 HR 50000
Parna 11111 HR 50000
Sariq 23948 SI 43000
Rick 9898 SI 46000
Mohinish 12212 SI 46000
Sampy 12780 SI 46000
Shyam 12133 SI 48000
Shyam 12133 SI 48000
Ram 11212 SSI 47000
Rocky 12312 SSI 56000
Rocky 12312 SSI 56000 -
ADF multiple row selection using checkbox
One of the basic feature missing in ADF 11g is multiple row selection using checkbox (ADF supports multiple row selection by CTRL+CLICK) and business users doesn't like the idea of CTRL+CLICK especially when the volume of click is more. Our requirement is to show the records as selected, on click of checkbox. We implemented multiple row selection by giving a checkbox and on submission, iterate all the rows and filter only selected rows for further processing. The approach works fine,but it is very slow when the volume of data is more, say 10 thousand rows. For 4 thousand records, iterating everything takes more than 200 secs !
Had the multiple row selection been the ADF standard way using CTRL+CLICK, and retrieving the selected rows using method theTable.getSelectedRowKeys() works much faster (completes in millisecs for 4 thousand records). Somehow ADF fetches the selected records much faster this way. Our requirement is on click of the checkbox, the ADF should select the records ( the same way it is doing CTRL+CLICK) and all such selected rows should be retrievable using the ADF method theTable.getSelectedRowKeys()
Is there any way it can be done?
Regards,
Antony.Hi All,
We have implemented the select and select all using check-box and it is working fine. Issue here is the performance is too slow
Assume SelectValue is the VO coulmn for the checkbox to select the values. To filter out the selected rows, we use the following line
Row[] pidRows = pidView.getFilteredRows("SelectValue", Boolean.TRUE);
it is very taking more than 2 minutes if the total number of rows are *4 thousands* and only if 2 rows are selected.
Whereas with the CTRL+CLICK standard approach, ADF has a built in API theTable.getSelectedRowKeys(); to get only the selected rows, and the built in API takes only few milliseconds to get the selected rows. Users are not agreeing to the CTRL+CLICK approach as it is not user friendly. Suggest if there is a way to make the select box to make it work the same way as CTRL+CLICK.
code snippet to do the standard way :
RowKeySet sk = theTable.getSelectedRowKeys();
_logger.info("row count of select "+sk.getSize());;+
Iterator selection =sk.iterator();
EmpVORowImpl empRow = null;
+while (selection.hasNext()) {+
Object rowKey = selection.next();
theTable.setRowKey(rowKey);
rowdata = (JUCtrlHierNodeBinding)theTable.getRowData();
empRow = (EmpVORowImpl)rowdata.getRow();
_logger.info("Emp # "+empRow.getEmpno() +" Emp Name : "+empRow.getEname() +" Is selected ? "+empRow.getisChecked());+
+}+
Maybe you are looking for
-
How do I delete a file from my USB Stick
I have a new MacBook Pro with retina display. I have just put in my USB flash drive which contains some movies (MP4 format). I am unable to even move the files to the trash. When I "double click" I only get options to open/ create alias etc When I ho
-
Using an old iBook as a file server...
Okay. So, right now I'm using an old Apple iBook G3. It's a Dual-USB 800 MHz version. It's running Panther 10.3.9... In the near future (Two months, maybe) I'll be purchasing a new Macbook. I don't want to just pawn off my old mac, or throw it out (E
-
DNG Converter won't recognize Canon Powershot S95 CR2
I've just installed the latest version (6.2) of DNG Converter. When I point it to a small directory (5 files) of .cr2 files from my Canon Powershot S95, it gives me the following message: "The source folder does not contain any supported camera raw
-
New Computer... how to copy music and keep playlist linked?
I have a new computer. Moved (using Windows) the "My Music" folder to a USB drive. When I copy it to the new computer and import the folder, the playlist is not linked. What are the steps to move the library and keep the playlists linked?
-
Photo stream not working on mac
photo stream isnt detected in iphoto! Dont know what to do!