Ver Mensaje Individual
  #4
Antiguo 3 de junio de 2015, 19:56
Kuk
Administrador
Última Actividad 19.09.2026 20:11
Posts Posts: 2.500
Likes enviados Enviados: 1037
Likes recibidos Recibidos: 1207

Josber, en el segundo te falta una coma:

Código SQL:
  1. EXEC SQL
  2.           FETCH cursor_tabla
  3.                 INTO  :LPNUM    /* <== AQUI!!! */
  4.                          AES_DECRYPT(:LPPRO1,'FaCtUrAcIóN'),
  5.                          AES_DECRYPT(:LPPRO2,'FaCtUrAcIóN'),
  6.                          AES_DECRYPT(:LPPRO3,'FaCtUrAcIóN'),
  7.                          AES_DECRYPT(:LPPRO4,'FaCtUrAcIóN'),
  8.                          AES_DECRYPT(:LPPRO5,'FaCtUrAcIóN'),
  9.                          AES_DECRYPT(:LPPRO6,'FaCtUrAcIóN')
  10.      END-EXEC.

En cuanto a lo de NULL, haces todo bien. El problema es (según he leído), la longitud de los campos encriptados. Es decir, si usas VarChar, debes saber la longitud exacta e indicarsela a la hora de decriptar. Si algo no le cuadra, devuelve NULL:

Cita:
The answer is that the columns are binary when they should be varbinary. This article explains it:

Because if AES_DECRYPT() detects invalid data or incorrect padding, it will return NULL.

With binary column types being fixed length, the length of the input value must be known to ensure correct padding. For unknown length values, use varbinary to avoid issues with incorrect padding resulting from differing value lengths.
Para indicar la longitud, graba todo con la misma longitud y haz SELECT indicando esa misma longitud. Cómo se declaraban los VarChar en COBOL creo que te lo comenté. Si no te acuerdas, te lo pongo otra vez.
Si no tienes datos muy largos, usa Char



NORMAS DEL FORO - para garantizar el buen funcionamiento del Foro.
¿Te han ayudado? NO TE OLVIDES de darle a
¿Quieres dirigirte a alguien en tu post? Notifícale haciendo clic en su Nick
Kuk is offline   Responder Con Cita