<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="lt">
	<id>https://wiki.eofnet.lt/w//index.php?action=history&amp;feed=atom&amp;title=Perl_DBI_Multi_Insert</id>
	<title>Perl DBI Multi Insert - Versijų istorija</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.eofnet.lt/w//index.php?action=history&amp;feed=atom&amp;title=Perl_DBI_Multi_Insert"/>
	<link rel="alternate" type="text/html" href="https://wiki.eofnet.lt/w//index.php?title=Perl_DBI_Multi_Insert&amp;action=history"/>
	<updated>2026-04-23T19:55:09Z</updated>
	<subtitle>Šio puslapio versijų istorija projekte</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.eofnet.lt/w//index.php?title=Perl_DBI_Multi_Insert&amp;diff=8511&amp;oldid=prev</id>
		<title>\dev\null 08:33, 26 spalio 2017</title>
		<link rel="alternate" type="text/html" href="https://wiki.eofnet.lt/w//index.php?title=Perl_DBI_Multi_Insert&amp;diff=8511&amp;oldid=prev"/>
		<updated>2017-10-26T08:33:57Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Naujas puslapis&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Tiesiog būdas, kai reikia daug įrašų įrašyti viena SQL INSERT užklausa...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;perl&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/perl -w&lt;br /&gt;
# Perl-MySQL MultiInsert With DBI Interface PoC&lt;br /&gt;
use strict;&lt;br /&gt;
use DBI;&lt;br /&gt;
my $dbh = DBI-&amp;gt;connect(&amp;quot;DBI:mysql:testdb:host.eofnet.lt&amp;quot;, &amp;quot;testuser&amp;quot;, &amp;quot;testpassw&amp;quot;,{ PrintError =&amp;gt; 1, RaiseError =&amp;gt; 0 }) or die &amp;quot;can't connect\n&amp;quot;;&lt;br /&gt;
$dbh-&amp;gt;do(qq{drop table if exists testdbi});&lt;br /&gt;
$dbh-&amp;gt;do(qq{create table testdbi&lt;br /&gt;
    (&lt;br /&gt;
 `id` bigint(20) NOT NULL,&lt;br /&gt;
  `data` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,&lt;br /&gt;
  `value` text COLLATE utf8_unicode_ci,&lt;br /&gt;
  `host` text COLLATE utf8_unicode_ci NOT NULL,&lt;br /&gt;
  `log_time` text COLLATE utf8_unicode_ci NOT NULL,&lt;br /&gt;
  `log_host` text COLLATE utf8_unicode_ci NOT NULL,&lt;br /&gt;
  `log_process` text COLLATE utf8_unicode_ci NOT NULL,&lt;br /&gt;
  `log_key` varchar(255) COLLATE utf8_unicode_ci NOT NULL,&lt;br /&gt;
  `address` text COLLATE utf8_unicode_ci NOT NULL,&lt;br /&gt;
  `log_status` text COLLATE utf8_unicode_ci NOT NULL&lt;br /&gt;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;&lt;br /&gt;
    });&lt;br /&gt;
my @records = ( [ 'blastpit', '11:12', 'blastpit', 'smtp', 'AD1FC4B', 'justinas@eofnet.lt', 'OK' ], [ 'blastpit', '11:13', 'blastpit', 'smtp', 'AD1CC4B', 'test@eofnet.lt', 'ERR' ] );&lt;br /&gt;
push(@records,( [ 'naujashost', '11:15', 'blastpitas', 'smtp', 'ADV3C1' , 'heh@eofnet.lt', 'UNKNOWN' ] ));&lt;br /&gt;
push(@records,( [ 'naujashost2', '11:16', 'blastpitas', 'smtp', 'BDV3C1' , 'heh0@eofnet.lt', 'UNKNOWN' ] ));&lt;br /&gt;
my $values = join &amp;quot;, &amp;quot;, (&amp;quot;( ?, ?, ?, ?, ?, ?, ? )&amp;quot;) x @records;&lt;br /&gt;
my $query  = &amp;quot;INSERT INTO testdbi (host,log_time,log_host,log_process,log_key,address,log_status) VALUES $values&amp;quot;;&lt;br /&gt;
my $sth    = $dbh-&amp;gt;prepare($query);&lt;br /&gt;
$sth-&amp;gt;execute(map { @$_ } @records);&lt;br /&gt;
use Data::Dumper qw(Dumper); # dumperis skirta isvesti duomenis pvz, dump array contents&lt;br /&gt;
print Dumper \@records; # print array&lt;br /&gt;
undef @records; # array isvalymas&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Vaizdas:Screenshot at Oct 26 10-18-45.png]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Programavimas]]&lt;br /&gt;
[[Category:Perl]]&lt;br /&gt;
[[Category:Scripts]]&lt;/div&gt;</summary>
		<author><name>\dev\null</name></author>
	</entry>
</feed>