Development philosphy PL/SQL vs SQL

Hi All
I talked to another fellow developer and both he and me both agrees that our company code base uses too much for loop in the PL/SQL.
(1)He says if the data is in Oracle already better avoid PL/SQL all together and just use SQL statement.
Any suggestions on (1)
This company is really data-sensitive so perhaps in the very beginning they would do it row-by-row because of that.
And this fellow engineer talks about we can use ON ERROR when in cases like that.
Anyone can give an example for using this ON ERROR ?
Or can someone show an re-startable SQL example. For example: when processing 10 million rows and it fails in the middle how we can re-start the process in SQL without re-doing the whole thing?
-Thanks for all your inputs

Hi,
vxwo0owxv wrote:
Hi All
I talked to another fellow developer and both he and me both agrees that our company code base uses too much for loop in the PL/SQL.
(1)He says if the data is in Oracle already better avoid PL/SQL all together and just use SQL statement.
Any suggestions on (1).Doing things in PL/SQL shat should be done in pure SQL is definitely a common mistake. Let's call this Mistake A.
Doing things in SQL that should be done in PL/SQL is also a mistake. Let's call it Mistake B. In practice, Mistake B is much less common mistake than Mistake A, but it's a mistake just the same.
FOR loops are one common way people make Mistake A. SQL was designed for efficiently hanlding sets of rows, for example, executing a query and inserting its result set into a table. A common manifestation of Msitake A is to put the query in a cursor FOR loop, and INSERT the data one row at a time. (Among the mad wags, this is called Slow-by-Slow Priocessing .)
This company is really data-sensitive so perhaps in the very beginning they would do it row-by-row because of that.What does "data-sensitive" mean?
Whatever it means, I don't see how it can justify doing soemthing in a slow, error-prone way.
And this fellow engineer talks about we can use ON ERROR when in cases like that.
Anyone can give an example for using this ON ERROR ?
Or can someone show an re-startable SQL example. For example: when processing 10 million rows and it fails in the middle how we can re-start the process in SQL without re-doing the whole thing?ON ERROR is a SQL*Plus mechanism for trapping errors.
PL/SQL's error handling is better, so this might be an occasion for committing Mistake B. (It would be more accurate to call this Mistake C, since SQL*Plus is not the same as SQL.)
Within PL/SQL, you can use many of the best features of SQL (for example, a multi-row INSERT rather than a FOR loop), and also take advantage of the good features of PL/SQL (such as EXCEPTION handling).

Similar Messages

  • Oracle SQL Developer vs Oracle SQL Developer Migration Workbench

    Gurus,
    Can anybody let me know what's the difference between Oracle SQL Developer vs Oracle SQL Developer Migration Workbench tools.
    I am in the process of Migrating MS-Access Application to APEX. So the example says me to use Oracle SQL Developer Migration Workbench. Is this part of Oracle SQL Developer? If yes, I know SQL Developer is free.
    If not is Oracle SQL Developer Migration Workbench if free?
    Thanks and Regards

    Thank Oracle ;)
    (well, it's the least they can do after you paid big $$$ for the database)
    Regards,
    K.

  • SQL Developer vs. SQL*Plus Performance???

    Hi,
    DB: Oracle 10.2.0.3.0
    SQL Developer: 1.2.0
    SQL*Plus: 10.2.0.3.0
    I am running the same query once in SQL Developer (Response time 10 sec.)
    The same query in SQL*Plus takes over 20 Minutes.
    SQL*Plus is using SQL*Net right?
    Is that the reason?
    Thanks

    Hi,
    how can I check for SQL Developer?
    Does SQL Developer use SQL*Net also?
    I changed the arraysize to 1000
    but does not see any performance gain.
    The query still taking more than 6 minutes.
    The same in SQL Developer runs within 10 seconds!
    Thanks

  • Which PL/SQL developer tool is best to develop the PL/SQL program?

    Hi, all, who know which PL/SQL developer tool is best to develop the PL/SQL program? it is jdeveloper or designer or third party developer tool? please let me know, Thanks!

    To be honest , I have been using only Notepad or
    a simple Textpad ..to this date.
    While these tools may be of help in indenting and beautification of code, I feel you lose your debugging skills and forget the SQL-PL/SQL syntax with them.
    Cheers
    Ashwin N.

  • SQL Developer Connection to SQL Server

    Hi,
    could some body help in connection sql developer connection to sql server 2005 please?
    thanks,
    kamalesh

    Setting Up SQL Developer for MS SQL SERVER 2000
    1) Install/Extract SQL Developer 1.2.1 in C:\Program Files\Oracle
         Making the {$sqldevhome} = C:\Program Files\Oracle\sqldeveloper
    2) Obtain the JDBC SQL SERVER Pluggin (jtds-1.2.2-dist.zip) from:
    http://sourceforge.net/project/showfiles.php?group_id=33291&package_id=25350
    3) Unzip jtds-1.2.2-dist.zip
         Creates:      jtds-1.2.2.jar
                   \x86\SSO\ntlmauth.dll
    4) Copy the jtds-1.2.2.jar into:
    {$sqldevhome}\jlib Directory.
    5) Copy the the ntlmauth.dll dll in the \x86\SSO subdir into:
    {$sqldevhome}\jdk\jre\bin\ntlmauth.dll
    6) In SQL Developer:
         Got Menu "Tools"
                   - Preferences...
                   Expand the "[+] Database
                   Choose "Third Party JDBC Drivers"
                   Click "Add Entry"
                   Then Browse for your copy of "{$sqldevhome}\jlib\jtds-1.2.2.jar"
                   Note: Use the jar filename, not its parent directory for entry.
    7) Restart SQL Developer and try your SQL Server 2000 Connection

  • Problems developing a pl sql web service

    Hello, someone knows how to develop a pl sql web service to retrieve many rows from a table (NOt ONLY ONE RECORD). I need an example of the function or procedure. I'm using JDeveloper 11g and WebLogic 11g.Thanks!.

    I guess this is what you are looking for:
    http://docs.oracle.com/cd/E23943_01/web.1111/e13735/dbws.htm#CHDGJGJI
    You may want to use "REF CURSOR" for your requirement. Store the result set in a "REF CURSOR" in your webservice.
    From the JDeveloper documentation how to use PL/SQL WebServices.
    http://docs.oracle.com/cd/E24382_01/user.1112/e17455/dev_web_services.htm#CHDFHIHB
    May be you want to try using JPublisher to achieve the code for storing the results of a stored procedure
    http://docs.oracle.com/cd/E24382_01/user.1112/e17455/java_database.htm#CACJBBHH
    Arun

  • Connect from SQL Developer to several SQL Server instances

    Our SQL Server has more than one instance, but I see only one instance of them trying to connect from SQL Developer 1.2 to SQL Server. How I should define the connection information? Usually we connect to SQL Server by <hostname>/<instancename> and then the database name as CatalogName (Initial Catalog). In the Oracle world you can give only the hostname, a port number and the database name. How I can convince the SQL Developer to choose one of our SQL Server instances?

    Hi user627927,
    Bug/Enhancement request already logged.
    We have not got this configuration in house, two people have suggested workarounds but we are unable to test them for now. The last person was unable to get these workarounds working, and we have not confirmed them in house.
    Can you get the instances connected through two different ports?
    It would be great if you could confirm either workaround.
    -Turloch
    *1/Suggestion 1 change the URL through SQLDevelopers xml connection store.
    *2/Overload the port field to have instance in the eventual url
    *1/Suggestion 1 change the url through SQLDevelopers xml connection store.
    [Note it is probably simpler to connect a dummy connection through the connection dialog as usual save it (you cannot connect) and then add the instance information rather than having to enter all the information in an unmanaged way.]
    Hi Naveen,
    I had same problem as you and user579801. I managed to resolve it by doing the following.
    1. Locate the file called IDEConnections.xml in the folder where you have installed SQL Developer (eg. c:\sql developer\sqldeveloper\system\oracle.jdeveloper.db.connection.11.1.1.0.11.42.62).
    2. Create the following entries under <connections> tag.
    <connection>
    <URL>jdbc:jtds:sqlserver://\\.\;namedPipe=true;instance=SQLDBNam;</URL>
    <ConnectionName>SQLServer</ConnectionName>
    <user>SQLUser</user>
    <ConnectionType>JDBC</ConnectionType>
    <DeployPassword>false</DeployPassword>
    <JdbcDriver>net.sourceforge.jtds.jdbc.Driver</JdbcDriver>
    <RaptorConnectionType>Microsoft SQL Server</RaptorConnectionType>
    </connection>
    3. Save the file; Close and re-open the SQL Developer and try connecting.
    Hope this will solve your problem. Good luck.
    Regards
    Raja
    *2/Overload the port field to have instance in the eventual url
    This took some figuring out but I cracked it in the end....
    SQLServer tab:
    Hostname: <servername>
    Port: <portnumber>/<databasename>;instance=<instancename>
    so for me the Port field looks like this: 1433/Gaffa;instance=SQL01
    That should now connect to a named instance SQL Server.
    Paul Fairhurst

  • Development in PL/SQL

    hi,
    i am new to this forum, i am an OCA I have done pl/sql in web browser.........
    please let me know is there any application other than web browser for pl/sql queries?????????

    Hi,
    There are two types of architecture in development of pl/sql syntax.
    One is two tier which do not include the web browser. This is achieved by building your applications using SQLDEVELOPER.
    Other is the three tier architecture where you use SQL * Plus to develop and run your application. This is a browser compatible Application.
    Hope this help's you.

  • WHAT IS DIFFERENCE BETWEEN DEVELOPER 2000 AND SQL DEVELOPER?

    Hello Everyone.I am new to oracle and want to know the difference between developer 2000 and sql developer in oracle.Pls?

    Developer 2000 is an application for making webforms that will be served on an Application Server, and accessed by the end users through an applet in their webbrowser.
    SQL Developer is a tool for administrating and manipulating data and structure of your database. Like a GUI version of SQL*Plus, not advisable for end users.
    Regards,
    K.

  • SQL Developer create wrong SQL for creation of Database link

    Hi,
    I tried to create Database link to another machine through SQL Developer. and I got error message saying "Sql not properly ended" or similar.
    I copy-paste the sql to sqlplus shell and I found that the problem came from password part of database link so the generated from SQL Plus is something like:
    SQL> CREATE DATABASE LINK mytest CONNECT TO anotherDB IDENTIFIED BY 1234 USING 'OtherServiceName';
    but it should be
    SQL> CREATE DATABASE LINK mytest CONNECT TO anotherDB IDENTIFIED BY "1234" USING 'OtherServiceName';
    so if I type in the password field
    "1234" which is ****** /6 chars/ the database link was created correctly.
    Could you check and fix this in next release of the SQL Developer?
    Otherwise the Application is very good and far ahead from TORA :)

    Thanks, I didn't notice that for passwords. So it's most definately my problem that the SQL Developer . :)
    Thank you for clarification!
    Offtopic: I am searching for DB Comparison tool which could compare 2 schemas and return me the differences and the sync script. Do you know any /free if possible/? There is such thing in TOAD but I am on Linux and I prefer to use something else. :)
    Thank you in advance

  • Oracle SQL Developer 3.2, SQL*Plus COLUMN FORMAT bug

    SQL*Plus command COLUMN truncates output result in SQL Developer.
    Script in Worksheet:
    column nn format 999
    select level nn from dual connect by level<=10;The Run Script (F5) result contains only 8 lines in Script Output window:
    NN
    1
    2
    3
    4
    5
    6
    7
    8
    Changing column alias:
    select level nn2 from dual connect by level<=10NN2
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    10 rows selected
    The output can contain no data for more formatted columns.
    ===============================================================
    About
    Oracle SQL Developer 3.2.09
    Version 3.2.09
    Build MAIN-09.30
    Copyright © 2005, 2012 Oracle. All Rights Reserved.
    IDE Version: 11.1.1.4.37.59.48
    Product ID: oracle.sqldeveloper
    Product Version: 11.2.0.09.30
    Version
    Component     Version
    =========     =======
    Java(TM) Platform     1.7.0_02
    Oracle IDE     3.2.09.30
    Versioning Support     3.2.09.30

    sqldeveloper64-3.2.09.30-no-jre.zip.
    My jdk now is 1.7.07 x64, Windows 7 x64.
    C:\Java\jdk17\bin>java -version
    java version "1.7.0_07"
    Java(TM) SE Runtime Environment (build 1.7.0_07-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
    Gary Graham wrote:Also, I don't understand what you mean by
    The output can contain no data for more formatted columns.
    Sript:
    col owner format a10
    col table_name format a20
    col column_name format a20
    col comments format a50
    select
       row_number() over(order by column_name) r11,   
       count(*) over() c11,
       owner ow,
       table_name tn,
       column_name cn,
       comments co
    from all_col_comments t
    where owner='SYS' and table_name='INDEX_STATS';
    select
       row_number() over(order by column_name) r,   
       count(*) over() c,
       owner,
       table_name,
       column_name,
       comments
    from all_col_comments t
    where owner='SYS' and table_name='INDEX_STATS';
    select 1 from dual;
    prompt abcThe output truncated after headers of second queryR11 C11 OW                             TN                             CN                             CO                                                                                                                                                        
      1  25 SYS                            INDEX_STATS                    BLKS_GETS_PER_ACCESS           Expected number of consistent mode block gets per row. This assumes that a row chosen at random from the table is being searched for using the index
      2  25 SYS                            INDEX_STATS                    BLOCKS                         blocks allocated to the segment                                                                                                                    
      3  25 SYS                            INDEX_STATS                    BR_BLKS                        number of branch blocks in the b-tree                                                     
      4  25 SYS                            INDEX_STATS                    BR_BLK_LEN                     useable space in a branch block                                                           
      5  25 SYS                            INDEX_STATS                    BR_ROWS                        number of branch rows                                                                     
      6  25 SYS                            INDEX_STATS                    BR_ROWS_LEN                    sum of the lengths of all the branch blocks in the b-tree                                 
      7  25 SYS                            INDEX_STATS                    BTREE_SPACE                    total space currently allocated in the b-tree                                             
      8  25 SYS                            INDEX_STATS                    DEL_LF_ROWS                    number of deleted leaf rows in the index                                                  
      9  25 SYS                            INDEX_STATS                    DEL_LF_ROWS_LEN                total length of all deleted rows in the index                                             
    10  25 SYS                            INDEX_STATS                    DISTINCT_KEYS                  number of distinct keys in the index                                                      
    11  25 SYS                            INDEX_STATS                    HEIGHT                         height of the b-tree                                                                      
    12  25 SYS                            INDEX_STATS                    LF_BLKS                        number of leaf blocks in the b-tree                                                       
    13  25 SYS                            INDEX_STATS                    LF_BLK_LEN                     useable space in a leaf block                                                             
    14  25 SYS                            INDEX_STATS                    LF_ROWS                        number of leaf rows (values in the index)                                                 
    15  25 SYS                            INDEX_STATS                    LF_ROWS_LEN                    sum of the lengths of all the leaf rows                                                   
    16  25 SYS                            INDEX_STATS                    MOST_REPEATED_KEY              how many times the most repeated key is repeated                                          
    17  25 SYS                            INDEX_STATS                    NAME                           name of the index                                                                         
    18  25 SYS                            INDEX_STATS                    OPT_CMPR_COUNT                 optimal prefix compression count for the index                                            
    19  25 SYS                            INDEX_STATS                    OPT_CMPR_PCTSAVE               percentage storage saving expected from optimal prefix compression                        
    20  25 SYS                            INDEX_STATS                    PARTITION_NAME                 name of the index partition, if partitioned                                               
    21  25 SYS                            INDEX_STATS                    PCT_USED                       percent of space allocated in the b-tree that is being used                               
    22  25 SYS                            INDEX_STATS                    PRE_ROWS                       number of prefix rows (values in the index)                                               
    23  25 SYS                            INDEX_STATS                    PRE_ROWS_LEN                   sum of lengths of all prefix rows                                                         
    24  25 SYS                            INDEX_STATS                    ROWS_PER_KEY                   average number of rows per distinct key                                                   
    25  25 SYS                            INDEX_STATS                    USED_SPACE                     total space that is currently being used in the b-tree                                    
    25 rows selected
    R C OWNER      TABLE_NAME           COLUMN_NAME          COMMENTS                                        
    - - ---------- -------------------- -------------------- --------------------------------------------------

  • Developer using ms sql as datasource

    i'm trying to develope a program which retrieve data from ms sql database. the problem is when i use select statement in sqlplus there is no prob!! But when i try to query data in developer form!! problem occur!. it says datatype is not supported! think i know somethin related to rowid is not supported or else!! just that i don;t know the solution!! so please anybody can help me how???
    i'm using developer as the interface and mssql as datasource/database link using odbc tq bye!

    I think you'd better look at MsSQL documentation (BOL Book On Line) which should be available with installation.
    <a href="http://support.microsoft.com/kb/873235">This MS Knowledgebase article</a> might help

  • Able to connect via Oracle SQL Developer, but not sql plus

    Using Oracle 10.2.0.
    I can connect using the TNS connection type in SQL Developer, but cannot do so in SQL PLUS. SQL Plus gives me the error -- could not resolve the connect identifier.
    When I do tnsping USPO_ADHOC, I get:
    C:\oracle\product\10.2.0\client_1\network\admin\sqlnet.ora
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION =
    TNS-12533: TNS:illegal ADDRESS parameters
    So here is my tnsnames.ora file:
    INTL_ADHOC =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.239.162.108)(PORT = 1521))
    (CONNECT_DATA =
    (SID = intl1)
    USSYN_ADHOC =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.239.162.109)(PORT = 1521))
    (CONNECT_DATA =
    (SID = USSYN)
    USPO_ADHOC =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.239.162.107)(PORT = 1521))
    (CONNECT_DATA =
    (SID = uspo)
    Any assistance gratefully appreciated. Thanks.

    I actually did not have that environmental variable, so I added it, but nothing changed.
    I would note that if I do tnsping foo, I get: failed to resolve name.
    If I do tnsping USPO_ADHOC, I get: illegal address parameter.
    In both cases, the output correctly identified the path to my sqlnet.ora file, which is in the same directory as my tnsnames.
    So I would conclude from that, that the system was already able to find my tnsnames file.
    Anyway, here's my sqlnet.ora:
    SQLNET.AUTHENTICATION_SERVICES= (NTS)
    NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
    Thanks again for any ideas!

  • "SQL Developer" vs. "SQL Developer Data Modeler"

    Hi Everybody!
    I'm using SQL Developer and I miss functionalities like re-engeneering of ER Models. As far as I know this is what the "SQL Developer Data Modeler" does. So my question is: Is the "SQL Developer Data Modeler" a complete replacement for "SQL Developer" or do I need both?
    thank you in advance

    Whoooops, sorry, I replied in the wrong thread -.-
    My reply was meant to be in the thread about Designer EA2 and the non-versioned repository import (Import repository from Designer concerning non-versioned applications (EA2)

  • Code runs correctly when compiled by SQL developer but not SQL Plus

    I have a rather large package body I need to deploy and compile ... It's big and complex (I inherited the project). Our it dept is huge and scripts are deployed by the dba team and they seem to only use sql plus. My code deploys and runs fine when compiled in sql developer. Once I compile it from SQL plus it stops working. It runs and using debug statements I can see the values are correct but it no longer inserts the data into the proper tables. I get ZERO errors or warnings when this is compiled in SQL Plus and no errors are generated from the code at run time. I've diffed the extracts of the code from the DB after each deployment and the only difference is the blank lines which SQL Plus strips out when you load the file. Has anyone run into anything remotely similar and if so how did you solve it? I've tried modifying the code to no avail, adding in comments to preserve the white space makes no difference. The thing that really kills me is that there is no error at all.

    Ok this is the problem area.... vReplyMessage is a clob. I've replaced it in this section of processing with a varchar2(32000). And now it works. I still would like to know why though. Nothing is changed when I load it though sqlplus or sql developer but this line " update swn_recip_response_t set SWN_RECIP_RESPONSE = vTextReply where notification_id = v_notification_id; " would never execute with the clob. Logging showed that the clob had the correct value though. I am puzzled.
    begin
    call_SWNPost('http://www.sendwordnow.com/usps/getNotificationResults',vMessageText, vReplyMessage, v_status_code, v_status_phrase, '');
    exception
    when others then
    raise eJavaException;
    end;
    vTextReply := dbms_lob.substr( vReplyMessage, 32000, 1 );
    if (vDebug) then
    update PEMS_PROD_2.SWN_POST_LOG set response = 'notif_id == '|| v_notification_id || 'status code == '|| v_status_code|| ' '||vTextReply where log_pk = vLogPK;
    commit;
    end if;
    IF v_status_code = 200 then
    v_has_error := 'N';
    ELSE
    v_has_error := 'Y';
    END IF;
    -- we handle all exceptions below in case something goes wrong here.
    -- this area can die silently.
    vTextReply := replace(vTextReply,'<getNotificationResultsResponse xmlns="http://www.sendwordnow.com/usps">', '<getNotificationResultsResponse xmlns:xyz="http://www.sendwordnow.com/usps">');
    begin
    insert into swn_recip_response_t(notification_id) values (v_notification_id);
    exception
    when others then
    if (vDebug) then
    err_num := SQLCODE;
    err_msg := SUBSTR(SQLERRM, 1, 100);
    insert into PEMS_PROD_2.SWN_POST_LOG (LOG_PK, create_date, REQUEST, notification_id) values(pems_prod_2.swn_post_log_seq.nextval,sysdate,
    'err_num - '||to_char(err_num)|| ' error_msg - '|| err_msg, v_notification_id);
    commit;
    else
    null;
    end if;
    end;
    commit;
    begin
    update swn_recip_response_t
    set SWN_RECIP_RESPONSE = vTextReply
    where notification_id = v_notification_id;
    exception
    when others then
    if (vDebug) then
    err_num := SQLCODE;
    err_msg := SUBSTR(SQLERRM, 1, 100);
    insert into PEMS_PROD_2.SWN_POST_LOG (log_pk, create_date, REQUEST, notification_id) values(pems_prod_2.swn_post_log_seq.nextval,sysdate,
    'err_num - '||to_char(err_num)|| ' error_msg - '|| err_msg, v_notification_id);
    commit;
    else
    null;
    end if;
    end;
    commit;
    -- parse through the XML document and update the notification and recipient records
    -- parse the clob into an xml dom object
    begin
    vReplyMessage := vTextReply;
    ...

Maybe you are looking for