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?


    Requires Free Membership to View

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
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
Sort by: OldestNewest

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: