My pl/sql procedure works; I'm just looking for someone to review it

Hi All,
I wrote the below procedure to be executed via APEX (inside the APEX_PLSQL_JOB.SUBMIT_PROCESS wrapper).
It works fine, but I'm not a programmer per se and am just curious if one of the veterans on this forum could review it
and just tell me if it looks like I followed proper standards/procedures etc. or make any suggestions on how I can be more efficient etc.
The purpose of the procedure is to update Oracle Applications translations tables with language-translated values that we have
accumulated from our global workforce. It's pretty simple - just a big find and replace exercise - replacing english values in the apps
tables with translated values. Oracle's '_TL' tables are designed for this purpose and I'm not updating any primary or foriegn keys.
I don't know the exact update statement or instance at the time of execution and hence the need for dynamic SQL and a DB link.
Again, there are no issues (yet) - everything is working fine, I'm just interested in having someone review it and offer me some feedback.
thanks in advance,
John
create or replace
procedure GSE_UPDATE_TL_TABLES (l_instance IN varchar2, l_app_job IN number)
IS
l_tname  varchar2(30);
l_column_name VARCHAR2(30);
l_col_value VARCHAR2(4000);
l_eng_value VARCHAR2(4000);
l_language VARCHAR2(4);
i number;
l_query VARCHAR2(4000);
l_messages dbms_output.chararr;
l_numlines integer := 1000; -- retrieves max 1000 messages from the buffer
l_rows_updated number := 0;
l_rows_processed number;
CURSOR TABLES_CUR IS
SELECT TABLE_NAME, COLUMN_NAME, COLUMN_VALUE, eng_value, LANGUAGE FROM GSE_LNG_STRINGS WHERE COMPLETION_STATUS = 'Y'; ---This table is our repository of translations
and includes the english value, the translated values, the language code and the table and column names that will be updated.
BEGIN
DBMS_OUTPUT.ENABLE(1000000);
delete from gse_update_tracking;  ---I'm using this table to track real-time progress and to update a progress status bar in APEX.
commit;
open tables_cur;
LOOP
fetch tables_cur into l_tname, l_column_name,l_col_value, l_eng_value, l_language;
EXIT WHEN tables_cur%NOTFOUND;
BEGIN
EXECUTE IMMEDIATE
'Update ' ||l_tname||'@'||l_instance||' set ' ||l_column_name|| ' = q''['||l_col_value||']''  where ' ||l_column_name|| ' = q''['||l_eng_value||']'' and language = '''||l_language||'''';
l_rows_updated := (l_rows_updated + sql%rowcount);
insert into gse_update_tracking (counter) values (1);
commit;
exception
  when dup_val_on_index then
l_query := 'Update ' ||l_tname||'@'||l_instance||' set ' ||l_column_name|| ' = q''['||l_col_value||']''  where ' ||l_column_name|| ' = q''['||l_eng_value||']'' and language = '''||l_language||'''';
DBMS_OUTPUT.PUT_LINE('This query caused DUP_VAL_ON_INDEX exception: '||l_query);
when others then
l_query := 'Update ' ||l_tname||'@'||l_instance||' set ' ||l_column_name|| ' = q''['||l_col_value||']''  where ' ||l_column_name|| ' = q''['||l_eng_value||']'' and language = '''||l_language||'''';
DBMS_OUTPUT.PUT_LINE('This caused an undefined exception: '||l_query);
end;
End Loop;
l_rows_processed := tables_cur%rowcount;
update gse_lng_jobs set rows_processed = l_rows_processed, rows_updated = l_rows_updated where job_id = l_app_job;
close tables_cur;
begin
dbms_output.get_lines(l_messages, l_numlines);
for i in 1..l_messages.count
loop
insert into gse_lng_update_exceptions(id, text, Job) values(i, l_messages(i), l_app_job);
commit;
end loop;
end;
END;

Hoek, davidp 2, Tubby, rp0428 et al.,
I think I'm making progress. I'm researching and trying to incorporate your suggestions.
I worked through the examples of error logging here: http://www.oracle.com/technetwork/issue-archive/2006/06-mar/o26performance-096310.html. I'm not sure if this will work for me though since I'm updating many tables and not just one. So it seems I would need to run this for every table that I'm updating?
BEGIN
        DBMS_ERRLOG.CREATE_ERROR_LOG('[table_name]');
END;
Otherwise, this is the current state of things:
create or replace
procedure gse_lng_test_1 (p_table varchar2, p_column varchar2) *--using proper parameter names prefixed with 'p' to distinguish from local variables*
IS
i number;
l_query VARCHAR2(4000);
l_messages dbms_output.chararr;
l_numlines integer := 1000; -- retrieves max 1000 messages from the buffer
l_rows_updated number := 0;
l_rows_processed number;
BEGIN
DBMS_OUTPUT.ENABLE(1000000);
commit;
l_query := 'Update ' ||p_table||' set ' ||p_column|| ' = :newval where '||p_column|| ' = :engval and language = :lang' ; *--build the string once in a local variable with bind variables. Table names and column names are passed via parameters*
for c2 IN (SELECT TABLE_NAME, COLUMN_NAME, COLUMN_VALUE, eng_value, LANGUAGE FROM GSE_LNG_STRINGS WHERE COMPLETION_STATUS = 'Y' and table_name = p_table and column_name = p_column) *--using implicit cursor instead of explicit cursor*
LOOP
BEGIN
EXECUTE IMMEDIATE l_query USING c2.eng_value, c2.column_value, c2.language; *--execute immediate with bind variables*
exception
  when dup_val_on_index then
  dbms_output.put_line('this query caused a dup_val_on_index: '||SQLERRM||' - '||l_query); *--include SQLERRM in message*
when others then
dbms_output.put_line('this query caused an exception: '||SQLERRM||' - '||l_query); *--include SQLERRM in message*
end;
commit;
end loop;
end;Now that the table names and column names are in parameters, I am calling this from APEX as follows:
Begin
for c1 in (select distinct table_name, column_name from gse_lng_strings)
LOOP
gse_lng_test_1 (p_table=> c1.table_name, p_column=>c1.column_name);
end loop;
end;The one thing I need to do is to get a status of the number of rows processed and updated so I can report back to APEX realtime with a jquery counter plugin that I'm using. That was the reason I was inserting records into a dummy table (gse_update_tracking) before. It worked ok but I realize it was a clumsy approach. I'm not to sure how to accomplish that since I don't think I can access sql%rowcount while the loop is running. Is that correct and if so, are there any other options?
I know I still need to deal with my exception handling and I would like to use the DML error logging if at all possible.
Overall though I feel like it's much cleaner and more manageable. Hopefully it's looking better?
thanks again for the education - I really appreciate it,
John

Similar Messages

  • SQL Procedure working when run manually, not running from sql server agent

    I have a procedure that runs fine using the execute command in SSMS, however putting the same command in a job gives the following error.
    line 9, character 9, unexpected end of input
    The code takes a very long XML string in UTF-8 encoding and puts it into a single nvarchar(max) cell. Then puts this string into a XML cell in a different table, allowing me to query the individual parts of the XML code using the nodes function. I cannot put
    the data directly into a nvarchar cell due to encoding differences.
    I can't reproduce the string here as it is very very long.
    I'm just looking for ideas really as to where it might be going wrong.
    Here is what I know so far:
    The procedure runs without issue when executed manually
    I have checked permission issues, and that doesn't seem to be the problem. The agent runs under my own account and I am a sysadmin on the database
    I split the procedure into seperate parts to locate exactly where the problem is occuring. Once again the seperate procedures run fine when executed manually but an error occurs when run through SQL Server agent.
    When the query is run seperately through SQL Server Agent it gives a slightly different error. This leads me to believe it is an encoding issue. However I am getting the XML from a webpage and I can't change the encoding on the webpage.
    line 1, character 38, unable to switch the encoding
    I know this is a long shot since you can't replicate the issue but if anyone could give an idea as to where to start looking for an answer, it would be greatly appreciated.

    Here's how I'm taking the XML data and putting it into an nvarchar(max) column (Column Name TEXT):
    Select @url = 'http://....'
    EXEC @hr=sp_OACreate 'WinHttp.WinHttpRequest.5.1',@win OUT
    IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
    EXEC @hr=sp_OAMethod @win, 'Open',NULL,'GET',@url,'false'
    IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
    EXEC @hr=sp_OAMethod @win,'Send'
    IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
    INSERT #TextData(TEXT)
    EXEC @hr=sp_OAGetProperty @win,'ResponseText'
    IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
    EXEC @hr=sp_OADestroy @win
    IF @hr <> 0 EXEC sp_OAGetErrorInfo @win

  • I accidentally downloaded the search engine called Genieo and I am trying to remove it but it just wont go away! I followed the step to remove it but its not working. I am begging for someone's help!!

    I accidentally downloaded the search engine called Genieo and I am trying to remove it but it just wont go away! I followed the step to remove it but its not working. I am begging for someone's help!!

    See if these instructions work:
    http://www.thesafemac.com/arg-genieo/
    Ciao.

  • How do EDGE charges work/where do I look for itemized billing GoPhone Pic

    How do EDGE charges work/where do I look for itemized billing. I have the GoPhone Pick Your Plan. The AT&T _phone call_ charges are clearly itemized on line at AT&T.
    Can I view the charges for the Media Net Unlimited feature package? I have connected to WiFi at the local coffee shop. I have connected briefly to a local TV weather page while using EDGE. I fear the twenty or thirty dollar charges I have read about if I do any serious use of Safari while using EDGE.
    I have explored this on the following:
    http://www.lindenlan.net/2007/08/15/prepaid-vs-contract-att-gophone-or-nation-pl an/
    and
    http://www.tuaw.com/2007/09/24/prepaid-data-packages-and-the-iphone/
    and both suggest I will be thoroughly reamed unless I am on a WiFi hot spot.
    Every time I read the word "Unlimited" in my unlimited Media Net package there is the dreaded double asterisk "**" and the warning "additional per minute charges apply.
    I don't see a charge for my maiden foray onto the internet using EDGE to view the weather page at KKTV so where is it. Surly I cannot use EDGE without charges on this turkey plan. Or can I ?

    How exciting ! You have gone way beyond the call of duty for me. I appreciate it; thanks. I am so pleased with the iPhone but did not want to spend my life in coffee shops just to use it. Also I need the map function at work to help my customers and we have no WiFi there yet. But looks like I am ok at work on EDGE.
    Every other day I was oscillating between being extremely pleased with my purchase and then chastising myself for spending all the money on the service that I was sure would be inadequate. I don't call much and considering how fast things are changing I don't want to be locked into a two year contract though I understand Apple is locked into five years exclusively with AT&T.
    I hope good things come your way !
    Message was edited by: barkingmad

  • I am looking for software to store photos with.  I am not a fancy photographer, and really am just looking for the digital version of a photo album. iPhoto is not cutting it, mainly because it does not back up and restore easily on an external HD.

    I am looking for software to store photos with.  I am not a fancy photographer, and really am just looking for the digital version of a photo album. iPhoto is not cutting it, mainly because it does not back up and restore easily on an external HD.

    That's how Time Machine and iPhoto now work.  Restore the library to one of the external HDs, check it for the photos you want, export them to the boot drive and delete the restored library.
    If you know the file name of the photo you're looking for you can search for them in the TM backup using Find Any File.
    My workflow allows me to do that:
    1 - upload new photos to a folder on the Desktop.
    2 - name the folder to represent the contents and date: 01/03/10-Toads Bday
    3 - use a file renaming app to sequentially rename the photos in the folder to: 2010-01-03-Toads Bday-001.JPG,  -002,JPG, -003.JPG,  etc.
    4 - import the folder into iPhoto creating an Event with the same title as the folder.
    Now I can search for those file by file name with any app of my choosing.

  • Looking for someone to do paid scripting work

    Hey,
    I'm in a bit of a bind with InDesign scripting - I've got a huge amount of it to do in very little time. I've hired someone on Elance who claims to know about Extendscript etc to help me, but I am slightly dubious. I thought coming to the Adobe forums might be a good idea, as you guys will probably know what you are talking about!
    Is there anyone around here offering scripting services for pay? It's quite an interesting project, automating the production of a certain type of book. I am fairly proficient in scripting myself after having written a script to do a similar thing last year, but simply can't deal with the amount of work I have.
    I'm looking for someone who really knows InDesign and scripting inside out and who would be able to advise me on best practice, rather than the current situation where I'm instructing someone fairly unskilled how to do things the way I've just sort of 'worked them out'.
    Apologies if this is in the wrong place; I'm pretty desperate!
    Thanks,
    Dan

    There's a lot of very qualified folks here on this forum.
    The big question is what's the scope of the project as well as time restrains.
    I, for example would not be able to look at any sizeable project for at least a month.
    Give some more details on what's involved, and someone will probably be able to help...
    Harbs

  • I want to set up 5 different ipods to sync from one library, but want to be able to control what is synced to each ipod and have it remember that for future synching and just look for new songs and not sync all the other music in the library

    I want to set up 5 different ipods to sync from one library, but want to be able to control what is synced to each ipod and have it remember that for future synching and just look for new songs and not sync all the other music in the library

    Click here for options.
    (58961)

  • I have a MacBook Pro 5,4 running OSX 10.6.8 and Safari 5.1.10. A website i like has a known bug with 5.1.10 and recommends I install a newer version of Safari or use Firefox or Chrome. Just looking for advice on the best approach. Thanks!

    I have a MacBook Pro 5,4 running OSX 10.6.8 and Safari 5.1.10. A website i like has a known bug with 5.1.10 and recommends I install a newer version of Safari or use Firefox or Chrome. Just looking for advice on the best approach. Thanks!

    Unfortunately, Safari cannot be updated past 5.1.10 on a Mac running v10.6.8.
    So, the options are to upgrade to a newer OS X or use Firefox or  Chrome.
    Be aware, Apple no longer support Snow Leopard v10.6 >  www.ibtimes.com/apple-kills-snow-leopard-os-x-106-no-longer-receives-security-u pdates-1558393
    See if your Mac can run v10.9 Mavericks >  OS X Mavericks: System Requirements
    If so, you can download and install Mavericks for free from the App Store.
    Read prior to upgrading >   Upgrading to 10.7 and above, don't forget Rosetta! | Apple Support Communities

  • Everytime I open itunes I get a message saying itunes has stopped working and windows is looking for a solution

    Everytime I open itunes I get a message saying itunes has stopped working and windows is looking for a solution

    I have the same issue. An iTunes help page (iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues - Apple Support) suggested I hold down shift and control when clicking to open iTunes, which opens iTunes fine for me. That would mean the problem is in the third party plug-ins that work with iTunes. However, the help pages did not say what to do with the plug-ins once I knew that was the issue. The pages said to find the plug-ins and move them to the Desktop, which I did. That's where the help pages stopped, which is ridiculous. Does anyone know what to do from there?

  • Fortinet configuration with SCCM - just looking for experiences with it.

    Just looking for experiences with Fortinet SSL gateway and managing clients with SCCM with it.  I'm planning on building a lab area and selling management the idea of using Windows Defender and managing the 700 remote clients we have with our SCCM 2k7
    R2 setup on Windows 7.
    So if anyone has any experiences it would be handy.  Or white papers would be awesome.
    Trying to figure out an SSL gateway product with a path of least resistance that isn't Citrix.

    Yes, I know this is an old post, but I’m trying to clean them up.
    You will get more responses from Fortinet forums.
    Garth Jones | My blogs: Enhansoft and
    Old Blog site | Twitter:
    @GarthMJ

  • PRE 8.0 Just looking for a way to delete titles

    I have just started using PRE 8.0 and was adding titles yesturday, having learned it in an online adobe tutorial. However I could not find the delete button to remove the title once created. I was dragging different titles from the title menu onto the preview screen and playing with them a lttle bit. I noticed the little red line appearing down in the timeline representing the added title, but could not delete it again. i tried just looking for a delete button or a trashcan. i search all the menus around that screen. i tried highlighting and pressing keyboard delete. i tried right clicking the title in the preview pane and looking for a delete options. I would be glad to be glad to solve this little technique?? Other than that happy with its performance on my new Sony Vaio. I would also be keen to be pointed to a online tutorial to goes slowly though how to make a simple video

    You need to use the scroll button along the right side of the timeline to scroll up.
    The title is a clip on an upper video track.
    You can find out more about using this program in my free Basic Training with Premiere Elements tutorials on Muvipix.com and in my books, which are available on Amazon.

  • Itunes launches fine however I cannot connect to the Itunes store.  It says that Itunes has stopped working and windows is looking for a solution.

    Everything seems fine until I try to access the ITunes store.  Then I get a message that ITunes has stopped working and that Windows is looking for a solution.  Then it tells me that no solution has been found and closes down Itunes.
    I can still sync music / podcasts to my ipod and iphone.  I am still getting podcast downloads automatically for the ones I have subscribed to.
    This is the first time this issue with not being able to access the Itune stores has happened to me.  I was just there 2 nights ago.

    Hello notime4,
    The article linked below details some useful troubleshooting steps that can help stabilize iTunes on your computer.
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/TS1717
    Cheers,
    Allen

  • Web Based Messageboard (JSP, XML, XSLT) - Just Looking For Advice Please!

    I have a general question - I am not looking for any code, just some advice if possible. I am studying on a Masters course and I have been given an assignment to do which I am having difficult getting started. I have worked a lot with Java up until now, however this is the first time I have had to JSP on my course.
    My current assignment is that I am required to create a simple web based message board, using JSP and XML, which allows users to post messages to the board, and also to reply to messages. The content of the message board is stored in an XML file, and there is no database involved. The message data needs to be formatted for viewing in a browser using XSL transformations.
    I am stuck as to how to go about starting the project, and this is all I am asking for advice in. I have created the basic XML file which has some preliminary data stored within it, and I have created an XSL stylesheet to transform this data, however I am stuck with the JSP. Do I need to create a seperate JSP page for each page of the website? How does this link in with the XSLT?
    I would welcome and really appreciate any advice, but I stress that I am not looking for anyone to give me any code or anything like that.
    Thanks.

    You can use XSLT to convert XML to HTML. Then include this HTML in your JSP. Further on you've a plain HTML form with an input field for a message which you submit to a servlet. In the servlet validate/convert/whatever this message and add it to the XML file and then forward/redirect the request back to the JSP.

  • HT3576 still doesn't work, where do I look for the network or firewall on the phone?

    Cannot figure out the notifications on my Iphone 5. I have an Itouch and the notifications work just fine, I like the banners type. Anyone help me please?

    http://support.apple.com/kb/TS2802

  • Just looking for some advice at this stage

    Hello all, been a while since I posted here... That's cause it's been a while since I've upgraded :D
    Anyway, I'm just planning my build now and I want to check up on a few things... I'm going Conroe obviously (E6600) but I'm not decided on which flavour of board I'll go for just yet. Depending on what AMD/ATi pull out of the bag it'll either be the 975X or a P6N SLI (in some form or other). At this point three things are on my mind:
    1. I want to go for 4Gb of (matched) RAM on two sticks... anything I need to be aware of regarding 2Gb module compatibility? Any makes to avoid (OCZ seem to be unpopular in that regard).
    2. I'd like to move to a SATA optical drive, and issues there? Makes to avoid etc. especially in the case of the 975X as the tested hardware list only seems to include PATA drives.
    3. What the recommended Amperage on the 12V line these days? I'm currently looking at the 620W Corsair PSU as a safe bet, other recommendations are welcome though.
    Thanks for any advice/opinions offered in advance... hopefully with a bit more info this time I'll be able to avoid trouble shooting posts :D
    Gift.

    Right so I've done it, two PCs at the spec posted in my sig...
    They seem to be working fine, nice and stable but a few little niggles I'd like to sort:
    1. Updating the Mobo drivers, live update doesn't seem to like Vista so should I just DL the ones on the mobo main page?
    2. Vista seems to behave strangely when it greys out the screen to indicate a UAC box needs attention. It fades in ok on both PCs but seems to flicker off once I'm done with the box in a way that seems to render the graphics weirdly. I wouldn't go so far to describe it as graphical corruption more like a kind of rendering lag... Anyone else noticed this, I've an idea uptodate mobo/gfx drivers might be the problem (I've just gone with the stuff vista DL'ed installed, for me) but otherwise all good games run stably so far (touch wood).
    I'm off for a night of installing software :D Deep joy.
    Gift.
    PS sorry this was late, parts got delayed in the post :D And I had no probs with my RAM if peeps are interested.

Maybe you are looking for