Problem solve Get help with specific problems with your technologies, process and projects.

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.
  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;

   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 
     -- do what you need to do..maybe call a procedure
  orders that will process.

 END ;

This was last published in October 2004

Dig Deeper on Using Oracle PL-SQL

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.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.