0

I am trying to use NORMALIZE_STRING inside a stored function under DB2,:

CREATE FUNCTION foo(INSTR VARCHAR(4000) CCSID UNICODE)
      RETURNS VARCHAR(4000) CCSID UNICODE

      READS SQL DATA
      APPLICATION ENCODING SCHEME UNICODE      
  BEGIN
     SET RESULT = NORMALIZE_STRING(INSTR, NFD);
     RETURN RESULT;
  END#

However, I can not pass the second argument to the function, as this results in an error:

VARIABLE NFD IS NOT DEFINED OR NOT USABLE. SQLCODE=-312, SQLSTATE=42618, DRIVER=4.13.111

Is there any way I can get this working?

Do I have to specify some kind of scope/namespace/... to make clear that I am not referring to a local variable named "NFD", but to some constant, instead? The same applies to NFC, NFKC and NFKD.
Or is there any way to pass this parameter using another value (an integer constant maybe)?

I am looking forward to your ideas!

Matthias
  • 12,053
  • 4
  • 49
  • 91
  • What do you mean by "some constant"? Where is that "NFD" defined, and how does the DB2 compiler knows about that? – mustaccio Sep 25 '13 at 23:50
  • The documentation states that you should pass "NFD" (without quotations) to the function (it's build-in). I don't know exactly where it is defined. I can use this syntax outside of a stored function without any problems. – Matthias Sep 28 '13 at 11:22
  • Would you mind sharing the link to the documentation you're referring to? – mustaccio Sep 28 '13 at 13:42
  • Which DB2 version are you using? Your RESULT variable looks suspicious, not being declared anywhere. – mustaccio Sep 28 '13 at 13:48
  • Missing declaration is a copy&paste error, sorry. DB2 version is 10 (on z/OS). Documentation link: http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z10.doc.sqlref%2Fsrc%2Ftpc%2Fdb2z_bif_normalizestring.htm – Matthias Sep 29 '13 at 10:18

0 Answers0