Where to put the sql

Hi,
When I develop a Java software which gets data from the user (for example a Web page) and use them for performing and put the result into the database, according to you is it almost always smarter calling an Oracle stored procedure or a package making the task or can it be usefull to put the logics-sql inside the Java code? For me it's always better to develop a strored procedure to be called, but I'd like to listen to your experience.
Thanks!

If the Java code is to run against a variety of different database products, then it is limited to the lowest common denominator between these products - the basic SQL language.
And unfortunately, such code will use the various database products non-optimally. SQL language implementations differ. Analytical SQL functions available in one product will be different or even non-existent in another.
But in this case, the Java code has little choice - and need to use bare bones SQL.
Usually this is only a problem for ISVs that are developing commercial client products. For most others, we have a single database product as the strategic product for the selected IT architecture.
So in this case it makes sense to use and leverage all the features of that database products. Enabling the Java code to optimally use the database. Enable the database to perform and scale.
In the case of Oracle, that typically means not having Java developers code SQL at all. Not because they are SQL/Oracle idiots (which can be argued). But because of providing a formal and abstract data interface allows far greater flexibility, maintainability and usability.
It enables you to to deal with SQL and SQL related performance inside this interface, without having to touch and recompile a single byte of Java client code.
It enables you to deal with database structure changes via this interface, without having to touch and recompile a single byte of Java client code.
So it makes a LOT of sense to create and use such an interface - not just for Java clients, but all clients. Allowing all clients to share the same interface and be subject to the same validation and business rules in a coherent and consistent fashion.
In Oracle, this interface will be written using PL/SQL packages - and will typically return ref cursors to the clients.

Similar Messages

  • Where to put the commit in the FORALL BULK COLLECT LOOP

    Hi,
    Have the following LOOP code using FORALL and bulk collect, but didnt know where to put the
    'commit' :
    open f_viewed;
    LOOP
    fetch f_viewed bulk collect into f_viewed_rec LIMIT 2000;
    forall i in 1..f_viewed_rec.count
    insert into jwoodman.jw_job_history_112300
    values f_viewed_rec(i);
    --commit; [Can I put this 'commit' here? - Jenny]
    EXIT when f_viewed%NOTFOUND;
    END LOOP;
    commit;
    Thanks,
    - Jenny

    mc**** wrote:
    Bulk collect normally used with large data sets. If you have less dataset such as 1000-2000 records then you canot get such a performance improvent using bulk collect.(Please see oracle documents for this)
    When you update records Oracle acquire exclusive lock for that. So if you use commit inside the loop then it will process number of records defined by limit parameter at ones and then commit those changes.
    That will release all locks acquired by Oracle and also teh memory used to keep those uncommited transactions.
    If you use commit outside the loop,
    Just assume that you insert 100,000 records, all those records will store in oracle memory and it will affect all other users performance as well.
    Further more if you update 100,000 records then it will hold exclusive lock for all 100,000 records addtion to the usage of the oracle memory.
    I am using this for telco application which we process over 30 million complex records (one row has 234 columns).
    When we work with large data sets we do not depends with the oracle basic rollback function. because when you keep records without commit itb uses oracle memory and badly slowdown all other processes.Hi mc****,
    What a load of dangerous and inaccurate rubbish to be telling a new Oracle developer. Commit processing should be driven by the logical unit of a transaction. This should hold true whether that transaction involves a few rows or millions. If, and only if, the transaction is so large that it affects the size constraints of the database resources, in particular, rollback or redo space, then you can consider breaking that transaction up to smaller transactions.
    Why is frequent committing undesirable I hear you ask?
    First of all it is hugely wasteful of rollback or redo space. This is because while the database is capable of locking at a row level, redo is written at a block level, which means that if you update, delete or insert a million rows and commit after each individual statement, then that is a million blocks that need to go into redo. As many of these rows will be in the same block, if you instead do these as one transaction, then the same block in redo can be transacted upon, making the operation more efficient. True, locks will be held for longer, but if this is new data being done in batches then users will rarely be inconvenienced. If locking is a problem then I would suggest that you should be looking at how you are doing your processing.
    Secondly, committing brings into play one of the major serialization points in the database, log sync. When a transaction is committed, the log buffer needs to be written to disc. This occurs serially for multiple commits. Each commit has to wait until the commit before has completed. This becomes even more of a bottleneck if you are using Data Guard in SYNC mode, as the commit cycle does not complete until the remote log is notified as written.
    This then brings us two rules of thumb that will always lead a developer in the right direction.
    1. Commit as infrequently as possible, usually at the logical unit of a transaction
    2. When building transactions, first of all seek to do it using straight SQL (CTAS, insert select, update where etc). If this can't be easily achieved, then use PL/SQL bulk operations.
    Regards
    Andre

  • I changed my iPhone lately but i can't restore my last backup since it keeps saying "itunes could not restore backup because the password was incorrect" but I don't know where to put the password to make it happen... Any suggestions?

    Hey guys,
    I just bought a new iPhone but i can't restore my backup files beacuse it keeps saying "itunes could not restore backup because the password was incorrect" but I really don't know where to put the password to restore it. I really have some files that are meaningful for me so I really need help. Any suggestions anyone?

    Select your iDevice in the iTunes.
    Choose the Summary screen (tab) and scroll to the bottom of the screen.
    Then un-select Encrypt iPhone backup.
    iTunes will then prompt you to “Enter the password to unlock your iPhone backup”, enter the password you set originally.

  • How to put the SQL-statement returned value into the field (as a default)

    Hi,
    I am using Developer/2000 (Forms Designer) under windows 98.
    Please tell me how to put the SQL-statement value (as a default value) into the field before enter-query mode. Noted that I have tried the following ways but still some problems:-
    1) Place the SQL-statement into PRE_QUERY trigger in the form/block level.
    There is a message box which ask 'Do you want to save the changes?'.
    2) Place the SQL-statement before execute enter_query. There is still a
    message box which ask 'Do you want to save the changes?'.
    Any hints? Thanks. Urgent.

    solved it!
    1) Suppress DEFAULT save message
    if form_failure then
    raise form_trigger_failure;
    end if;
    2) Place the default value before enter-query.
    Ref: Title='Default value in query field in ENTER_QUERY mode' in designer forum by CVZ
    form level trigger
    ============
    WHEN-NEW-ITEM-INSTANCE
    =======================
    if :system.mode = 'ENTER-QUERY' then
    :block.item := 'default waarde';
    end if;
    3) Suppress the changes whenever leaving the default field.
    if :block.item is null then
    -- assign statement
    end if;

  • Architecture question...where to put the code

    Newbie here, so please be gentle and explicit (no detail is
    too much to give or insulting to me).
    I'm hoping one of you architecture/design gurus can help me
    with this. I am trying to use good principals of design and not
    have code scattered all over the place and also use OO as much as
    possible. Therefore I would appreciate very much some advice on
    best practices/good design for the following situation.
    On my main timeline I have a frame where I instantiate all my
    objects. These objects refer to movieClips and textFields etc. that
    are on a content frame on that timeline. I have all the
    instantiation code in a function called initialize() which I call
    from the content frame. All this works just fine. One of the
    objects on the content frame is a movieClip which I allow the user
    to go forward and backward in using some navigation controls.
    Again, the object that manages all that is instantiated on the main
    timeline in the initialize() function and works fine too. So here's
    my question. I would like to add some interactive objects on some
    of the frames of the movieClip I allow the user to navigate forward
    and backward in (lets call it NavClip) . For example on frame 1 I
    might have a button, on frame 2 and 3 nothing, on frame 4 maybe a
    clip I allow the user to drag around etc. So I thought I would add
    a layer to NavClip where I will have key frames and put the various
    interactive assets on the appropriate key frames. So now I don't
    know where to put the code that instantiates these objects (i.e.
    the objects that know how to deal with the events and such for each
    of these interactive assets). I tried putting the code on my main
    timeline, but realized that I can't address the interactive assets
    until the NavClip is on the frame that holds the particular asset.
    I'm trying not to sprinkle code all over the place, so what do I
    do? I thought I might be able to address the assets by just
    providing a name for the asset and not a reference to the asset
    itself, and then address the asset that way (i.e.
    NavClip["interactive_mc"] instead of NavClip.interactive_mc), but
    then I thought that's not good since I think there is no type
    checking when you use the NavClip["interactive_mc"] form.
    I hope I'm not being too dim a bulb on this and have missed
    something really obvious. Thanks in advance to anyone who can help
    me use a best practice.

    1. First of all, the code should be:
    var myDraggable:Draggable=new Draggable(myClip_mc);
    myDraggable.initDrag();
    Where initDrag() is defined in the Draggable class. When you
    start coding functions on the timeline... that's asking for
    problems.
    >>Do I wind up with another object each time this
    function is called
    Well, no, but. That would totally depend on the code in the
    (Draggable) class. Let's say you would have a private static var
    counter (private static, so a class property instead of an instance
    property) and you would increment that counter using a
    setInterval(). The second time you enter the frame and create a new
    Draggable object... the counter starts at the last value of the
    'old' object. So, you don't get another object with your function
    literal but you still end up with a faulty program. And the same
    goes for listener objects that are not removed, tweens that are
    running and so on.
    The destroy() method in a custom class (=object, I can't
    stress that enough...) needs to do the cleanup, removing anything
    you don't need anymore.
    2. if myDraggable != undefined
    You shouldn't be using that, period. If you don't need the
    asset anymore, delete it using the destroy() method. Again, if you
    want to make sure only one instance of a custom object is alive,
    use the Singleton design pattern. To elaborate on inheritance:
    define the Draggable class (class Draggable extends MovieClip) and
    connect it to the myClip_mc using the linkage identifier in the
    library). In the Draggable class you can define a function unOnLoad
    (an event fired when myClip_mc is removed using
    myClip_mc.removeMovieClip()...) and do the cleanup there.
    3. A destroy() method performs a cleanup of any assets we
    don't need anymore to make sure we don't end up with all kinds of
    stuff hanging around in the memory. When you extend the MovieClip
    Class you can (additionally) use the onUnLoad event. And with the
    code you posted, no it wouldn't delete the myClip_mc unless you
    program it to do so.

  • I wanted to know explain my problem down package cc2014 where I put the serial number of the problem that I have is that when you open the program asks me start of session in which he put it and go but back inside and it drives me to request the start of

    I wanted to know explain my problem down package cc2014 where I put the serial number of the problem that I have is that when you open the program asks me start of session in which he put it and go but back inside and it drives me to request the start of session and I take 3 weeks or more with this problem if they can support me solve it was the number of seire wearing this being installed at a private university

    Cloud programs do not use serial numbers... you log in to your paid Cloud account to download & install & activate... you MAY need to log out of the Cloud and restart your computer and log back in to the Cloud for things to work
    Some general information for a Cloud subscription
    Log out of your Cloud account... Restart your computer... Log in to your paid Cloud account
    -Sign in help http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html
    -http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
    -http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html
    Does your Cloud subscription properly show on your account page?
    If you have more than one email, are you sure you are using the correct Adobe ID?
    https://www.adobe.com/account.html for subscriptions on your Adobe page

  • Hello there, am new here and very stressed, i have an Imac core i3 which is logging off itself after a few seconds of login, it goes back to the login menu where i put the password. I have tried to repair the os but my pioneer rom is not reading the disk.

    Hello there, am new here and very stressed, i have an Imac core i3 which is logging off itself after a few seconds of login, it goes back to the login menu where i put the password. I have tried to repair the os but my pioneer rom is not reading the disk. I press the :c" button on startup but its not picking up the disk in the rom, i have tried to put the disk in an external rom but same answer, am starting to think that my os disk is bad. Please help me.

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of this exercise is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login. Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    *Note: If FileVault is enabled under Mac OS X 10.7 or later, or if a firmware password is set, you can’t boot in safe mode.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem(s)?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

  • Where to put the Transform.xsl File

    Good evening!
    I am trying to execute a bpel:doXslTransform(xslURI,$a) and i dont know where to put the transform.xsl file for this operation.
    Can anybody tell me?
    Greetz,
    RaRu

    It needs to be in the same folder as the .bpel process - the bpel folder of your project.
    Hope this helps,
    Shanmuhanathan Thiagaraja

  • In HELLO Where doI put the email address of a contact.

    I must be very stupid (admitted) but I cannot get Hello to work for me. Where do I put the email adddress of a person I wish to contcact.

    Hi Brad,
    I really appreciate your taking the effort to help - I must be the greatest of idiots or someting is wrong with my system. I click on the Hello button at the top of my screen and this brings up a panel stating "conversation 1" and below that "Start a conversation" in a blue box. I cannot see the two tabs you refer to "one for chat and other for contacts."
    Unfortunately I am going away for a few days and will not be able to respond, but certainly will when I return.
    Thank you for your interest.

  • JNI where to put the jnilib?

    I have a smal calculating code, and need it fast done, therefore I will use the JNI.
    On MacOSX there is no problem doing this with a dylib, compile the dylib, compile the jnilib put them in the Bundle .. ready to deploy. Easyly done.
    On WIN I get a messsage of unknownsource in the ClassLoader., Runtime. and System. loadlibrary(blah)
    Where do I have to put the blah.jnilib and the dll to get the applikation used of them??
    Must the library path set to get the compiled jnilib run on WIN?? Where do i have to set the path for the jnilib and the dll? DLL in system 32 I guess but where the jnilib???
    Or should i just name the prefix of blah when compiling .dll instead of .jnilib, but then I need to manage the file using on different platforms isn�t so??
    thanks for help

    Windows will find the DLL if it is listed in the PATH environment variable. On Windows XP, I click Start / Control Panel / System / Advanced / Environment Variables. I can then edit the path string which is a semicolon-separated path list.
    If you do not want to mess around with the environment variables, you can allways do it M$-style and squeeze the DLL into c:\windows\system32 amongst the other couple hundreds of DLL's already there.

  • Where to find the SQL text in v$ views?

    Hi All,
    Oracle 11.2.0.3 on RedHat.
    I am trying to find out SQL activity on my database for a very narrow time window. Please see the SQLs I did
    SQL> select distinct user_id, sql_id
      2  from v$active_session_history
      3  where sample_time between to_date('20120704012000','yyyymmddhh24miss') and
      4            to_date('20120704012200','yyyymmddhh24miss')
      5  and user_id = 111 ;
       USER_ID SQL_ID
           111
           111 gjg25k7stx9ba
           111 a8m049aj31b1y
           111 asjw7b7h99w4m
           111 fvffk1aqrb55n
           111 9gskv9b1u7mau
           111 03tsb9pp3h1uj
           111 dm0jppss5z0ay
           111 44n0svyuc000x
           111 16t1tpr7mdqnf
           111 bzpu510tng689
           111 dsqzhqdvzamys
    12 rows selected.
    SQL> select * from v$sqltext where sql_id='16t1tpr7mdqnf' order by piece ;
    no rows selected
    SQL> select * from table( dbms_xplan.display_awr('16t1tpr7mdqnf') ) ;
    no rows selectedI can see the text for all SQLs in v$sqltext, except 16t1tpr7mdqnf. User id 111 is the user used to run our batch processes.
    Where can I find the text for this SQL id 16t1tpr7mdqnf ?
    This SQL has run about 8 hours ago.
    Thanks in advance

    When you say, ASH captures active sessions, does that mean, it only captures "session" information, which may not include details about SQL ?Exactly, it's a snapshot of session level information for active sessions.
    So, session X can be executing sql statement abc123 and be captured by ASH which takes a snapshot of all active sessions every 1 second in V$ACTIVE_SESSION_HISTORY.
    1 in 10 of these active sessions is stored in the repository - DBA_HIST_ACTIVE_SESS_HISTORY (in practice, this 1 in 10 sample is literally as simple as store the active sessions from every 10th second).
    Independently of this, obviously you have the shared pool and V$SQL. If your statements are in here then great.
    Otherwise you have AWR which captures the top N sql from each interval.
    So, as mentioned, perfectly normal to have references to sql ids and sql plan hash values captured in ASH but not AWR.
    One interesting thing here is, sql_exec_id is blank. What does that say? It depends.
    It's likely to be one of two things:
    1. some sort of bug or limitation - there are certain operations and time limits were some of the ASH values get cleared out or don't get cleared out.
    2. occasionally I've seen the ASH information be misleading when it comes to certain recursive operations - one specific example I can think of related to the recursive merge of sql plan baseline metric tracking operations.

  • Where to download the SQL Server 2000 plug-in for Migration Workbench

    Dear All,
    I am new to Migration WorkBench, I want to migrate the SQL Server 2000 database to Oracle 9i. When i start the Migration WorkBench, it requires me to select the plug-in (SQL Server) for the migration source. Before i have download and install the Access plug-in for testing. Can anybody tell me where i can find the SQL Server 2000 Plug-in for migration workbench.
    thx.
    Alan,

    here on OTN; on the same page like all the other plugins:
    http://otn.oracle.com/software/tech/migration/workbench/htdocs/utilsoft.html

  • Where to put the logic!

    Hello everybody!
    I have a big doubt and so does my CIO.
    I'd like to develop Web Services using the facade pattern (Entity + Session). I prefer to put the business logic into the stateless EJB and just go to the database to insert, update or delete records.
    But the boss says it would be better just to develop a pl SQL (Oracle) that has all the business logic into it and just make the call from the Stateless.
    Is there a general approach? What do you recommend?
    Thank you very much!

    Hi,
    in my experience it is better to put the logic in the bean itself.Because if we want to change the database later, it would be very easier.

  • Where to put the url endpoint for changing between enviroments?

    Hello,
    I have created a few jax-ws clients. I am now in development stage, but in the future I will want to put them in preproduction enviroment. where is the best place to put the service urls for calling it and changing in an easy way?
    I came from dot net world, I am used to a web.config file which I can change in hot, does java have something like that?
    Thanks in advance.

    If you are using Spring then these will be helpful to you-
    [http://blog.vinodsingh.com/2008/11/environment-specific-property-with.html|http://blog.vinodsingh.com/2008/11/environment-specific-property-with.html]
    [http://blog.vinodsingh.com/2008/05/webservice-endpoint.html|http://blog.vinodsingh.com/2008/05/webservice-endpoint.html]
    if not then you can devise some thing similar.

  • Where to put the patches ????

    Hi All,
    I have a question about where to keep the patches on weblogic6.1+sp2.
    what is the best practice/way to put the patches on wls6.1/wls8.1 .....iam more or less interested on putting these patches on wls6.1+sp2
    say for some reason, i need 4 patches(which are related to the same problem) ....and i downloaded it from support.bea.com site ...and then ......what is the best practice to place them....where ??
    We have been keeping the 4 patches(or all of them) at CLASSPATH level....but i don't know if it could be a issue for HOT DEPLOYMENT or not ....OR some other issues ?
    please let me know what is the BEST practice and other practices of keeping these patches ????
    thanks alot.
    -sangita

    I put patches on the knees of my denim overalls. I also like to wear a straw hat and carry around a pitchfork. It makes me look like a hick, but people better respect me or I will spear them with my pitchfork!

Maybe you are looking for

  • How to migrate from ascii to unicode (MaxDB 7.5)? loadercli: ERR -25347

    Hi, I use MaxDB 7.5.00.26. (Ok, I know that I should switch to 7.6, however, it is not possilble for some customer restriction for now, but should be possible quite soon). We'd like to migrate a db from ascii to unicode. Based on the infos in the thr

  • Basic Query on CQ 5

    Hi, I have a basic query about CQ5 ,actually i will be getting training on it ,i have the following doubts:- 1)I am a beginner in JAva and related technologies,does one need to be an expert in java to understand CQ5? 2)I have mainly worked on Teamsit

  • Cenvat and pla

    hi, i need to know if 1) cenvat account is receivable or expense? 2) what is cenvat clearing for? 3) what is cenvat on hold for? 4) what is the difference for cenvat account and pla account like pla on hold, plaaed, plabed... point will be given. tha

  • Get matched string problem

    i have a simple question i want to find string which has roman and cryillic letters inside for example '04556888A321212V' (A in roman,V in cryillic) matched case '04556888A321212S' (A in roman,S in roman) nn matched case i want to get first string th

  • Update Access Denied HP OfficeJet Pro 8600

    When I try to run the HP Update utility, I get an error message: Access Denied. That's all it says, and I have no clue as to what it is talking about or how to grant access. Does anyone know the answer to this one?