Help - Unable to assign char value to a var within cursor for statement

Connectivity
Enthusiast

Help - Unable to assign char value to a var within cursor for statement

Hi

Iam unable to extract the CHAR value for the variable D_SYMP when used in the cursor but with a integer variable it works fine.

REPLACE PROCEDURE SP_SYMP(OUT V_SYMP VARCHAR(2000))
BEGIN
DECLARE D_SYMP VARCHAR(2000) ;
FOR SYMCUR AS C_SYM CURSOR FOR
SELECT SEQ_ID, SYMP_CAT||'-'||SYMP_NM AS SYMP
FROM SIDE_EFFS
DO
SET D_SYMP = D_SYMP || SYMCUR.SYMP;
END FOR;
SET V_SYMPTOM = D_SYMPTOM;
END;

Please help me, if iam missing something.

Thnx
Sony
1 REPLY
Enthusiast

Re: Help - Unable to assign char value to a var within cursor for statement

D_SYMP is initially NULL

and when you have NULL || "anything" it gives you NULL not "anything"

so you never get anything out !!

That's probably what happened in your case ...

you can declare the variable to have a default value of '' (empty string, not NULL)

DECLARE D_SYMP VARCHAR(2000) DEFAULT '' ;