1

My sqlQuery is this:

sqlQuery := 'SELECT sa.nombre_archivo, sha.registrosok, sha.registroserroneos,'||
            ' sha.registrosinconsistentes,'||
            ' (sha.registrosok+sha.registroserroneos+sha.registrosinconsistentes),'||
            ' sha.fechaprocesamiento'||
              ' FROM src_historialarchivo sha, src_archivo sa, src_usuario su'||
            ' WHERE sa.idarchivo = sha.idarchivo'||
              ' AND sa.nombre_archivo LIKE ''%:1%'''||
              ' AND sa.idusuario = su.idusuario'||
              ' AND isvalidrange(sha.fechaprocesamiento,:2,:3) = ''T'''||
            ' ORDER BY to_date(sha.fechaprocesamiento, ''DD/MM/YYYY'')';

But there's seems to be a problem with the binding-variable :1, how to solve it? The error thrown is java.sql.SQLException: ORA-01006

1 Answer 1

2

Try it like this:

sqlQuery := 'SELECT sa.nombre_archivo, sha.registrosok, sha.registroserroneos,'||
            ' sha.registrosinconsistentes,'||
            ' (sha.registrosok+sha.registroserroneos+sha.registrosinconsistentes),'||
            ' sha.fechaprocesamiento'||
              ' FROM src_historialarchivo sha, src_archivo sa, src_usuario su'||
            ' WHERE sa.idarchivo = sha.idarchivo'||
              ' AND sa.nombre_archivo LIKE :1'||
              ' AND sa.idusuario = su.idusuario'||
              ' AND isvalidrange(sha.fechaprocesamiento,:2,:3) = ''T'''||
            ' ORDER BY to_date(sha.fechaprocesamiento, ''DD/MM/YYYY'')';

execute immediate sqlQuery using '%abc%';
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks that worked! ... Why do the binding variables aren't recognized if they are between quotes?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.