Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How the apex_collection.add_member generates the MD5 checksum?

PaoloMJun 29 2007 — edited Jun 29 2007

Hello,
I hope somebody can help me understand how the apex_collection.add_member function is calculating the MD5 checksum when the parameter p_generate_md5 is set to YES.

For example, if I add several items as a collection member and I generate its MD5 checksum, I get a certain MD5 sum, but if I run the wwv_flow_item.md5() function passing to it the single item values I used in the collection, I am not able to regenerate the MD5 checksum from the collection. Here is my example process:

DECLARE
  l_cksum VARCHAR2(32767);
  l_seq_id NUMBER(15);

  CURSOR C_data
  IS
    SELECT * FROM EMP
     WHERE ENAME = 'MARTIN';

  Curr_row C_data%ROWTYPE;
BEGIN
  -- fetch data
  OPEN C_data;
  FETCH C_data INTO Curr_row;
  CLOSE C_data;

  -- init fields
  APEX_UTIL.SET_SESSION_STATE('P1_EMPNO', Curr_row.EMPNO);
  APEX_UTIL.SET_SESSION_STATE('P1_ENAME', Curr_row.ENAME);

  -- create a collection
  apex_collection.create_or_truncate_collection('MYTEST');

  -- add a collection member and calculate its checksum
  l_seq_id := apex_collection.add_member(
                     p_collection_name => 'MYTEST'
                    ,p_c001 => v('P1_EMPNO')
                    ,p_c002 => v('P1_ENAME')
                    ,p_generate_md5  => 'YES');

  -- fetch the original checksum for the collection members
  SELECT md5_original
    INTO l_cksum
    FROM apex_collections
   WHERE collection_name = 'MYTEST'
     AND seq_id = l_seq_id;

  -- print it
  HTP.p('<BR>Checksum from query on collection: '||l_cksum);

  -- recalculate the current checksum for the collection members
  l_cksum := APEX_COLLECTION.GET_MEMBER_MD5(
                      p_collection_name => 'MYTEST',
                      p_seq             => l_seq_id);

  -- print it
  HTP.p('<BR>Checksum calculated from current collection: '||l_cksum);
  -- this is OK

  -- recalculate the checksum of the current items I used in the collection
  l_cksum := wwv_flow_item.md5(
                      v('P1_EMPNO'),
                      v('P1_ENAME') );

  -- print it again
  HTP.p('<BR>Checksum calculated with wwv_flow_item.md5(): '||l_cksum);
  -- this checksum is different: WHY?
END;

What am I doing wrong?

Thanks,
Paolo

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 27 2007
Added on Jun 29 2007
2 comments
1,122 views