Link to home
Start Free TrialLog in
Avatar of johnmemor
johnmemor

asked on

MS SQL in Perl ?

Here is my "select" part :

#!C:\perl\bin\perl

use DBI;
$dbHandle = (DBI->connect('DBI:ADO:DSN', 'sa', ''));
$sql = "SELECT * FROM Test";
$statementHandle = $dbHandle->prepare($sql);
$statementHandle->execute() || die $statementHandle->errstr;

while (($cat1) = $statementHandle->fetchrow_array )
{
     print $cat1."\n";
 }

Above script works fine.  I just wonder how can I insert some value into the table ?
May I have some example script for insert ?
Avatar of johnmemor
johnmemor

ASKER

Here is my "insert" part :

#!C:\perl\bin\perl

 use DBI;
 $dbHandle = (DBI->connect('DBI:ADO:DSN', 'sa', ''));
 $sql = "insert into Test (name) values(\"some_value\")";
 $statementHandle = $dbHandle->prepare($sql);
 $statementHandle->execute() || die $statementHandle->errstr;


I got error after execution.
ASKER CERTIFIED SOLUTION
Avatar of Paul Maker
Paul Maker
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How can I get the row count ?

This is what I have :

$rowCount = $dbh->do($sql);
print $rowCount."\n";


and I got -1, I have more than 1 record in the table.