Jue Oct 12, 2006 1:30 pm
|
 |
Juan JOse
Perlero Nuevo

|
Registrado: 21 Sep 2006
Mensajes: 10
Ubicación: Desarrollo
|
|
|
|
|
Saludos:
Tengo ahora un problema al escribir un Query, quiero ejecutar el siguiente:
| SQL: | SELECT count(*) FROM empleados WHERE rfc=algo AND nombre LIKE 'paterno%materno' |
Pero necesito que paterno y materno sean variables. Intenté el siguiente código:
| Perl: | 47: $prep= "select count(*) from empleados where rfc=? and nombre like \'?\%?\' ";
48: my $sth= $dbh prepare ($prep);
49: $sth-> execute($rfc, $paterno, $materno);
50: $n_registros = $sth-> fetchrow_array();
51: print "$n_registros registros encontrados";
52: $sth-> finish;
95: if($n_registros eq "0" ){
105: if($n_registros eq "1" )
|
Y me salen los siguientes mensajes de error:
| Código: |
[Thu Oct 12 15:15:05 2006] [error] [client xxx.xxx.xxx.xxx] DBD::Informix::st execute failed: called with 3 bind variables when 1 are needed at /var/www/cgi-bin/sueldo.pl line 49., referer: http://xxx.xxx.xxx.xxx/cgi-bin/sueldo.pl
[Thu Oct 12 15:15:05 2006] [error] [client xxx.xxx.xxx.xxx] DBD::Informix::st fetchrow_array failed: SQL: -400: Fetch attempted on unopen cursor. at /var/www/cgi-bin/sueldo.pl line 50., referer: http://xxx.xxx.xxx.xxx/cgi-bin/sueldo.pl
[Thu Oct 12 15:15:05 2006] [error] [client xxx.xxx.xxx.xxx] Use of uninitialized value in concatenation (.) or string at /var/www/cgi-bin/sueldo.pl line 51., referer: http://xxx.xxx.xxx.xxx/cgi-bin/sueldo.pl
[Thu Oct 12 15:15:05 2006] [error] [client xxx.xxx.xxx.xxx] Use of uninitialized value in string eq at /var/www/cgi-bin/sueldo.pl line 95., referer: http://xxx.xxx.xxx.xxx/cgi-bin/sueldo.pl
[Thu Oct 12 15:15:05 2006] [error] [client xxx.xxx.xxx.xxx] Use of uninitialized value in string eq at /var/www/cgi-bin/sueldo_base1.pl line 105., referer: http://xxx.xxx.xxx.xxx/cgi-bin/sueldo.pl |
Ojalá alguno de uds pueda ayudarme, aún me falta mucho por aprender de Perl. Gracias nuevamente. |
|
|
|


Vie Oct 13, 2006 1:32 pm
|
 |
Juan JOse
Perlero Nuevo

|
Registrado: 21 Sep 2006
Mensajes: 10
Ubicación: Desarrollo
|
|
|
|
|
Saludos:
Se resolvio el problema escibiendo la sentencia como me recomendaste
$prep = "select count(*) from cheque where rfc=? and nombre like \"$paterno\%$materno\%\" ";
my $sth = $dbh->prepare($prep);
$sth->execute($rfc);
Gracias. |
|
Powered by phpBB © 2001, 2005 phpBB Group
|