Sunday, September 18, 2011

Local subprogram

DECLARE curContacts IS
  SELECT FirstName, LastName FROM CONTACTS;
  vFormatName VARCHAR2(50);
  FUNCTION FormatName(vFirstName IN VARCHAR2, vLastName IN VARCHAR2)
    RETURN VARCHAR2 IS
  BEGIN
    RETURN vFirstName || ' ' || vLastName;
  END FormatName
BEGIN
  FOR vContact IN curContacts LOOP
    vFormatName := FormatName(vContact.FirstName, vContact.LastName);
    INSERT INTO temp_table(char_col)
    VALUES(vFormatName);
  END LOOP;
  COMMIT;
END;

No comments:

Post a Comment