mnlight has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: ct_cmd_alloc failed
by jZed (Prior) on Aug 10, 2007 at 15:25 UTC
    That's a lot of code to ask us to read through. And you don't tell us basic information like what driver/RDBMS you are using. But a simple search turns up this possibly helpful tidbit.
Re: ct_cmd_alloc failed
by derby (Abbot) on Aug 10, 2007 at 15:59 UTC

    See Re: Can't execute sql.

    I would say you're referencing dbh incorrectly somewhere in your code. Setting the connection as a global but then passing around references to the global while also sometimes using the global is a recipe for disaster.

    -derby

    Update: also ... what does $app->disconnect($$dbh) do? Does it do a dbh disconnect as well? That could be a problem.

      The $app->disconnect() was the problem. Thank you
Re: ct_cmd_alloc failed
by shmem (Chancellor) on Aug 10, 2007 at 16:11 UTC
    Prior to posting, you should do some basic cleanup like running your script through at least perltidy -io to get the indentation right.

    That helps a lot with reading. Then, I can't match the line numbers of the errors you get with the script:

    ct_cmd_alloc failed at ./chris_create_login.pl line 348, <STDIN> line +1. no statement executing at ./chris_create_login.pl line 350, <STDIN> li +ne 1. 346 $sth->execute(); 347 348 while ( my ( @array ) = $sth->fetchrow_array() ) { 349 $result .= "\t $array[0] \t $array[1] \n"; 350 } ct_cmd_alloc failed at ./chris_create_login.pl line 173, <STDIN> line +1. 170 $sth->execute(); 171 172 my $servers = $sth->fetchall_arrayref(); 173 174 $sth->finish(); 175 Can't call method "prepare" on an undefined value at ./chris_create_lo +gin.pl line 195, <STDIN> line 1. 192 my $sth = $$dbh->prepare($sql) 193 or app->error($ERROR, "Can't prepare SQL statement [ $sq +l ] :: $DBI::errstr"); 194 195 $sth->execute(); 196 197 my $idvalues = $sth->fetchall_arrayref(); 198

    It seems like you altered the script after you got the errors, and before posting.

    I can not figure out why one sub routine works and another one does not.

    Some basic debugging techniques could help, like printing arguments to subroutines to STDERR. Then, check whether your database handle really is and does what you expect it to do, before you do anything with it. Look up the ping method in the DBI doc and the docs for your database driver. See also brian's Guide to Solving Any Perl Problem.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}