Need suggestions on writing a better IF condition
Hi,
I have a cursor which returns around 15000 rows. I am processing around these records in a cursor FOR loop based on a condition. The condition ( cursor_variable.customer_id IS NULL AND cursor_variable.class = 'A' ) will evaluate to FALSE 99% of the time. Considering this, which of the following will be the better approach?
Case-I
FOR cursor_variable IN cursor
LOOP
IF ( cursor_variable.customer_id IS NULL AND cursor_variable.class = 'A' ) THEN
<do nothing>
ELSE
<do stuff>
END IF;
END LOOPCase-II
FOR cursor_variable IN cursor
LOOP
IF NOT ( cursor_variable.customer_id IS NULL AND cursor_variable.class = 'A' ) THEN
<do stuff>
END IF;
END LOOPNote: I have a 11g database on Solaris
Regards,
Sujoy
Hi,
Blu and Billy, thanks for you invaluable insights.
I understand that doing everything in SQL would be the best choice considering, among others, performance and scalability. However, the "stuff" inside the LOOP seems a little complex to me. I have included the pseudo-code below:
LOOP
select column_a
from multiple tables
where join conditions include results from cursor;
--This section will return a bunch of values (set A and set B, for example)
if column_a = 'A' and cursor_variable.value = 'B' then
--return values from multiple columns(set A)
select multiple columns
from multiple tables
where join conditions include results from cursor;
select column_b
from multiple tables
where join conditions include results from cursor;
--return values from multiple columns(set B)
if column_b = 'C' then
select multiple columns
from multiple tables
where join conditions include results from cursor;
end if;
--return values from multiple columns(set B)
if column_b = 'D' then
select column_c
from multiple tables
where join conditions include results from cursor;
if column_c = 'E' then
select multiple columns
from multiple tables
where join conditions include results from cursor;
end if;
if column_c = 'F' then
select multiple columns
from multiple tables
where join conditions include results from cursor;
end if;
if column_c = 'G' then
call a procedure with input parameters to fetch values;
--using a procedure since there is some complex logic involved and it can be reused
--in other sections of the package
end if;
end if;
end if;
Processing similar to what is done in the IF section above is repeated throughout the package to obtain set C, set D... set N etc
insert SET A,B,C,D...N into a single row spread across into tables A, B and C
--having multiple tables is a business requirement
END LOOPRefractoring the code entirely to SQL would definitley be the right way to go, but I am not sure we have the time to do and test that. In the meantime can you please give your suggestion regarding the original question?
Regards,
Sujoy
Similar Messages
-
Need some suggestions in writing package..
Hi everyone,
I am just asking this question to know a better way than what i am doing.
I have a patient with 2 million rows in it.Is it possible to extract 2 million rows in a text file using UTL_FILE?.I need to extract each patient related data which comes from differnt tables (bigger than patient table) in a comma deleted file.For each patient id i have to query other tables and get the data related to that patient(according to the requirement).For that i need to call different functions against different tables.
Some think like this..
Create or replace procedure XXXX
cursor -----> to get the patient id's
variables ------> declare any other variables
begin
file handler for utl file to write into a file
open cursor
using bulk collect to fetch limited no of rows
For each patient id loop
data1 := function1
data2 := function2
data3 := function3
string : = data1|| data2 || data3|| ....
UTL_FILE.put_line
reset the string
end loop;
end;
My questions are:
Is it OK to call differnt functions for each patient id (2 million patients) are there? is there any better way to do this.
Please give me some suggestions if i need to change any steps that i am following to get better performance.
Thanks
PhaniHello,
It would be strongly advisable to minimise your function calls here.
What I would suggest is: writing one piece of SQL to be looped through with BULK COLLECT, so these:
data1 := function1
data2 := function2
data3 := function3Will be taken care of in the main SQL. Otherwise things will be very, very slow.
Therefore, something like this:
BEGIN
DECLARE CURSOR c_all_data IS
SELECT -- put all your data to be retrieved in this SELECT, that will easily be the quickest and most efficient
FROM tab1
JOIN tab2 ON (...
v1,v2,...
BEGIN
OPEN c_all_data;
LOOP
FETCH c_all_data BULK COLLECT INTO v1, v2, ....... LIMIT 1000;
FOR i IN 1 .. v1.COUNT
LOOP
--write to your file
UTL_FILE...
END LOOP;
EXIT WHEN c_all_data%NOTFOUND;
END LOOP;
CLOSE c_all_data;
END; -
Need Suggestion​: buy ThinkPad Edge E540 or wait for Edge E550?
Hello Everyone,
I need suggestion what to do: buy ThinkPad Edge E54020C6003AGE (i7 4702MQ & GF 740M 2GB) or wait for Edge E550?
http://www.notebookcheck.net/Review-Lenovo-ThinkPad-Edge-E540-20C6003AGE-Notebook.114194.0.html in Germany is price about 830 Euros
I use ThinkPads in last 10 years for study and gaming (R60, SL510, Edge 520) and wish sell my Edge E520 replace it with new one due stuck with old Radeon 6630M drivers (I cannot use a new AMD drivers when I try I getting mostly BOSD errors and latest Official Lenovo driver is from 2012) second reason is that E520 fan cannot be accessed & cleaned on easy way.
In which month Lenovo mostly release new Edges, What is your option are Broadwell CPU + GeForce 840/940M in Edges worth to wait?
In future I try to avoid AMD GPU due poor drivers support.
I know that there is much better notebooks for gaming but I like ThinkPadsTo support it the model you're buying should be equiped with the :
Intel® Dual Band Wireless-N 7260
Intel® Dual Band Wireless-AC 7260
Wireless network adapters and core i5/i7 cpu's . But careful, not all E540s come with the intel wireless card
Just check this and you're good to go. -
Dear gurus,
I need suggestion before learning new module. I did ABAP and having good experience. Now I want to update my skill please suggest me wat I should learn. I want to upgrade my skill only in technical side. Few of them suggested me BI but dont know how good it will be in US market.
Any help will be appreciated.
Regards
DaveHi Aasim,
Even the carrer growth in ABAP is very Good.
IN BW project, there is requirement of ABAPer. So if you are BW+ABAP, you will be getting paid more. Your value would be more.
Now, making a shift, even you want to change from ABAP to BW, you need to take some training. Because BW abap is a bit different thatn general ABAP.
The DW experience is not needed very much.but yes, its better to have knowledge in DW.
I'll suggest you to work for 6 months in ABAP and then take a training in BW. Because its more BW than ABAP in BW.
Hope you would have got some idea.
Please revert for any other questions.
Thanks..
Shambhu -
Need Suggestion for Archival of a Table Data
Hi guys,
I want to archive one of my large table. the structure of table is as below.
Daily there will be around 40000 rows inserted into the table.
Need suggestion for the same. will the partitioning help and on what basis?
CREATE TABLE IM_JMS_MESSAGES_CLOB_IN
LOAN_NUMBER VARCHAR2(10 BYTE),
LOAN_XML CLOB,
LOAN_UPDATE_DT TIMESTAMP(6),
JMS_TIMESTAMP TIMESTAMP(6),
INSERT_DT TIMESTAMP(6)
TABLESPACE DATA
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 1M
NEXT 1M
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
LOGGING
LOB (LOAN_XML) STORE AS
( TABLESPACE DATA
ENABLE STORAGE IN ROW
CHUNK 8192
PCTVERSION 10
NOCACHE
STORAGE (
INITIAL 1M
NEXT 1M
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
NOCACHE
NOPARALLEL;
do the needful.
regards,
SandeepThere will not be any updates /deletes on the table.
I have created a partitioned table with same struture and i am inserting the records from my original table to this partitioned table where i will maintain data for 6 months.
After loading the data from original table to archived table i will truncating the original table.
If my original table is partitioned then what about the restoring of the data??? how will restore the data of last month??? -
Questions you need to answer to receive better help
Questions you need to answer to receive better help... please answer as much as you can, that relates to your problem, back in your original message
If a program is not showing on the Cloud screen, it is most likely because your computer does not meet the specifications
FOR EXAMPLE, Premiere Pro requires a 64bit computer - Not all apps displayed for download | Creative Cloud desktop app, Adobe Application Manager
What error message do you see, or what is the screen you see that does not work? (examples... a BLANK login screen, or a spinning wheel)
A screen shot works well to SHOW people what you are doing - http://forums.adobe.com/thread/592070?tstart=30 for screen shot instructions
Are you using Windows or Mac, and exactly which version? (include "dot" numbers like Windows 8.1 or Mac 10.9.3)
Which brand and version web browser are you using... and have you tried a different web browser?
What Firewall do you use, and have you tried turning it off to download?
What anti-virus do you use, and have you tried turning it off to download?
Has this ever worked before? If yes, do you recall any changes you made to the program, such as adding Plug-ins, etc.?
Did you make any changes to your system, such as updating hardware, printers or drivers; or installing/uninstalling any programs since this last worked?
Are you using an account with Administrator Privileges? Run as Administrator will sometimes help (this EXAMPLE http://forums.adobe.com/thread/969395 is for Encore + "All" Premiere)
What were you doing when the problem occurred?
What other software are you running?
Tell us about your computer hardware. How much RAM is installed? How much free space is on your system (C:) drive?
Hardware Blue Screen shutdowns http://forums.adobe.com/thread/1427408?tstart=0
For Windows, do NOT rely on Windows Update to have current driver information
(you need to go direct to the vendor web site and check updates for yourself)
What is your exact brand/model graphics adapter (ATI or nVidia or ???)
What is your exact graphics adapter driver version?
Have you gone to the vendor web site to check for a newer driver?
ATI Driver Autodetect http://support.amd.com/en-us/download/auto-detect-tool
nVidia Driver Downloads http://www.nvidia.com/Download/index.aspx?lang=en-us
Do you have dual graphics adapters? (common in many "energy saving" laptops)
-http://helpx.adobe.com/premiere-pro/kb/error---preludevideo-play-modules.html
-http://forums.adobe.com/thread/1001579
-Use BIOS http://forums.adobe.com/thread/1019004?tstart=0
-link to why http://forums.adobe.com/message/4685328
-http://www.anandtech.com/show/4839/mobile-gpu-faceoff-amd-dynamic-switchable-graphics-vs-n vidia-optimus-technology/2
-and a Mac Utility http://forums.adobe.com/thread/1017891?tstart=0
JUST FOR MAC USERS
Next link says After Effects, but check YOUR permissions !!!
-http://blogs.adobe.com/aftereffects/2014/06/permissions-mac-os-start-adobe-applications.ht ml
-Mac 10.9.4 and OpenCL issue https://forums.adobe.com/thread/1514717
Mac 10.9.3 workaround https://forums.adobe.com/thread/1489922
-more Mac 10.9.3 https://forums.adobe.com/thread/1491469
-Mac 10.9.3 and CS6 https://forums.adobe.com/thread/1480238
Enable Mac Root User https://forums.adobe.com/thread/1156604
-more Root User http://forums.adobe.com/thread/879931
-and more root user http://forums.adobe.com/thread/940869?tstart=0
Case sensitive hard drive
-http://helpx.adobe.com/creative-suite/kb/error-case-sensitive-drives-supported.html
Troubleshooting guide for Mac freeze
-http://helpx.adobe.com/x-productkb/global/troubleshoot-system-errors-freezes-mac.html
-next link says After Effects, but check YOUR permissions !!!
-http://blogs.adobe.com/aftereffects/2014/06/permissions-mac-os-start-adobe-applications.ht ml
Some links concerning error codes
http://helpx.adobe.com/creative-cloud/kb/failed-install-creative-cloud-desktop.html
A12... download & install error http://forums.adobe.com/thread/1289484
-more A12... discussion http://forums.adobe.com/thread/1045283?tstart=0
U44.. update error http://forums.adobe.com/thread/1289956 may help
-more U44.. discussion http://forums.adobe.com/thread/1275963
-http://helpx.adobe.com/creative-suite/kb/error-u44m1p7-installing-updates-ccm.html
-http://helpx.adobe.com/creative-suite/kb/error-u44m1i210-installing-updates-ccm.html
http://helpx.adobe.com/x-productkb/global/installation-launch-log-errors-creative.html
Repeated updates http://helpx.adobe.com/creative-cloud/kb/updates-repeatedly-applied-cc.html
Code 6 & Code 7 http://helpx.adobe.com/creative-suite/kb/errors-exit-code-6-exit.html
Error 16 http://helpx.adobe.com/x-productkb/policy-pricing/configuration-error-cs5.html
-including DW039 https://forums.adobe.com/thread/1500609
Error 49 https://forums.adobe.com/thread/1491394
Error 50 https://forums.adobe.com/thread/1432237
Errors 201 & 205 & 206 & 207 or several U43 errors
-http://helpx.adobe.com/creative-cloud/kb/error-downloading-cc-apps.html
Muse error http://helpx.adobe.com/muse/kb/unexpected-error-occurred-i-200.html
InDeisgn error http://helpx.adobe.com/indesign/kb/indesign-cc-crashing-launch.html
Sign Out When Sign In http://forums.adobe.com/thread/1450581?tstart=0 may help
-and http://helpx.adobe.com/creative-cloud/kb/unable-login-creative-cloud-248.html
-and 'looping' https://forums.adobe.com/thread/1504792
BLANK Cloud Screen http://forums.adobe.com/message/5484303 may help
-and step by step http://forums.adobe.com/thread/1440508?tstart=0
-and http://helpx.adobe.com/creative-cloud/kb/blank-white-screen-ccp.html
Mac Spinning Wheel https://forums.adobe.com/message/5470608
-Similar in Windows https://forums.adobe.com/message/5853430Does anyone know if there's a way to change the questions themselves? (Frankly, they have to be the most ridiculous security questions I've ever seen. A good security question should be one that you'll have no problem remembering the answer to, even if you're asked years later. To answer one from the third batch, I'd have to make something up, which makes it unlikely I'll remember the answer later. And I certainly don't want to have to write the answers down somewhere.)
-
I want to set up the Time Machine and I would love to use the Time
Capsule but since I already have a wireless router I need suggestions on
what other
external disks Apple could recommend to use with the Time Machine and
how to configure that disk.
A complication that I need to resolve is the fact that I am using Vmware
Fusion to be able to use Windows on my Mac. Now it seems that Time
Machine is not backing up my files
on that virtual Windows without additional configuration and my question
is whether you can advise me here or whether this is only a matter for
the Fusion virtual machine.If you want to use Time Capsule you can.. you simply bridge it and plug it into the existing router.. wireless can be either turned off or used to reinforce the existing wireless.. eg use 5ghz in the TC which is much faster than your 2.4ghz.
You can also use a NAS.. many brands available but the top brands are synology, qnap and netgear readynas series. These will all do Time Machine backups although how well always depends on Apple sticking to a standard. There are cheaper ones.. I bought a single disk zyxel which was rebadged and sold through my local supermarket. It actually works very well for TM at least on Snow Leopard. Major changes were made in Lion and again ML so do not instantly think it will work on later versions. I haven't tried it yet with those versions.
Any external drive can be plugged into the mac. Use the one with the fastest connection or cheapest price according to your budget. USB2 drives are cheap and plentiful. But no where near as fast as USB3 or FW800. So just pick whichever suits the ports on your Mac. Interesting Apple finally moved to USB3 on their latest computers.
TM should exclude the VM partition file.. it is useless backing it up from Mac OS side.. and will slow TM as it needs to backup that partition everyday for no purpose.. TM cannot see the files inside it to backup just the changes.
You need to backup windows from windows. Use MSbackup to external drive.. if you have pro or ultimate versions you can backup to network drive. But MSbackup is a dog.. at least until the latest version it cannot restore the partition without first loading windows. There are about a zillion backup software versions for windows.. look up reviews and buy one which works for you. I use a free one Macrium Reflect which does full disk backups and is easy to restore.. to do incremental backups though you have to pay for it. -
Need suggestion on how to do 3D spinning title animation
Hello all experts,
I need suggestion on how to do 3D rotating title animation. Let me explain what i wanted to do.
The end product is the word WELCOME.
But I want to animate it in such a way that the alphabelt W first appear as nothing from inside the screen to appear in the screen (that means zoom from small to big, is it called zoom out ?). In the process of zooming out, I want the W to have a thickness & it spins very fast along the horizontal X-axis and stops at the screen with the alphbelt W.
Then the whole process repeat with E, and I have WE. It then repeats with L and I have WEL. This whole thing repeats until it forms the word WELCOME.
Any suggestions ? Is there an inbuilt preset for this ?
If not, if I do from scratch, do I need a separate track for each alphabelt ?
Thank you very much.
Cheers.Nick Holmes wrote:
You would have to build this one from scratch, but it's pretty easy.
Work on the whole word first to get the basic movement, then play with the Timing settings in the Inspector. To have the letters do this one after the other use the Sequence setting. Typically you would set it to the number of letters in your word plus 1 -so your welcome should have a Sequence value of 8. You can of course set it to whatever you think looks best.
Give it a go and let us know how you get on. Don't forget to save your new effect!
Thanks Holmes but where do I find the Sequence settings ?
Thanks -
Need suggestion in getting data using JDBC
Hi all need suggestion,
i had a VO corresponding to database table.
when i am try to get the records from that table,
how can i initialize the particular column value to the
corresponding VO setter method.
please do the needful.Hello inform2csr,
Your question is not so clear.
Can you be more precise?
What is VO? -
Need suggestion for designing a BEx report
Hi,
I need suggestions for designing a BEx report.
Iu2019ve a DSO with below structure:
1. Functional Location u2013 Key
2. Maintenance Plan u2013 Key
3. Maintenance Item u2013 Key
4. Call # - Key
5. Cycle u2013 Data Field
6. Planned Date u2013 Data Field
7. Completion Date u2013 Data Field
This DSO contains data like:
Functional -
Plan --- Item -
Call# --- Cycle -
Planned Dt -
Completion Dt
Location
11177 -
134 -
20 -
1 -
T1 -
02-Jan-2011 -
10-Jan-2011
11177 -
134 -
20 -
2 -
T2 -
15-Feb-2011 -
11177 -
134 -
20 -
3 -
T1 -
15-Mar-2011 -
11177 -
134 -
20 -
4 -
M1 -
30-Mar-2011 -
25000 -
170 -
145 -
1 -
T1 -
19-Jan-2011 -
19-Jan-2011
25000 -
134 -
145 -
2 -
T2 -
20-Feb-2011 -
25-Feb-2011
25000 -
134 -
145 -
3 -
T1 -
14-Mar-2011 -
Now Iu2019ve to create a report which will be executed at the end of every month and should display the list of Functional Locations whose Cycles were planned in that particular month, along with the last completed Cycle/Date.
Thus based upon above data, if I execute report at the end of (say) March then report must display:
Functional --- Curr. Cycle --- Planned Date --- Prev. completed Cycle --- Prev Completed Date
Location
11177 -
T1 -
15-Mar-2011 -
--- T1 -
-- 10-Jan-2011
11177 -
M1 -
30-Mar-2011 -
--- T1 -
-- 10-Jan-2011
25000 -
T1 -
14-Mar-2011 -
--- T2 -
-- 25-Feb-2011
Any idea how can I display Previous Completed Cycle and Completion Date (i.e. the last two columns)?
Regards,
Vikrant.hi vikrant,
You can a Cube at the reporting layer which gets data from DSO and which has these 2 extra characteristics completion date and previous cycle along with other chars and keyfigures from DSO.
You can populate these based on your logic in the field routine.
Hope it helps.
Regards
Dev -
Need Suggestion about Solman support & testing E CATT feature
Hi Solman Experts .
I need your Strong suggestion. Actually i am working in ABAP module , I recently joined as a fresher in small company, I got opportunity to go Saudi for "Solman support & testing ,E CATT" in big MNC . Now i need suggestion , If i go and work there in these areas , If i return to India will i get Good Job and Salary here .
Please suggest me. please it my career issue.hi Gafoor,
I too had this kind of oppurtunity and now i am in abhudabi in crm and solman testing. No problem in this , So you can go to saudi as your wish and the future and scope for the solman is very good. So it s reasonable to go saudi .
Regards,
Prabhushankar -
hi....i need suggestion on my problem.i've been given a complete atand-alone java application.my assignment is to make the system,a web-based system so that when we want to make a demo we did not need to bring an installer.just show to from the browser.i thought of using java web start.it's just my opinion.so,i want to hear others opinion......
TqJava Web Start is the solution I would choose. You must bear in mind that a browser is not enough to run Java Web Start - the client PC must have the correct version of the run-time environment (JRE) installed as a minimum - which, I think, is somewhere about a 10-15 megabyte installation.
The run-time environment for end-users is best/readily installed from the http://www.java.com site. Click the "get it now" button and away you go!
Alternatively, I think some PCs actually recognise when you've clicked on a JNLP link and automatically check your to see if you have a version of the JRE and download it if necessary - but I'm not 100% sure if this can be relied upon across all platforms/browsers...
I think you can also program your JNLP file as to where to look for the JRE installer (ie: maybe on your LAN instead of www.java.com), but I haven't researched that one yet. -
Need help in writing data from JSP to excel
Hi ,
I need help in writing the data from JSP to excel.I somehow able to retrieve the data into excel but unable to get the required format.
For eg: The amount should be displayed in 0.00 format .when i am exporting it to excel it is displaying as 0 :( .
I am using the following code in JSP.
"out.print(amt + '\t');"
Would like to know if there is any otherway where in i can get my requirement.
Thanks
TomHi,
Try using format part of the JSTL tag libs.
Syntax :
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatNumber value="40" pattern="$#,##0.00"/>
I need help in writing the data from JSP to excel.I
somehow able to retrieve the data into excelHow do u convert the jsp to excel?
One way to convert the jsp page to excel, is to render it as an excel appl instead of html. Set the content type of the response to application/ms-excel.
response.setContentType("application/ms-excel")Hope this Helps.... -
Need suggestion on Multi currency and Unicode character set use in ABAP
Hi All,
Need suggestion. In one of the requirement I saw 'multi-currency and Unicode character set experience in FICO'.
Can you please elaborate me how ABAPers are invlolved in multi currency as I think this is FICO fuctional area.
And also what is Unicode character set exp.? Please give me some document of you have any.
Thanks
Sreedevi
Moderator message - This isn't the place to prepare for interviews - thread locked
Edited by: Rob Burbank on Sep 17, 2009 4:45 PMUse the default parser.
By default, WebLogic Server is configured to use the default parser and transformer to parse and transform XML documents. The default parser and transformer are those included in the JDK 5.0.
The built-in WebLogic Server DOM factory implementation class is com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl.
The DocumentBuilderFactory.newInstance method returns the built-in parser.
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); -
Need suggestion whether to use ATM or MPLS in DSL implementation
Presently i am working in ISP, and we are providing internet access via simple dialup, ISDN and IVS. and now we want to implement DSL i ve talk with few peoples regarding whether to use ATM or MPLS in DSL implementation but because they are solution providers so i think they are giving me expensive solution. as long as i know about this is,whole world is shifting from ATM to MPLS Technology. ATM implementation cost is very high. so i need suggestion from u because you also have practical exposure.
I believe ATM is soon getting obsolete...
Maybe you are looking for
-
I-Tunes not appearing + crashing system, no solution works so far
General problem description I-Tunes does not appear after program start, and the computer slowly crashes by other programs (explorer, MSN) all not responding anymore after a while Sequence of problems 1. I start up I-Tunes from the program list 2. Mo
-
Errors not enough bandwidth...failed to respond
Hi All. I am on my new shiny Macbook and great it is. But ichat..what a pain in the a.r.s.e. I have tried with a friend in NY and it took ages of him changing proxies disabling firewalls etc...on and on and on. Keep getting insufficient badwidth. I h
-
T-SQL functions & business rules
Why can't I use T-SQL string functions in business rules? For example, REPLACE(my_attribute, 'xyz', '_') from Moscow with money
-
How to open damaged word file?
I m trying to open MS Word Document file, MS word files are showing error message like word 2003 doesn't open file, I have important document file got corrupted, so How to open damaged word file? If you have any answer please help assist me.
-
How do I get the latest version of safari on my macbook pro?