Solved

How to change Oracle SP to UDB SP in Visual Age for JAVA?

Posted on 2002-05-29
4
222 Views
Last Modified: 2010-03-31
my original source is used for ORACLE :

    sql =  " DECLARE";
    sql += "     CURSOR line is";
    sql += "         " + SelectStatment + ";";
    sql += "     lrec line%ROWTYPE;";
    sql += " CNT     NUMBER(7):=1;";
    sql += " BEGIN";
    sql += "     OPEN line;";
    sql += "     WHILE CNT <= " + PersonCount + " LOOP";
    sql += "         FETCH line INTO lrec;";
    sql += "         EXIT WHEN line%NOTFOUND;";
    sql += "       " + InsertStatment + ;";
    sql += "         CNT := CNT + 1;";
    sql += "     END LOOP;";
    sql += "     CLOSE line;";
    sql += " END; ";
   
    db.executeUpdate(sql);

How can I change this SP to avaliable for UDB?

0
Comment
Question by:ChristBoy
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
Jim Cakalic earned 500 total points
Comment Utility
Wish I had time and expertise to write the full answer for you. Right now the best I can do is point you at this IBM Redbook:
    http://www.redbooks.ibm.com/pubs/pdfs/redbooks/sg245485.pdf

DB2 has historically supported stored procedures as native language methods that are executed by the database engine. The SQL Procedures language described by the Redbook is more traditionally like PL/SQL. As such, it may not be that difficult to syntactically convert the PL/SQL.

One hurdle you may have to overcome is that it appears you are using PL/SQL directly from your Java program. I don't know that DB2 would really support this in any form. I think you would have to write a stored procedure and install it on the database -- not assemble it dynamically in your application as you appear to be doing.

Barring that, it seems that it would be necessary to convert this to Java code which uses an outer SELECT statement and an inner INSERT statement to do the same thing.

Jim
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- points to jim_cakalic@idg

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0
 
LVL 19

Expert Comment

by:Jim Cakalic
Comment Utility
OK. Thanks. :-)
Jim
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
hash value 2 38
stringclean challenge 26 53
json example 39 110
Checkbox and ListView in Android Layout 4 35
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now