Converting Cobol Programs to PL/SQL Packages/Procedures

Our company is trying to move away from Cobol and code all new projects and begin to convert old code to pl/sqlpackages/procedures. I was wondering if anyone in here had any experience in converting Cobol programs to Pl/sql. Any help would be greatly appreciated.

user8697075 wrote:
Our company is trying to move away from Cobol and code all new projects and begin to convert old code to pl/sqlpackages/procedures.JOY!! ;-)
I have written a lot of Cobol and converted a lot of Cobol (not to PL/SQL though). But the mere thought of it, brings a song to my heart. :D
PL/SQL will be significantly faster and more scalable than using Cobol. It is also a lot simpler to design and code than using Cobol. Always found Cobol development very boring - except for the odd occasions when we had to design and write re-entrant Cobol code..
Just do not make the mistake of attempting a straight port - rewriting a Cobol program essentially line by line into a PL/SQL unit. Implementing row-by-row slow-by-slow processing into PL.SQL.
Without rethinking the process flow, the program design and so on, the resulting code unit will be little better than the original Cobol unit. Which begs the question, why bother and why use the new code then? In fact, seen this first hand back in the 80's when this approach was used to convert a pretty large system from Cobol to Natural. After many man years of development (and lots of money), the new system had all the problems of the old.. and was canned during the testing phase. Money, time and resources utterly and totally wasted.

Similar Messages

  • Calling Cobol program from PL/SQL

    What is the caling convention for PL/SQL to call a Cobol program?

    You cannot do it directly from PL/SQL. PL/SQL is.. well, kind of abstract ito the actual platform it runs on. PL/SQL cannot talk directly to operating system. It cannot (itself) do socket calls, file I/O calls, use the printer, etc.
    <p>
    All this has to be done using a lower level implementation library - like UTL_FILE for example that wraps internal C written modules that does file I/O. PL/SQL can call these to do I/O on its behalf. Ditto for wrappers like UTL_TCP and others.
    <p>
    There is no default wrapper for calling external processes from PL/SQL. It can however be done indirectly using the external procedure (EXTPROC) feature, or using Java to do it.
    <p>
    The latter is the easiest. You create a Java stored proc that can access the operating system and run external programs and commands. You punch a big hole in the Oracle Java security to allow this Java stored proc access to the operating system. Next you create a PL/SQL wrapper for this Java proc which then in turn can be called from PL/SQL.
    Just remember that you MUST secure this hole you've punched into Oracle security. If any Oracle user can access this PL/SQL wrapper, they can hack, compromise, trash or simply destroy your entire Oracle account on that server.
    Here is the basic code:
    create or replace and compile Java Source named "OSCommand" as
    -- java:        OS COMMAND
    -- descr:       Executes an Operating System Command using the JAVA RTS
    -- IN parameter:        os command to execute (including fully qualified path names)
    -- OUT parameter:       returncode [\nstring]
    --                      where string a max of 32000 chars of the output of the command
    --                      (note that \n is used as separators in the string)
    --                      returncode=-1   Java RTS error occurred (e.g. command does not exist)
    --                      returncode=255  o/s command failed (e.g. invalid command params)
    import java.io.*;
    import java.lang.*;
    public class OSCommand{
            public static String Run(String Command){
                    Runtime rt = Runtime.getRuntime();
                    int     rc = -1;
                    try{
                            Process p = rt.exec( Command );
                            int bufSize = 32000;
                            int len = 0;
                            byte buffer[] = new byte[bufSize];
                            String s = null;
                            BufferedInputStream bis = new BufferedInputStream( p.getInputStream(), bufSize );
                            len = bis.read( buffer, 0, bufSize );
                            rc = p.waitFor();
                            if ( len != -1 ){
                                    s = new String( buffer, 0, len );
                                    return( s );
                            return( rc+"" );
                    catch (Exception e){
                            e.printStackTrace();
                            return(  "-1\ncommand[" + Command + "]\n" + e.getMessage() );
    show errors
    create or replace function OSexec( cCommand IN string ) return varchar2 is
    -- function:    OS EXEC
    -- descr:       PL/SQL wrapper for the Java OSCOMMAND stored proc
    language        JAVA
    name            'OSCommand.Run(java.lang.String) return java.lang.String';
    show errors
    -- Punching a hole into the Java VM sandbox. The following must be run as
    -- sysdba. Substitute SCOTT with the applicable schema that owns the OSEXEC
    -- and OSCOMMAND stored procs.
    declare
            SCHEMA  varchar2(30) := 'SCOTT';
    begin
            dbms_java.grant_permission(
                    SCHEMA,
                    'SYS:java.io.FilePermission',
                    '<<ALL FILES>>',
                    'execute'
            dbms_java.grant_permission(
                    SCHEMA,
                    'SYS:java.lang.RuntimePermission',
                    'writeFileDescriptor',
            dbms_java.grant_permission(
                    SCHEMA,
                    'SYS:java.lang.RuntimePermission',
                    'readFileDescriptor',
    commit;
    end;
    -- example: running the Unix/Linux date command to get the current date and time
    SQL> select OSexec('/usr/bin/date') as STDOUT from dual;
    STDOUT
    Fri Sep  1 08:09:34 SAST 2006
    1 row selected.
    SQL>Edited by: Billy Verreynne on Sep 4, 2008 6:26 PM to make the code snippet readable with the new Jive forum s/w.

  • Encryption of pl/sql package/procedures/function code

    Is it possible to make the code inside a package/procedure/function un readable to other users.
    As is some of the api package body code in portal ?
    thanks in anticipation.
    SD,

    PL/SQL Wrap Utilityhttp://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/c_wrap.htm#LNPLS016
    Note, however that you cannot revert back to original un-wrapped code from a code that has been wrapped. You would need access to the original source files to get the original source code.

  • How to run a PL/SQL package procedure

    I can run a procedure in Jdeveloper 9.0.3, but How can run a procedure of a package not using SQL*PLUS

    You can run a procedure or function in a package the same way you run a top level procedure or package. Select the package containing the procedure in the navigator and select 'Run' from the context menu. In the Run PL/SQL dialog, select the procedure/function you wish to run from the list in the top left-hand side.
    - John McGinnis
    Oracle JDeveloper Team

  • Calling Oracle BugDB PL/SQL Package Procedures from Application Modules

    Hi Experts,
    I am using JDev 11g R2.My requirement is as follows:
    1.Create a public database link to remote bugDB using the Testing Environment.(Done)
    2.Access the data from local database to BugDB using that DB link (Done)
    3.Insert/Create a bug using the Create_Bug procedure in the API provided by BugDB(Failed).In the Application ModuleImpl class I have added the following code(Just an Example) to call the API containing a pl/sql procedure which creates a bug in the remote db table.
    public void Create_Bug(String Product, String Component, String Subcomponent, String Status) {
    CallableStatement st = null ;
    try {
    StringBuffer str = new StringBuffer();
    str.append(" BEGIN ");
    str.append(" Bug.Bug_API_V1.Create_Bug@bugtest( ");
    str.append(" Product => :1, ");
    str.append(" Component => :2, ");
    str.append(" BugNo => :3 ");
    str.append(" Status => :4 ");
    str.append(" ")
    str.append(" ); ");
    str.append(" END; ");
    st =getDBTransaction().createCallableStatement(str.toString(), 1);
    st.setString(1, Product);
    st.setString(2, Component);
    st.setString(3, Subcomponent);
    st.setString(4, Status);
    st.execute();
    } catch (SQLException sqle) {
    // TODO: Add catch code
    sqle.printStackTrace();
    } catch (NumberFormatException nfe) {
    // TODO: Add catch code
    nfe.printStackTrace();
    4.Added a managed bean to invoke this AppModuleDataControl which stores the value in the remote database.(Failed in this part).
    Its not showing any errors in the log but the bug is not created either in the remote database.Could anyone guide me where am I going wrong or what is the better way to handle this requirement.Any suggestion for materials,links or tutorials would be highly appreciated.Thanks in advance.
    Regards,
    Prasanna

    Prasanna,
    this is a public form_ and the Oracle bug database API is not public! Can you please post internal questions to Oracle internal forums and mailing lists?
    thank you
    Frank

  • How to Compile the PL/SQL Package/ Procedure using shell script

    Hi,
    I tried to Compiled the shell script but I am facing some error.
    Can any one help me how to compile the PL/SQL shell script without error. Awaiting for your valuable reply.
    Thanks,
    Arun Prakash

    user8726849 wrote:
    PL/SQL shell script without errorWhat's a PL/SQL shell script?
    Can you please post exactly what you are trying to do (As in the actual code that you are executing and its output)? Also please post it in \ tags (See FAQ).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to Create a PDF file from database package/procedure in 10g?

    Hi,
    Is there a way to create a pdf file in 10g Application Server using PL/SQL package/procedure in 10g database?
    Thanks in advance.
    Regards
    Vishnu Nekkanti

    http://technology.amis.nl/2010/10/20/as_pdf-generating-a-pdf-document-with-some-plsql/
    http://technology.amis.nl/2012/04/11/generating-a-pdf-document-with-some-plsql-as_pdf_mini-as_pdf3/

  • JS Validation for Drop down List is not working in Oracle PL/SQL Package

    Hi All,
    I am facing an issue with JavaScript validation done in Oracle PL SQL package.
    System Requirement:
    There is one screen which contains two fields viz. FLD 1 & FLD 2 and one 'Submit' button.
    FLD 1 and FLD 2 fields are drop down list boxes.These are mandatory fields.
    The screen is developed in Oracle Mod PL SQL package.
    The html coding and java scripting are embedded in the respective Oracle PL SQL Package procedure which generates this screen,takes the input values provided by user,does the
    field validations and submits the form.
    Issue:
    The javascript validation for FLD 2 dropdown is working successfully.
    When the user leaves this field as blank,the embedded javascript pops up an error message 'Selection of FLD 2 is manadatory before submitting the form!'.
    As FLD 1 is also a mandatory field,the javascripting validation should pop up the similar error message 'Selection of FLD 1 is manadatory before submitting the form!'.
    But,this first field validation is not at all working.
    The system allows to submit the form even if the 'FLD 1' is left blank.
    The javascript code sysntax for validation of FLD 1 & FLD 2 drop down list boxes as follows:
    function validate_form_fields()
    if (document.forms[0].p_fld_1.selectedIndex == 0))) || (document.forms
    [0].p_fld_1.selectedIndex < 1 )
    alert("Selection of FLD 1 is manadatory before submitting the form!!!");
    return false;
    else if (document.forms[0].p_fld_2.selectedIndex == 0))) || (document.forms
    [0].p_fld_2.selectedIndex < 1 )
    alert("Selection of FLD 2 is manadatory before submitting the form!!!");
    return false;
    return true;
    I am viewing the screen from the web browser IE version 8.0.
    Your timely help will really be appreciated.
    Regards & Thanking in advance,
    Alka

    Hi,
    1. Your problem is actually related to JavaScript, not SQL and PL/SQL. So, this is the wrong forum to post. The closest to JS is the Application Express forum {forum:id=137}. Clearly state that it is not an Apex issue and that you are looking for JS help.
    2. Your JS code, the way you has posted it, is syntactically incorrect, so if you post on Apex forum put the correct code and in tags as described in the FAQ
    {quote}
    function validate_form_fields()
    if (document.forms[0].p_fld_1.selectedIndex == 0))) || (document.forms
    [0].p_fld_1.selectedIndex < 1 )
    alert("Selection of FLD 1 is manadatory before submitting the form!!!");
    return false;
    else if (document.forms[0].p_fld_2.selectedIndex == 0))) || (document.forms
    [0].p_fld_2.selectedIndex < 1 )
    alert("Selection of FLD 2 is manadatory before submitting the form!!!");
    return false;
    return true;
    {quote}
    Regards,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Performance of PL/SQL-packages under Oracle 11gR2

    Under Oracle 9i I have used PL/SQL-packages/procedures to perform complicated initializations of the tables of a database schema.
    This was always a long job ... but an execution time of about 4 hours was acceptable!
    Now I changed to Oracle 11g.
    And now there is the following behaviour:
    When I create a NEW instance of the database and then create the schema the execution time ( using the same PL/SQL-packages as in Oracle 9i ) is more than 12 hours which is not acceptable anymore!
    When I only drop the schema ( in the EXISTING instance ) with a drop user (owner of the schema) cascading and then create the schema again the execution time for the same initialization is less than 3 hours which is OK.
    Does anyone have an idea about the reason for such a 'strange' behaviour?
    ... Or does anyone have a hint where I could look for such reasons?

    Hi,
    did you compare the execution plan in 9i and 11g R2?
    when you go to 11gR2, did you keep the statistic of the 9i, so if any regression, 11g can use 9i plan?
    thanks

  • What's the quickest way to find all calls to some PL/SQL package?

    Here's my situation:
    I have a large application (>100 pages) which has multiple calls to a PL/SQL package procedure X.Y occurring in various processes, conditions, etc on an unknown set of pages. The procedure is being moved to package Z, so I want to replace all instances of X.Y with Z.Y. What is the best way to do this?
    I'm thinking of exporting the application, and doing a manual find and replace of all X.Y with Z.Y, then importing the modified export file. Will this work?
    Alternatively, is there a report available which can be run to show something like this, given an input of X.Y, which shows all pages where X.Y is referenced :
    Page Object
    1 After-submit process abc
    5 item P display condition
    13 validation xyz
    etc
    If not, how easy is it to write such a report from the available apex views?

    Have you looked at the Database Object Dependency report?
    In the Application Builder, select your application.
    In the Tasks list on the right, click on View Application Reports.
    Under the Application menu, click on Database Object Dependencies.
    It will make a list of all database objects used by your application and where they are used.

  • Conc. prog as pl/sql stored procedure question

    When I registered a conc. program as pl/sql stored procedure, and, with in procedure I am using as following:
    exception
    when others
    retcode := 2;
    Where I am expecting the conc. request screen should show me as red one, that is completed with error. But, even though my program aborted for unknown reason, the conc. request screen for this conc. request-id shows as "completed-normal" insted of "completed_error".
    Any idea? what are the exact retcode should be used? please explain.
    Thanks
    R2b.
    null

    What about
    exception
    when others
    THEN
    retcode:=2;
    Jack

  • Still no way to access a PL/SQL package record type ?

    Sorry if this is a recurrent question...
    Is there still no way to set/retrieve input/output parameters of a PL/SQL package procedure/function through JDBC that is of type RECORD ??????
    I'm not considering wrapping up through objects or strings. Rather new versions of JDBC driver.
    How about SQLJ (don't know anything about that one. Does it call stored procedures ?
    Would it support package stored procedure ?
    And RECORD types ?
    Just out of curiosity as i'm setting off to breaking up all my types into individual arguments. What a pain !!!!!!!!!
    Thx.

    Thanks for the suggestion.
    We were arriving to a similar conclusion...
    There is however one BIG reason of being disapointed :
    - I did not know that (since I'm only Oracling since January) but objects do not accept attributes the type of which would be defined by refering the type of an existing column :
    Such as :
    CREATE TYPE type_customer AS OBJECT (
    cust_id CUSTOMERS.CUSTOMER_ID%TYPE,
    I have no idea why RECORDs can do it but object can't.
    To summarize it all we can use RECORDs but they are not seen through JDBC drivers and we can use OBJECTS but they don't map to column types... Unfortunate !
    Now to answer your question, at the moment I'm thinking of rewriting the routines rather than wrapping them up. Only around ten of them... So that the tool you mention is not needed.
    Just have to proofOfConcept it but that's the latest options we are considering...
    Thanks for the pointer I look it up right away...
    Alain
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by SQLJ Development ([email protected]):
    You could define a Customer Object type and create PL/SQL wrapper procedures/functions that take these as arguments and call your original PL/SQL SP. Unfortunately, right now you would have to do that by hand (JPublisher only gives you a Java representation of the Customer object type) - if there were a tool to generate the Object type and the PL/SQL wrappers, would you expect to use that?
    For an example of doing this (albeit in a pedestrian way) see: http://technet.oracle.com/docs/products/oracle8i/doc_library/817_doc/ java.817/a81357/sampcod8.htm#1042848 <HR></BLOCKQUOTE>
    null

  • Converting sql to procedure

    Hi experts,
    I was using the below query in my asp.net page and it is working fine.while i was browsing the internet i stumlbed on the sql injection article and i got so panic and try to convert my existing sql to procedure to avoid sql injection and so far i do not have a luck. I am sure someone out there have an idea how i can convert this sql to procedure.one of the thing that makes so difficult on me is that this sql statemnet is connected to some of the controls i have on my asp.net page. for example when rdDes.Checked the value paramter is passed to this part of the code. I am greatly appreciate for your help and time.
    Create or replace procedure ItemSearch(strItem IN varchar2)
    SELECT    Item_Number,Short_Description,LONG_DESCRIPTION,UNIT_NAME,PLAN_UNIT_DESCRIPTION, SPEC_YEAR
    FROM    ITEMSEARCH
    WHERE ITEM <> '2999509/00001'  AND   IOBSELET='N'    AND
    If rdDes.Checked Then
                  upper(LONG_DESCRIPTION) Like " & strWhereClause
    Else If rdUnit.Checked Then
                  upper(PLAN_UNIT_DESCRIPTION) like " & strWhereClause
    Else If rdNumber.Checked Then
                 "'" & Trim(txtItem.Text) & "%" & "'"
                    strWhereClause = Replace(strWhereClause, "'%", "''")
                    strSQLforGrid = strSQLforGrid & "upper(Item_Number )  like " & strWhereClause
    End If
    If (ck2005.Checked And ck2000.Checked) Then
                (SPEC_YEAR =  '05' or SPEC_YEAR= '00')
    Else If ck2000.Checked Then
                 SPEC_YEAR = '00'
    Else If ck2001.Checked Then
                    SPEC_YEAR = '01'
    Else If ck2005.Checked Then
                SPEC_YEAR = '05'"
    Else  SPEC_YEAR = '05'
    End if
    order by Item_Number   asc,LONG_DESCRIPTION   asc
        

    Please see the below sample packaged proc. It's not tested.
    You will have to change this eventually to Dynamic SQL.
    CREATE TABLE ITEMSEARCH
    Item_Number NUMBER(10) NOT NULL
    ,Short_Description VARCHAR2(30)
    ,LONG_DESCRIPTION VARCHAR2(100)
    ,UNIT_NAME VARCHAR2(100)
    ,PLAN_UNIT_DESCRIPTION VARCHAR2(100)
    ,SPEC_YEAR VARCHAR2(4)
    CREATE OR REPLACE PACKAGE ITEM
    AS
    TYPE RECORDSET IS REF CURSOR;
    PROCEDURE SearchItem
    in_Spec_Year IN VARCHAR2
    ,out_RecordSet OUT ITEM.RECORDSET
    END ITEM;
    CREATE OR REPLACE PACKAGE BODY ITEM
    AS
    PROCEDURE SearchItem
    in_Spec_Year IN VARCHAR2
    ,out_RecordSet OUT ITEM.RECORDSET
    IS
    BEGIN
    OPEN out_RecordSet
    FOR
    SELECT Item_Number
    ,Short_Description
    ,LONG_DESCRIPTION
    ,UNIT_NAME
    ,PLAN_UNIT_DESCRIPTION
    ,SPEC_YEAR
    FROM ITEMSEARCH
    WHERE SPEC_YEAR = in_Spec_Year;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE;
    END;
    END ITEM;
    Good Luck

  • External procedure call for cobol programs

    I'm trying to call cobol programs using external procedure calls. I followed metalink doc#119543.1 but when the cobol shared library is called from PL/SQL, the session hangs. I'm running Oracle 9.2.0.4 EE, Microfocus Server Express 2.2, C for AIX v6, and AIX 5.2 (64-bit). If you know how to get this working or you have a working test case, please post a reply. Thanks.

    You know that there are several steps to it :
    1.- Make a library from cobol a the source code in a file
    2.- Check the listener parameters to call external procedures and the service in the client
    3.- Make a library inside the database
    4.- Create the procedure that is going to call the
    procedure.
    Did you do those steps?
    Joel P�rez

  • How to convert sql server procedure in to plsql procedure

    hi guys
    i have requirement where in i have to convert sql server procedure into plsql procedure.
    can some one help me out .
    thanks,
    Vamshi.D

    Hi Vamshi,
    As you want to convert sql server procedure in to plsql procedure
    i.e SQL SERVER ->ORACLE Right
    FYI
    SQL SERVER Proc. Syntax are totally different as compared to ORACLE Proc.
    So, better you study Logic of SQL-SERVER Proc and convert into
    Oracle Procedure.
    Thanks,
    Samadhan

Maybe you are looking for