I have a function that works like a charm in Oracle, and I need it to be in SQL so that a stored procedure in SQL can get to it...I dont understand what I am doing wrong -- definitely need syntax help. Can someone please, please swith this to SQL for me and then explain it so I learn how to do it next time?
*********************************************************
CREATE OR REPLACE FUNCTION concat_part_desc_LMC082304 RETURN VARCHAR2 AS
concat_desc VARCHAR2(4000) := NULL;
BEGIN
FOR i IN (SELECT T.COMMENT_ONE,T.COMMENT_TWO
FROM CSIOWNER.txdt T, CSIOWNER.PART_ELK PART
WHERE T.TEXT_ID = PART.PART_NBR and T.prefix_id = 'TXT'
AND PART.USER_FIELD_3 = 'ELK')
LOOP
-- l_string := l_string || Ltrim(Rtrim(i.comment_one)) ||
-- ' ' || Ltrim(Rtrim(i.comment_two)) || ' ';
concat_DESC :=
substr(
concat_DESC ||
Ltrim(Rtrim(i.comment_one)) || ' ' ||
Ltrim(Rtrim(i.comment_two)) || ' '
,1,4000);
END LOOP;
RETURN concat_DESC;
END;
/
*****************************************************
LMC
*********************************************************
CREATE OR REPLACE FUNCTION concat_part_desc_LMC082304 RETURN VARCHAR2 AS
concat_desc VARCHAR2(4000) := NULL;
BEGIN
FOR i IN (SELECT T.COMMENT_ONE,T.COMMENT_TWO
FROM CSIOWNER.txdt T, CSIOWNER.PART_ELK PART
WHERE T.TEXT_ID = PART.PART_NBR and T.prefix_id = 'TXT'
AND PART.USER_FIELD_3 = 'ELK')
LOOP
-- l_string := l_string || Ltrim(Rtrim(i.comment_one)) ||
-- ' ' || Ltrim(Rtrim(i.comment_two)) || ' ';
concat_DESC :=
substr(
concat_DESC ||
Ltrim(Rtrim(i.comment_one)) || ' ' ||
Ltrim(Rtrim(i.comment_two)) || ' '
,1,4000);
END LOOP;
RETURN concat_DESC;
END;
/
*****************************************************
LMC