Q

Converting COBOL style code to PL/SQL

I have COBOL developed psuedo code, so I need to convert it into PL/SQL. Here is the code:

select A.*
from Event A
where event/d_create_ts>or=MMIS endtime from audit table of 1st run..
and n_evnt_type=399
and c_assn_ty='L'
and n_enty_id=n_line_id
if return_code=0
  
   move 'NN' to code_name
 goto orders.
else
   
  move 'MM' to code_name.

How should this code be converted to PL/SQL? I hope this can be written as a procedure; if so, how can we do it?


I am providing a rudimentary example in PL/SQL.

Create or replace procedure set_code_name(p_date IN DATE) is

/* YOu may want to define the SQL according here */
  cursor c1 is select * from event                         
  where d_create_ts >=  p_date
                 and n_event_type = 399
                 and c_assn_ty = 'L'
                 and n_enty_id = n_line_id
   v_code_name VARCHAR2(30);
-- define other variables
   rowcount  PLS_INTEGER := 0;
 BEGIN


   for c1rec in c1 loop
     rowcount := rowcount + 1;
     -- the cursor variable c1rec.
 
   will store the value of column_NAME for record # rowcount.

   end loop;

 
   if rowcount = 0 -- that means no record fetched 
                  then
     -- do what you need to do..maybe call a procedure
  orders that will process.


 END ;

This was first published in October 2004

Dig deeper on Using Oracle PL-SQL

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close