dbi

How do I connect with Perl to SQL Server?

て烟熏妆下的殇ゞ 提交于 2019-12-02 18:31:52
I have a user id, password, database name and datasource details. I want to connect with Perl to a MSSQL server. I just used the following snippet, but I am getting an error. #!/usr/bin/perl -w use strict; use DBI; my $data_source = q/dbi:ODBC:192.168.3.137/; my $user = q/bharani/; my $password = q/123456/; # Connect to the data source and get a handle for that connection. my $dbh = DBI->connect($data_source, $user, $password) or die "Can't connect to $data_source: $DBI::errstr"; My error is: DBI connect('192.168.3.137','bharani',...) failed: [Microsoft][ODBC Driver Manager] Data source name

Shutdown MSSQL server from perl script DBI

爱⌒轻易说出口 提交于 2019-12-02 17:21:37
问题 I'm writing a perl script in which I've to shutdown my mssql server ,do some operation and then I've to restart it.I know 1 way is to use netstat to stopt the service but I cann't use that. So I tried installing DBI and DBD::ODBC module.I'm able to connect and execute queries by following code use DBI; my $data_source = q/dbi:ODBC:AUTOMATION_WOW64/; my $user = q/pa/; my $password = q/DCE/; # Connect to the data source and get a handle for that connection. my $dbh = DBI->connect($data_source,

Can't locate DBI.pm in @INC (you may need to install the DBI module) [duplicate]

拟墨画扇 提交于 2019-12-02 17:07:16
问题 This question already has answers here : What's the easiest way to install a missing Perl module? (24 answers) How can I use a new Perl module without install permissions? (11 answers) Closed 2 years ago . I want to use the Defects4j dataset,when I do this follow the page of github: https://github.com/rjust/defects4j $ defects4j checkout Lang Can't locate DBI.pm in @INC (you may need to install the DBI module) (@INC contains: /c/Users/Liu Fang/defects4j/framework/lib /c/Users/Liu Fang

Perl DBI Error Msg: Can't call method “selectcol_arrayref” on an undefined value

喜你入骨 提交于 2019-12-02 16:22:39
问题 my $dblinks = ''; $dblinks = $dbh->selectcol_arrayref("select db_link from db_links where ticket=\'LOW\'"); my $success = 0; for my $dblink (@$dblinks) { $success = eval { my ($ret) = $dbh->selectrow_array("select 1 from " . $dbh->quote_identifier($dblink, 'SYSIBM', "SYSDUMMY1") ); $ret; }; if ($success) { &Logging (3, $I, "connect_${G_CONNECT_COUNT}", "Connect success for $dblink"); } else { # Read thru the selectcol_array, check for an oracle error $l_msg="$dblink Result doesn't match 1";

Querying multiple times in Oracle using perl returns only the first query

牧云@^-^@ 提交于 2019-12-02 13:16:36
Note: I have corrected the variable differences and it does print the query from the first set but it returns nothing from the second set. If I use the second set only it works. In the code below, I have some_array which is array of array the array contains text like name. So @some_array= ([sam, jon, july],[Mike, Han,Tommy],[angie, sita, lanny]); Now when I querying the list like 'sam jon july' first and 'mike han tommy' . Only the execute return the result from the first list others is undef. I don't know why any help will be appreciated. my $pointer; my $db = $db->prepare_cached(" begin

Win 64 Strawberry Perl DBI no error reporting bug still not fixed?

匆匆过客 提交于 2019-12-02 10:31:41
Been dealing with this since 2011. Usually able to work around it. Now a situation has arisen where I really need to be able to handle errors, and I'm thinking, people have known about this problem for years, it seems like the sort of thing high up on the fix list, but the latest DBI upgrade and the problem still has not been resolved. Has anyone found a work-around, or know how to hack the libraries and get DBI::errstr to carry a value when there is an error? Here's my code (And yes I am aware of the problems w/ a blank root password): use strict; use DBI; use DBD::mysql; use Data::Dumper; my

Shutdown MSSQL server from perl script DBI

杀马特。学长 韩版系。学妹 提交于 2019-12-02 09:46:29
I'm writing a perl script in which I've to shutdown my mssql server ,do some operation and then I've to restart it.I know 1 way is to use netstat to stopt the service but I cann't use that. So I tried installing DBI and DBD::ODBC module.I'm able to connect and execute queries by following code use DBI; my $data_source = q/dbi:ODBC:AUTOMATION_WOW64/; my $user = q/pa/; my $password = q/DCE/; # Connect to the data source and get a handle for that connection. my $dbh = DBI->connect($data_source, $user, $password) or die "Can't connect to $data_source: $DBI::errstr"; my $str=$dbh->prepare("select

DBI begin_work doesn't work with stored procedure calls

ぐ巨炮叔叔 提交于 2019-12-02 04:40:04
问题 I am trying to make a call to a stored procedure from with in a transaction in its simplified form: my $dbh= DBI->connect(............ ); my $sth = $dbh->prepare("call sp_get_workitems (1,1)"); $dbh->begin_work or die $dbh->errstr; $sth->execute(); my ($result)= $sth->fetchrow_array(); $dbh->commit; this gives the following error : DBD driver has not implemented the AutoCommit attribute If I replace the begin_work statement with $dbh->{'AutoCommit'} = 0; (before or after the prepare), I get

DBI begin_work doesn't work with stored procedure calls

ε祈祈猫儿з 提交于 2019-12-02 02:18:19
I am trying to make a call to a stored procedure from with in a transaction in its simplified form: my $dbh= DBI->connect(............ ); my $sth = $dbh->prepare("call sp_get_workitems (1,1)"); $dbh->begin_work or die $dbh->errstr; $sth->execute(); my ($result)= $sth->fetchrow_array(); $dbh->commit; this gives the following error : DBD driver has not implemented the AutoCommit attribute If I replace the begin_work statement with $dbh->{'AutoCommit'} = 0; (before or after the prepare), I get this error: DBD::mysql::db commit failed: Commands out of sync; you can't run this command now If I

DBD::CSV and placeholders

自作多情 提交于 2019-12-02 00:06:06
#!/usr/bin/env perl use warnings; use strict; use DBI; my $dbh = DBI->connect( "DBI:CSV:", '', '', { RaiseError => 1 } ) or die DBI->errstr; my $table = 'my_test_table_1.csv'; $dbh->do( "CREATE TEMP TABLE $table( id INTEGER, name CHAR(64) )" ); my $sth = $dbh->prepare( "INSERT INTO $table ( id, name ) VALUES( ?, ? )" ); $sth->execute( 1, 'Ruth' ); $sth->execute( 2, 'John' ); $sth->execute( 3, 'Nena' ); $sth->execute( 4, 'Mark' ); $sth = $dbh->prepare( "SELECT * FROM $table WHERE id > ? LIMIT ?" ); $sth->execute( 1, 2 ); $sth->dump_results; # Bad limit clause! at /usr/local/lib/perl5/site_perl