What you see, is origin for similar inquiries; i.e. it is somewhat
confusing such that others have encountered the same. However it is
correct according to the rules, that the SET statement is failing with
the SQL0303 condition.
You are trying to encrypt to the target field ACCOUNT, which was
previously modified in its attributes, to be binary and the 8-byte
aligned longer field length. Trying to ENCRYPT_RC2() on this longer
field would require a larger target, according to the rules of the
ENCRYPT function(s).
You need to encrypt the inversed type & length value for ACCOUNT.
That is, encrypt the value passed by the program to be inserted, not the
value in the row [buffer]. Effectively:
SET N . ACCOUNT = ENCRYPT_RC2 ( CHAR( N . ACCOUNT , 17), PASSWD );
It might be clearer, from the following [where the original CCSID for
ACCOUNT is assumed to be US English]:
CREATE TRIGGER MWLIBR.TEST_INSERT
BEFORE INSERT ON MWLIBR.TESTP
REFERENCING NEW AS N FOR EACH ROW MODE DB2ROW
BEGIN
DECLARE PASSWD VARCHAR ( 127 ) ;
/* */ DECLARE CHAR_ACCOUNT CHAR(17) CCSID 37;
/* */ SET CHAR_ACCOUNT = N . ACCOUNT ;
SET PASSWD = 'my20charpasswordhere' ;
/*- SET N . ACCOUNT = ENCRYPT_RC2 ( N . ACCOUNT , PASSWD ); -*/
/* */ SET N . ACCOUNT = ENCRYPT_RC2 ( CHAR_ACCOUNT , PASSWD ) ;
END
Regards, Chuck
As an Amazon Associate we earn from qualifying purchases.
This thread ...
RE: SQL ENCRYPT_RC2() function Question, (continued)
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.