in reply to Win32::ODBC query error

When you debug and set your breakpoint on the $sql2=... line try typing:
x %data
To see what you actually have. I suspect your first query is somehow messing up or you don't have a good connection to the database and your error trapping code not defined $db2 may be failing. Just a guess though. What kind of database are you using?

Celebrate Intellectual Diversity

Replies are listed 'Best First'.
Re^2: Win32::ODBC query error
by nicpon (Initiate) on Aug 30, 2005 at 18:38 UTC
    I`m using MSSQL. For example if take that query and put it into the mssql client(replace $vars with names )then it works fine. Its just when i make call from the script it doesnt work. The error says:
    Query error at F:\perl\rozne\ucfirst.pl line 20. I can pull data from that table without any problem.
      I normally ask questions about debugging because it seems to be an area of discontent for some Win32 users. Perhaps it is an aversion to the command line? You start a debugging session like so:
      perl -d scream.pl
      And you wind up in a strange screen with line numbers and package information and what-not on the left hand side. Type the letter l ("L" and not the number one) to see the current line:
      DB<1> l 5==> my $text = "my text [and maybe|and here's] more text [the end| +stop]"; 6: my @arr = parseit($text); 7: print "$_\n" for @arr; 8 9 sub parseit { ...
      And use b to set a breakpoint. The small letter r will run you to that breakpoint:
      DB<1> b 7 DB<2> r main::(scream.pl:7): print "$_\n" for @arr; DB<2>
      Now, to look at variables you can print them out, using p:
      DB<2> p @arr my text and maybe more text the endmy text and maybe more text stopmy +text and h ere's more text the endmy text and here's more text stop DB<3>
      Or, much better, you can examine them using x:
      DB<3> x @arr 0 'my text and maybe more text the end' 1 'my text and maybe more text stop' 2 'my text and here\'s more text the end' 3 'my text and here\'s more text stop'
      When you are done you can use the single letter q to get out of the debugging session. There is more to it, but that is the basics. Perldoc perldebug tells you all this and so much more. Give it a whirl.

      Celebrate Intellectual Diversity