gpt4 book ai didi

mysql - Perl DBD 错误 FUNCTION dbName.GLOB 不存在

转载 作者:行者123 更新时间:2023-11-29 05:31:41 26 4
gpt4 key购买 nike

我开始为一些 cron 作业编写一些 Perl 脚本,这些作业将查询数据库并发送有关即将发生的事件的提醒。我对 Perl 中的数据库访问还很陌生,因为到目前为止我的大部分工作都是在 Web 端使用 PHP 进行的。无论如何,第一个查询可以正常生成一个临时输出文件,然后我在该输出文件中回读以循环查询结果,以查找在第一个查询中发现的用户的特定事件。

我现在遇到的问题是出现以下错误:

./remind.pl 
DBD::mysql::st execute failed: FUNCTION dbName.GLOB does not exist at ./remind.pl line 41.
SQL Error: FUNCTION dbName.GLOB does not exist

这是我的 Perl 代码

$host = 'localhost';
$database = 'dbName';
$user = 'user';
$password = 'password';

use POSIX qw(strftime);
use List::MoreUtils qw(uniq);
use Mail::Sendmail;
use DBI;

$dt = strftime("%Y%m%d%H%M%S", localtime(time));
$List30 = "../tmp/queries/30DayUserList.$dt";
open my $UserList30Day, ">> $List30" or die "Can't create tmp file: $!";

$dbh = DBI->connect('dbi:mysql:dbName',$user,$password) or die "Connection error: $DBI::errstr\n";

$sql = "SELECT DISTINCT user FROM shows WHERE initial_date BETWEEN CURDATE() AND CURDATE() + INTERVAL 30 DAY";
$sth = $dbh->prepare($sql);
$sth->execute or die "SQL Error: $DBI::errstr\n";

while (@jeweler = $sth->fetchrow_array()) {
print $UserList30Day "$user[0]\n";
}
close $UserList30Day;

open my $UserIDList, "< $List30" or die "Can't open temp file: $List30";

while ($id = $UserIDList) { # Read in User ID from temp file as $id
# Query for show information for next 30 days

my $sql = "SELECT shows.initial_date, shows.initial_time, shows.hostess_key, hostess.hostess_fname, hostess.hostess_lname, hostess.primary_phone, hostess.address1, hostess.address2, hostess.city, hostess.zipcode, hostess.state
FROM shows, hostess
WHERE shows.user = $id
AND initial_date BETWEEN CURDATE() AND CURDATE() + INTERVAL 30 DAY
AND shows.hostess_key = hostess.hostess_key";
my $sth = $dbh->prepare($sql);
$sth->execute or die "SQL Error: $DBI::errstr\n";

# Iterate thru query results to create output data
while (@row = $sth->fetchrow_array()) {
$content = "Reminder: You have a show for $row[3] $row[4] coming up on $row[0] at $row[1].\n";
$content .= "Location: $row[6] \n";
if ($row[7] != '') {
$content .= " " . $row[7] . "\n";
}
$content .= " $row[8], $row[10] $row[9] \n";
$content .= "Phone: $row[5] \n";
}

%mail = (To => 'email',
From => 'email',
Subject => 'Just another test',
Message => $content
);

# sendmail(%mail) or die $Mail::Sendmail::error;
print %mail;
}
close $UserList30Day;

在此先感谢您的帮助。

最佳答案

while ($id = $UserIDList) {

应该是

while ($id = <$UserIDList>) {
chomp;

关于mysql - Perl DBD 错误 FUNCTION dbName.GLOB 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14149078/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com