Debug stored procedure

hi all, please help in writing this procedure. The cursor should take two variables and those variables are passed by using two different FOR loops. Finally, different tables should be based on IF condition.
(1) there are some errors ( PLS-00103 ) while creating procedure.
(2) is there any other way to write this logic by considering performance as it required to handle millions of records.
===========================================
create or replace procedure udprim
is
v_a number;
v_b varchar2(2000);
cursor c1 (vid varchar2(5), vfeat number) is select gid, listagg(vindex, ',') within group (order by tid) idx from table1 where idarpt=vid and feattype=vfeat group by gid;
begin
for irec in (select distinct idarpt from table2 order by 1) loop
for frec in (select distinct feattype from table3 order by 1) loop
if frec.feattype = 0 then
open c1 (irec.idarpt, frec.feattype);
loop
fetch c1 into v_a, v_b;
exit when c1%notfound;
update table4 set vindex=v_b where gid=v_a;
end loop;
close c1;
elsif frec.feattype = 1 then
open c1 (irec.idarpt, frec.feattype);
loop
fetch c1 into v_a, v_b;
exit when c1%notfound;
update table5 set vindex=v_b where gid=v_a;
end loop;
close c1;
elsif frec.feattype = 3 then
open c1 (irec.idarpt, frec.feattype);
loop
fetch c1 into v_a, v_b;
exit when c1%notfound;
update table6 set vindex=v_b where gid=v_a;
end loop;
close c1;
end if;
end loop;
end loop;
end udprim;
=====================================
regards

You are implementing a cross product and join by PL/SQL loops. That is not what PL/SQL is for.
For millions of records, I'd look at one MERGE statement per target table, i.e.
a) build a query, joining table 2, table 3 and table 1, that identifies the gid of rows in table 4 that need to be updated and the new vindex value
b) use that query in a MERGE INTO table4 statment.
c) repeat for table5 and table6.
That will perform much much better than the "slow by slow" loops of loops of query/update loops.
If you are updating a substantial fraction of rows in the table (more than 10%) you may find it is faster to create a new copy of the data via a "create table as select..." statement and then move it back (possibly by RENAME TABLE or truncate then insert /*+ append */).
Updating is often slow and can be disastrous if you are making the rows much longer (row chaining - you need PCTFREE large enough for there to be room for the new values in the existing data blocks).

Similar Messages

  • Debugging stored procedure in SQL Server 2012

    Hi,
    Please I need your help.
    I used to debug stored procedures in SQL server 2008, 2008 R2. I'm debugging the stored procedure using SQL Server management studio. I just create a break point then I click on the debug button
    and start debugging without any problems.
    I'm talking about my local machine which I have administrator privileges on the machine. My account in the administrators group and I'm assigned in the sysadmin role in SQL server but I couldn't
    debug the stored procedure. When I create a break point and try to debug the stored procedure I'm getting a popup screen saying "To continue debugging, the firewall needs to be configured. Configuring the firewall requires privileges."
    I tried to figure out the issue but unfortunately until now I'm not able to resolve it.
    Thanks. 

    The problem resolved with help of Microsoft support but it was really strange situation.
    First, the following is my environment.
    OS is Windows 8 Pro
    SQL Server 2012
    I did try everything firewall, Anti-Virus and other thing as well. I usually type (local) on the server name TextBox. I did close my Anti-Virus program, turn off windows firewall and run SQL server as administrator but I’m still
    unable to debug.
    I just do one thing and one thing only, changed the (local) on the server name TextBox to the actual server name and everything work fine. I did try that with everything close/open my Anti-Virus program, turn
    off/one windows firewall and still work fine, and I was able to debug any T-SQL in SQL server 2012 but run it as administrator.
    Anyway, I’m happy to back on the road again.
    Thank you every single one of you who try his best to help.
    Cheers.

  • How to debug Stored Procedures on Runtime?

    Is there any way or any tool available using which I could debug stored procedures on runtime ? Please also pass the links if you know any.

    Check out the PL/SQL Developer tool:
    http://www.allroundautomations.nl/plsqldev.html
    You can download a fully functional version for a 30 day trial. Much less expensive than TOAD, and better yet, it actually works (the TOAD PL/SQL debugger in version 8 is so buggy as to render it useless)

  • Debugging Stored Procedures

    Hi friends,
                  I am using [SBO_SP_PostTransactionNotice] for update. is there any possibility to debug this procedure?. If it is possible pls guide me.
    Regards,
    Silambu

    Hi,
               But Update also happening.
    thanks,
    silambu

  • Debug Stored procedure or database trigger by 10g Forms

    Hi,
    I want to debug my table level trigger (On update for each row), I am updating this table by forms. When I debug this form I am unable to watch the database debug.
    Please help me regarding database trigger/function/procedures by debugging forms.

    not possible via forms
    you can debug it on SQL Developer by using manual INSERT Updates commands

  • Which tool is the best to develop stored procedure?

    Hello everyone,
    which tool is the best to develop and debug stored procedure in oracle9i/10g?
    Thanks

    > Now i am using sqlplus to develop procedures. But I can not debug them.
    How do you debug??
    Bad programmers tend to need and use a debugger a lot.
    I learned to program back when you were only allowed 3 compiles and link due to mainframe CPU costs. The 3rd build was the production one. If you could not cut it, you could not become a Programmer. (back then it still carried a lot of meaning and yes, people spoke of Programmers using capitals)
    If you need to debug your code regularly, then you have a more serious problem. A problem of not writing PROPER MODULARISED code. A problem of not tackling programming problems LOGICALLY - by reducing the complex problem into a set of smaller problems and solving each of those in turn.
    Having to trace code step by step, insert break points, and all that... Debugging must be an exception. If it is not, you must seriously consider your programming techniques and better your design skills. Get back to programming 101 fundamentals.

  • Debug messages in Stored Procedure

    is it possible to see the debug messages written in the Stored Procedure when invoking it from WLS.
    using wls 8.1 SP3
    DB :Sybase
    Driver : weblogic.jdbc.sybase.SybaseDriver
    setting debug parameters (
    -Dweblogic.Debug=weblogic.JDBCConn,weblogic.JDBCSQL,weblogic.JTAJDBC
    )is not enough. also using P6Spy does not help here ...

    Yuval Avni wrote:
    is it possible to see the debug messages written in the Stored Procedure when invoking it from WLS.
    using wls 8.1 SP3
    DB :Sybase
    Driver : weblogic.jdbc.sybase.SybaseDriver
    setting debug parameters (
    -Dweblogic.Debug=weblogic.JDBCConn,weblogic.JDBCSQL,weblogic.JTAJDBC
    )is not enough. also using P6Spy does not help here ...Hi. If/when Sybase sends informational messages to the client, a driver will typically
    make them available from the statement or connection or even result set via SQLWarnings.
    Try the getWarnings() methods of those objects.
    Joe

  • How to debug java stored procedures using jdwp with Eclipse IDE?

    I need to debug the java stored procedures loaded in Oracle 9.2.0.6. The java files are loaded into the database using dbms_java.loadjava('-force -debug -verbose -resolve lib/java_stored_procs.jar'); The jar contains .java files and the database resolves and compiles them into .class files. Works fine but I need to debug the code. I am tried of the println method since takes too much and too many iterations.
    My IDE is Eclipse 3.1. I want to use the jdwp for debugging in my IDE. Any one who knows the exact steps?
    Thanks a lot.

    I need to debug the java stored procedures loaded in Oracle 9.2.0.6. The java files are loaded into the database using dbms_java.loadjava('-force -debug -verbose -resolve lib/java_stored_procs.jar'); The jar contains .java files and the database resolves and compiles them into .class files. Works fine but I need to debug the code. I am tried of the println method since takes too much and too many iterations.
    My IDE is Eclipse 3.1. I want to use the jdwp for debugging in my IDE. Any one who knows the exact steps?
    Thanks a lot.

  • SQL Developer Bug: NVL() function error when debug/run stored procedure

    Version:
    SQL Developer: 1.5.3 (build main-5783)
    Oracle DB connected: Oracle9i Enterprise Edition Release 9.2.0.6.0
    Stored procedure code like this:
    procedure search(V_STATUS_IN IN CHAR(1)) is
    begin
    declare
    V_STATUS CHAR(1) := NULL;
    begin
    V_STATUS := NVL(V_STATUS_IN, '%'); -- error line
    end;
    end;
    The stored procedure runs well (I mean no oracle exception) when called through Java code (and in TOAD). But when debug/run in SQL Developer, following error at the error line:
    $Oracle.EXCEPTION_ORA_6502:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    --------------------------------------------------*/

    What parameter are you passing in? It is possible you are trying to cram a multibyte character into a singlebyte container. What are the nls settings for the database and for sqldeveloper?

  • How to debug a stored procedure in sql server 2012 ?

    whenever I do a change to a stored procedure and then run the alter proc again
    after that I place a break point on the exec stored procedure and try to step into the code 
    SQL management studio starts stepping into an older version of the stored procedure (i.e it does not feel the changes I made )
    How to get it to step through the latest version ? 

    Hi,
    Not sure what the exact problem is.. Refer the link below..
    http://stackoverflow.com/questions/8961600/debugging-does-not-show-current-stored-procedure-version
    Regards,
    Brindha.

  • How to debug MySQL stored procedures

    MySQL is a great open source database, but you can make it even better by adding Debugger for MySQL, a tool for debugging stored functions and procedures. Database Journal has a detailed how-to article that explains how to use the software to debug a stored procedure, with plenty of code examples and screenshots that illustrate displaying variables, evaluating expressions, and adding breakpoints.
    This topic first appeared in the Spiceworks Community

    MySQL is a great open source database, but you can make it even better by adding Debugger for MySQL, a tool for debugging stored functions and procedures. Database Journal has a detailed how-to article that explains how to use the software to debug a stored procedure, with plenty of code examples and screenshots that illustrate displaying variables, evaluating expressions, and adding breakpoints.
    This topic first appeared in the Spiceworks Community

  • Debug PL/SQL Stored Procedure

    I am using JDevloper 10.1.3.4. As I am steppping through a servlet in debug and a call is made to a pl/sql stored procedure is it possible to seamlessly (or otherwise) have the debugger step into that pl/sql procedure and then step back into the servlet when exiting? I can run a pl/sql proc in debug seperately but it would be great if it could be done in line with the servlet call.

    thanks a ton! I'll give this a try. Does the dbs_debug_jdwp.connect_tcp(ip,port) have to be in the called procedure?

  • Debugging Java-Stored-Procedure

    Hi,
    is there a way to debug a Java-program that runs as a Stored
    Procedure on Oracle8i usind JDev 2.0 (Build 384) ?
    Thanks for any Help
    J. Helf
    null

    hi,
    i debug java stored procedure in JDeveloper and Oracle 10G, it's working fine. But some time during step-in or step-out process, JDeveloper screen goes blank...
    Is there any suggestion while debugging Java Stored Procedure......
    Regards,
    Pawan Gautam

  • Stored procedure debugging

    How are stored procedures traced in Oracle?
    Informix sets a debug file and then trace on saves everything until the trace off command.
    Is there something similar for Oracle?

    Hi,
    U can generate trace file in Oracle. just in the initialisation parameters u can put SQL_TRACE = TRUE, if its u r own session which will call the stored procedure.
    if it is for some other user or session, Just mention the session id which u can get from v$session.
    this will generate a trace file as o/p with extn trc
    use TKPROF to convert trc file into readable format (.txt, .doc).
    I hope this is going to help...
    -Thanks

  • How to debug noclassdeferror from java stored procedure.

    Hi,
    I am making use of OracleSoapHttpConnection class to call a webservice from a java stored procedure. I used loadjava to load the soap.jar, everything loaded without any error. We can see the "OracleSoapHTTPConnection" class loaded in the all_objects table, still during runtime we get noclassdeferror. I am not sure on how to set classpath for oracle database jvm.
    Many Thanks.
    Chandana

    Please don't post duplicate messages in the forum. You're just cluttering up the place. How to resolve a noclassdeferror for OracleSoapHttpConnection class
    Cheers, APC

Maybe you are looking for

  • How to download the Contents of Spool Requests as one line into Local File

    Hello All, I am running a report (Tcode- MC40)in background and i want to download the output from Spool list . but the issue with me is, in spool the contents are displaying in 2 rows, where as i want to downlod the details in 1 row by filtering som

  • I tunes 6 wont play songs

    im using windows and when i open i tunes and click on a song the diamond will show that the song is playing but it wont play the song. my winamp works fine so the sound is fine on the computer. im stumped... thanks in advance

  • Outputting an error message in MV50AFZ1 when doing a VL01N - getting update

    Hello. I am getting an "update terminate" message due to using a MESSAGE statement in user-exit USEREXIT_SAVE_DOCUMENT_PREPARE . We need to be able to stop a delivery from getting created and alert the user under certain circumstances (if a field is

  • HT3275 Why do I keep getting this error message?

    The backup disk image "/Volumes/Data/Kari Romero's MacBook Pro.sparsebundle" is already in use. Any help would be appreciated!

  • Battery life poor after last OS update

    HI.  I updated my Q10's OS last week to version 10.3.1.1565.  Since then the battery life of the Q10's battery has reduced from lasting from 6am to 4:30pm with some heavy usage to not lasting past 10am with very little (if any) usage.  All apps I run