MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » February 2014

Resolution: FIELDPROC



fixed

It turns out...I didn't do anything wrong!

I reached out to Kent Milligan who kindly and ably responded. He answered these questions:

1. Why didn't the debug session pick up the run?
" The FieldProc program calls by DB2 are sometimes done in a thread, so you'll probably have to use STRSRVJOB for your debug session to capture the thread-based invocation." - Kent Milligan, DB2 for i Senior Certified IT Specialist

2. Why was the data un-encrypted after dropping the FIELDPROC program?
" As you've seen, dropping a FieldProc causes DB2 to decode all of the values back to their original value." - Kent Milligan, DB2 for i Senior Certified IT Specialist

3. How can I be assured that the process worked? How do I test it?
" There's a hidden function, HEX_ENCODED, that can be used to have DB2 just return the encoded value for a FieldProc column." - Kent Milligan, DB2 for i Senior Certified IT Specialist

So I ran it all over again, but used the HEX_ENCODED function to view the encoded value stored in the field and got:

select NORMALFIELD,hex_encoded(FIELDWITHPROC) from testfile

....+....1....+....2....+....3....+....4....+....5...
NORMALFIELD HEX_ENCODED
2345678901 F3F1F2F288F387F486F585F684F783F882F981F1

When decrypted. It appears as:

select NORMALFIELD,FIELDWITHPROC from testfile

....+....1....+....2....+.
NORMALFIELD FIELDWITHPROC
2345678901 abcdefgh23

Thank you Mr. Milligan!

Steve Needles


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Needles,Stephen J
Sent: Wednesday, February 12, 2014 3:19 PM
To: Midrange Systems Technical Discussion
Subject: RE: FIELDPROC

Vern,

Nothing.

I re-ran the whole thing from the beginning with the debugger off in a new job so I could get a clean joblog....still nothing.

Steve Needles


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Vernon Hamberg
Sent: Wednesday, February 12, 2014 3:09 PM
To: Midrange Systems Technical Discussion
Subject: Re: FIELDPROC

Hi Steve

Silly question - was it plugged in?

My real question is, anything in the job log?

Vern

On 2/12/2014 2:58 PM, Needles,Stephen J wrote:
I'm trying to write my first FIELDPROC POC and I've not had the greatest success...

I created a table:

CREATE TABLE TESTFILE
(NORMALFIELD FOR COLUMN NORFLD CHAR (10 ) NOT NULL WITH DEFAULT,
FIELDWITHPROC FOR COLUMN FLDPRC CHAR (10 ) FIELDPROC
library/TESTFLDPR2 NOT NULL WITH DEFAULT)

So now I've registered TESTFLDPR2 as the program to run when values are written/read from the table.

I stole Kent Milligan's code from an article he wrote. Here is the
link to the article and code:
http://www.mcpressonline.com/database/db2/enable-transparent-encryptio
n-with-db2-field-procedures.html#sthash.BA9pIdAt.dpuf

Before creating the table, I put TESTFLDPR2 in debug. When I ran the CREATE, I watched the registration occur and then it went through the encode portion of the code. All seems good.

Then I INSERTED a row into the table, debug is still active, and there is no indication that the code was run...the debugger didn't show me the steps.

INSERT INTO TESTFILE VALUES('2345678901', 'abcdefgh23')

I looked at the data using a simple SELECT and the data was as I inserted it...presumably due to being decoded...but again...the debugger didn't show me.

SELECT * FROM TESTFILE

....+....1....+....2....+.
NORMALFIELD FIELDWITHPROC
2345678901 abcdefgh23

So I DROPped the FIELDPROC:

ALTER TABLE TESTFILE ALTER COLUMN FIELDWITHPROC DROP FIELDPROC

I reran the SELECT and expected to see encoded data, but got the same results as before.

To me, it seems that the data was never encoded in the first place and I can't understand why the FIELDPROC wasn't invoked on the INSERT of my test data.

Have I missed something? Done something wrong?

Steve Needles

________________________________
This communication, including attachments, is confidential, may be subject to legal privileges, and is intended for the sole use of the addressee. Any use, duplication, disclosure or dissemination of this communication, other than by the addressee, is prohibited. If you have received this communication in error, please notify the sender immediately and delete or destroy this communication and all copies.

TRVDiscDefault::1201

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot 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 here. If you have questions about this, please contact