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

DBI answer! (was Re: ODBC question)

by BBQ (Deacon)
on May 10, 2000 at 07:51 UTC ( #10884=note: print w/replies, xml ) Need Help??

in reply to ODBC question

Well, the 1st way around it that I can think of would be to drop Win32::ODBC (unless you REALLY need it) and switch do DBD::ODBC! Not only will you be joining the "standard" in perl database programing, but you'll be able to port your code with minor modifications (not to say none) to other database systems. Here's a sample of what you how you would do it:
# 1st prepare the SQL with placeholders $sth = $dbh->prepare(qq{ INSERT INTO Comment ( Field1, Field2 ) VALUES ( ?,? ) }) or die("Failed to prepare ".$DBI::errstr); # now execute what you've prepared with the variables $rv = $sth->execute($val1,$val2) or die("Failed to execute ".$DBI::errstr);
(btrott wrote a complete select example back in March that also addresses placeholders)

Get the general drift? It gets better... Now you're using ODBC, and I'd guess that you're running Access or MS-SQL, right? If you switch to DBI, you'll be able to connect directly to Oracle, Informix, MySQL and others without the need for ODBC standing as a middle man. Seriously, look into DBI/DBDs, you won't regret it!

# Trust no1!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://10884]
and the universe expands...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2017-11-18 14:49 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (277 votes). Check out past polls.