Saturday, August 29, 2009

ORDImage type for Database ORACLE10g

CREATE OR REPLACE PROCEDURE MICR.Dpr_Insert_ORDImage (p_date in date,p_batch in number) IS
   
  Image_front ORDSYS.ORDImage;
  Image_rear ORDSYS.ORDImage;
  ctx RAW(6000) := NULL;
  vDocumentNum outwdclr.document_num%type;
  v_ErrorText Error_Tab."ErrorText"%type:= Null;
  v_ErrorCode Error_Tab."ErrorCode"%type:= Null;  
  vImage ORDSYS.ORDImage;  
  vWidth_f INTEGER; -- image.getWidth);
  vHeight_f INTEGER; -- image.getHeight);
  vWidth_r INTEGER; -- image.getWidth);
  vHeight_r INTEGER; -- image.getHeight);
  vContentLength INTEGER; -- image.getContentLength);
  vImageFileFormat_f VARCHAR2(4000); -- image.getFileFormat);
  vImageFileFormat_r VARCHAR2(4000); -- image.getFileFormat);
  vContentFormat VARCHAR2(4000); -- image.getContentFormat);
  vCompressionFormat_f VARCHAR2(4000); -- image.getCompressionFormat);
  vCompressionFormat_r VARCHAR2(4000); -- image.getCompressionFormat);
  vMimeType_f VARCHAR2(4000); -- image.getMimeType);
  vMimeType_r VARCHAR2(4000); -- image.getMimeType);
   
  vMyCommands VARCHAR2(4000);
   
BEGIN
  
  --vMyCommands := 'fileFormat=tiff compressionFormat=packbits contentFormat = 8bitlut';
  /*** Inserting ORDImage with Update of OUTWDCLR table ***/ 
  For i in (select document_num,
  check_number||bank_code||district_code||branch_code||check_digit||chk_actnum||tran_code Image_name 
  from outwdclr
  where document_date = p_date
  and batch_no = p_batch  
  and nvl(post_flag,'N') = 'N')
  Loop
   
  Insert Into MICR.OUT_IMAGE(document_num ,
  document_date , 
  batch_no , 
  image_front ,
  image_rear ,
  entry_timestamp ,
  entry_by)
  Values (i.document_num ,
  p_date , 
  p_batch , 
  ORDSYS.ORDImage.init(),
  ORDSYS.ORDImage.init(),
  sysdate ,
  'SYSTEM'
  );
   
   
  Select image_front,image_rear 
  Into Image_front,Image_rear 
  From out_image
  Where document_date = p_date
  and batch_no = p_batch 
  and document_num = i.document_num for UPDATE;  
   
  Image_front.setSource('FILE','MY_IMAGE_DIR',i.Image_name||'_Front.tif');
  Image_front.import(ctx);
  Image_rear.setSource('FILE','MY_IMAGE_DIR' ,i.Image_name||'_Rear.tif');
  Image_rear.import(ctx);
   
  vWidth_f := Image_front.getWidth ;
  vHeight_f := Image_front.getHeight ;
  vWidth_r := Image_rear.getWidth ;
  vHeight_r := Image_rear.getHeight ;
  vImageFileFormat_f := image_front.getFileFormat ;
  vImageFileFormat_r := image_rear.getFileFormat ;
  vCompressionFormat_f := image_front.getCompressionFormat;
  vCompressionFormat_r := image_rear.getCompressionFormat ;
  vMimeType_f := image_front.getMimeType ;
  vMimeType_r := image_rear.getMimeType ;
   
  --vMyCommands := 'compressionFormat=packbits';
  --Image_front.processCopy(vMyCommands, Image_front);
  --Image_rear.processCopy(vMyCommands, Image_rear);
   
  Update out_image 
  set image_front = Image_front ,
  image_rear = Image_rear , 
  width_front = vWidth_f ,  
  height_front = vHeight_f ,
  width_rear = vWidth_r ,
  height_rear = vHeight_r ,
  file_fmt_front = vImageFileFormat_f , 
  file_fmt_rear = vImageFileFormat_r ,  
  com_fmt_front = vCompressionFormat_f , 
  com_fmt_rear = vCompressionFormat_r ,
  mime_type_front = vMimeType_f ,
  mime_type_rear = vMimeType_r ,  
  update_timestamp = sysdate ,
  update_by = 'SYSTEM'
  Where document_num = i.document_num
  and document_date = p_date
  and batch_no = p_batch;
   
  End Loop;  
  
  COMMIT;  
  
   
Exception
  when others then Null;
END;
/

No comments:

Post a Comment