Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert SQL function to DB2

Status
Not open for further replies.
Try this out.

Code:
CREATE FUNCTION FNGETTITLE ( AU_ID VARCHAR(11) )               
LANGUAGE SQL                                                   
RETURNS NVARCHAR(2048)                                         
SET OPTION COMMIT = *NONE                                      
                                                               
BEGIN                                                          
DECLARE STRLIST NVARCHAR(2048) DEFAULT ' ';                    
                                                               
FOR V AS C1 CURSOR                                             
  FOR SELECT T.TITLE FROM TITLES T                             
      INNER JOIN TITLEAUTHOR TA  ON T.TITLE_ID = TA.TITLE_ID   
      INNER JOIN AUTHORS A ON TA.AU_ID = A.AU_ID               
      WHERE A.AU_ID = AU_ID                                    
   DO SET STRLIST = TRIM(STRLIST) CONCAT ' ' CONCAT V.T.TITLE; 
  END FOR;                                                     
                                                               
RETURN LTRIM(STRLIST);                                         
END



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top