我的数据库正在使用PostgreSQL.一个表使用serial自动增量宏.如果我想在表中插入记录,是否仍需要指定该值,还是会自动为我分配?
CREATE TABLE dataset
(
id serial NOT NULL,
age integer NOT NULL,
name character varying(32) NOT NULL,
description text NOT NULL DEFAULT ''::text
CONSTRAINT dataset_pkey PRIMARY KEY (id)
);
Run Code Online (Sandbox Code Playgroud) 我使用pgsql设置触发器,当更新表数据集(将状态更改为已完成)时,它将使用数据集电子邮件值自动向电子邮件帐户发送电子邮件并将此电子邮件保存在服务器中
但我不知道如何写入触发功能来发送电子邮件,并在服务器中发送电子邮件.先感谢您
Pg版本为9.1,CentOS 5.8
CREATE OR REPLACE FUNCTION sss()
RETURNS trigger AS
$BODY$begin
if(NEW.publisher== 'aaaa')
then
//send email and save to server 192.168.171.64
end if;
return NEW;
end
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION sss()
OWNER TO postgres;
GRANT EXECUTE ON FUNCTION sss() TO postgres;
Run Code Online (Sandbox Code Playgroud) 我使用PostgreSQL,我想在pl/perl中创建一个函数,但PostgreSQL不包含pl/perl.
当我输入createlang plperlu databasename它时显示:
createlang:语言安装失败:错误:无法打开扩展控制文件"/usr/local/pgsql/share/extension/plperlu.control":没有这样的文件或目录
我该如何安装plperlu?
PostgreSQL版本在CentOS 5.8中为9.1
我需要将 csv 文件上传到 postgresql 数据库表。csv文件就像
A B C D E F
16777216 16777471 AU AUSTRALIA OC OCEANIA
16777472 16778239 CN CHINA AS ASIA
16778240 16779263 AU AUSTRALIA OC OCEANIA
16779264 16781311 CN CHINA AS ASIA
Run Code Online (Sandbox Code Playgroud)
桌子是
CREATE TABLE ipligence
(
ip_from numeric(11,0) NOT NULL DEFAULT 0,
ip_to numeric(11,0) NOT NULL DEFAULT 0,
country_code character varying(10)[] NOT NULL,
country_name character varying(225)[] NOT NULL,
continent_code character varying(10)[] NOT NULL,
continent_name character varying(255)[] NOT NULL,
CONSTRAINT ipligence_pkey PRIMARY KEY (ip_to )
)
WITH …Run Code Online (Sandbox Code Playgroud) 启动Jira时,我遇到以下错误.
你会如何建议解决这个问题?
You cannot access JIRA at present. Look at the table below to identify the reasons
Description
The following plugins are required by JIRA, but have not been started:
Atlassian JIRA - Plugins - Project Config Plugin (com.atlassian.jira.jira-project-config-plugin)
Atlassian OAuth Admin Plugin (com.atlassian.oauth.admin)
Embedded Gadgets Plugin (com.atlassian.gadgets.embedded)
Gadget Dashboard Plugin (com.atlassian.gadgets.dashboard)
Atlassian JIRA - Plugins - Look And Feel Logo Upload Plugin com.atlassian.jira.lookandfeel)
Atlassian REST - Module Types (com.atlassian.plugins.rest.atlassian-rest-module)
Gadget Spec Publisher Plugin (com.atlassian.gadgets.publisher)
Atlassian JIRA - Plugins - …Run Code Online (Sandbox Code Playgroud) 这是代码
open IN, '</root/Desktop/out.txt' or die "Cannot open file : $!";
while (<IN>) {
chomp $_;
$seq_no= $_;
my @this_seq=();
if($seq_no=~ m/^complement\(/){
push(@this_seq,1);
$seq_no=~ s/complement\(//g;
if($seq_no=~ m/^order/){
push(@this_seq,2);
$seq_no=~ s/order//g;
$seq_no=~ s/\(//g;
$seq_no=~ s/\)//g;
#my @temp = split(/,/, $seq_no);
push @this_seq,$seq_no;
print "@this_seq \n";
}
}
else
{
$seq_no=~ s/\(//g;
$seq_no=~ s/\)//g;
push @this_seq,$seq_no;
#print "@this_seq \n";
}
push @sequence,\@this_seq;
}
print @sequence;
Run Code Online (Sandbox Code Playgroud)
输出文件是
complement(order(1843..1881,1923..2001,2065..2147, 2216..2277,2330..2468))
773..1447
Run Code Online (Sandbox Code Playgroud)
但是,当我打印@sequence时,它就会得到
ARRAY(0x119adb8)ARRAY(0x117e6b0)
Run Code Online (Sandbox Code Playgroud)
我已经在推入数组时添加\ @this_seq,但它仍然显示内存地址,任何人都可以告诉我如何更改它以显示数组内容.
我对这个例子中的perl子例程参数感到困惑
当我在子程序参数中使用引用时,它可以工作:
@a = ( 1, 2 );
@b = ( 5, 8 );
@c = add_vecpair( \@a, \@b );
print "@c\n";
print $a[0];
sub add_vecpair { # assumes both vectors the same length
my ( $x, $y ) = @_; # copy in the array references
my @result;
@$x[0] = 2;
for ( my $i = 0; $i < @$x; $i++ ) {
$result[$i] = $x->[$i] + $y->[$i];
}
return @result;
}
Run Code Online (Sandbox Code Playgroud)
但是当我不使用引用作为这样的参数时:
@a = ( 1, 2 ); …Run Code Online (Sandbox Code Playgroud) 可能重复:
psql触发器发送电子邮件
我使用PL/Perl语言在Postgresql中发送邮件.当数据集表upload_status更改为已发布时,它会将邮件发送到数据集表中作者的电子邮件地址.并且在信中包含此作者在数据集中的一些记录.数据集PK是标识符.
例如从xx@mail.com发送到(dataset.email)@ mail.com
亲爱的博士(dataset.author)
你的......(dataset.product)已经.......
那么如何使用PL/Perl和触发函数来编写函数.
谢谢,我使用这种方法http://evilrouters.net/2008/02/01/send-email-from-postgresql/
mydb=# CREATE OR REPLACE FUNCTION mydb_mytable_insert_send_mail_function()
mydb-# RETURNS "trigger" AS
mydb-# $BODY$
mydb$# use Mail::Sendmail;
mydb$#
mydb$# $message = "A new entry has been added to the 'mytable' table.\n\n";
mydb$# $message .= "The new name is: $_TD->{new}{name}\n\n";
mydb$#
mydb$# %mail = ( From => $_[0], To => $_[1], Subject => $_[2], Message => $message);
mydb$#
mydb$# sendmail(%mail) or die $Mail::Sendmail::error;
mydb$# return undef;
mydb$# $BODY$
mydb-# LANGUAGE 'plperlu' VOLATILE;
mydb=# …Run Code Online (Sandbox Code Playgroud) 我有很多短阵
@seq1 /773..1447/ @seq2 /1 2 1843..1881 1923..2001/
Run Code Online (Sandbox Code Playgroud)
但我用推
push(@add, @seq1);
push(@add, @seq2);
Run Code Online (Sandbox Code Playgroud)
但它显示它将所有数组合并为一个不能再获得每个子数组
/773..1447 1 2 1843..1881 1923..2001/
Run Code Online (Sandbox Code Playgroud)
当我使用
$number=@add;
Run Code Online (Sandbox Code Playgroud)
它显示6,但它应该是2.任何人都可以解释原因以及如何改变它.
当我使用for循环添加每个数组
for(..){
@temp= split(/,/,$_);
push(@add, \@temp);
}
Run Code Online (Sandbox Code Playgroud)
然后当我打印@add; 它只显示内存地址,如何显示@add中的所有数据
我喜欢哈希
key value
1 ababababab
11 cdcdcdcdcd
21 efefefefef
31 fgfgfgfgfg
41 ererererer
Run Code Online (Sandbox Code Playgroud)
现在我有一个数组[0] = 5数组[1] = 22如何从5-22得到字符串
abababababcdcdcdcdcdef
Run Code Online (Sandbox Code Playgroud)
我计划使用foreach比较5和22的键,但我不知道如何解决它.