#!/usr/local/bin/perl
BEGIN { use_ok(
'DBI'
);
use_ok(
'DBD::Sybase'
);}
use
vars
qw($Pwd $Uid $Srv $Db)
;
(
$Uid
,
$Pwd
,
$Srv
,
$Db
) = _test::get_info();
my
$dbh
= DBI->
connect
(
"dbi:Sybase:$Srv;database=$Db"
,
$Uid
,
$Pwd
, {
PrintError
=> 0,
syb_flush_finish
=> 1});
ok(
defined
(
$dbh
),
'Connect'
);
if
(!
$dbh
) {
warn
"No connection - did you set the user, password and server name correctly in PWD?\n"
;
for
(4 .. 12) {
ok(0);
}
exit
(0);
}
my
$rc
;
my
$sth
;
SKIP: {
skip 1,
"Test does not work with MS-SQL"
if
$dbh
->{syb_server_version} eq
'Unknown'
||
$dbh
->{syb_server_version} eq
'MS-SQL'
;
my
$sth
=
$dbh
->prepare("
select
* from sysusers
select
* from no_such_table
select
* from master..sysdatabases
");
$rc
=
$sth
->execute;
ok(!
defined
(
$rc
),
'Missing table'
);
}
$sth
=
$dbh
->prepare(
"select * from sysusers\n"
);
$rc
=
$sth
->execute;
ok(
defined
(
$rc
),
'Sysusers'
);
while
(
my
$d
=
$sth
->fetch) {
;
}
$rc
=
$dbh
->
do
(
"create table #test(one int not null primary key, two int not null, three int not null, check(two != three))"
);
ok(
defined
(
$rc
),
'Create table'
);
SKIP: {
skip
'? placeholders not supported'
, 3
unless
$dbh
->{syb_dynamic_supported};
$sth
=
$dbh
->prepare(
"insert #test (one, two, three) values(?,?,?)"
);
$rc
=
$sth
->execute(3, 4, 5);
ok(
defined
(
$rc
),
'prepare w/placeholder'
);
$rc
=
$sth
->execute(3, 4, 5);
ok(!
defined
(
$rc
),
'execute w/placeholder'
);
$rc
=
$sth
->execute(5, 3, 3);
ok(!
defined
(
$rc
),
'execute w/placeholder'
);
}
$sth
=
$dbh
->prepare("
insert
insert
insert
insert
");
$rc
=
$sth
->execute;
ok(!
defined
(
$rc
),
'prepare'
);
$sth
=
$dbh
->prepare(
"select * from #test"
);
$rc
=
$sth
->execute;
ok(
defined
(
$rc
),
'select'
);
while
(
my
$d
=
$sth
->fetch) {
print
"@$d\n"
;
}
$sth
=
$dbh
->prepare("
insert
select
* from
insert
");
$rc
=
$sth
->execute;
ok(
defined
(
$rc
),
'prepare/execute multi'
);
do
{
while
(
my
$d
=
$sth
->fetch) {
print
"@$d\n"
;
}
}
while
(
$sth
->{syb_more_results});
$dbh
->
do
(
"drop table #test"
);