Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Using DBI to extract from 2 databases

by marto (Cardinal)
on Apr 24, 2013 at 12:15 UTC ( [id://1030373]=note: print w/replies, xml ) Need Help??


in reply to Using DBI to extract from 2 databases

Your code is a little messy. Firstly add:

use strict; use warnings;

And work through those problems. You have variables declared out of scope then try to use them later, for example $table_name.This isn't going to work. Also, please consider the advice I gave last time you asked a databae question.

Update: On second look this is a little more messy that I thought. The advice about strict and warnings stands, see line 55, the sql statement uses a variable $ntime, which is never declared. Check for errors when doing anything with DBI, either with the RaiseError constructor, or manually each time.

Replies are listed 'Best First'.
Re^2: Using DBI to extract from 2 databases
by space_monk (Chaplain) on Apr 24, 2013 at 15:16 UTC

    Your code is a little messy
    is an understatement similar in magnitude to
    the Titanic has hit a little iceberg and has a tiny hole in it
    :-)

    If any of my proposed solutions have minor errors, it's because I don't waste my genius on trivial matters. :-P

      It's hardly this disaster you liken it to. With the advice given and a few minutes the existing code could be made less messy. Most DB issues would be caught by enabling RaiseError, advice has been given (in a previous thread also) on place holders, redundant variables would identified and easily resolved.

      With this out of the way OP can concentrate on the bigger issues which have been highlighted by resolving these trivial problems. Hopefully the exercise of cleaning this up would help with learning why such things are important, and how to think about approaching problems like this in future.

        Yes, I know - I gave an answer to try and resolve most of the issues below. My "titanic" response was just me succumbing to the Dark Side... :-)

        If any of my proposed solutions have minor errors, it's because I don't waste my genius on trivial matters. :-P

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1030373]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-03-28 16:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found