/
record.coretag
56 lines (52 loc) · 1.54 KB
/
record.coretag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright 2002-2007 Interchange Development Group and others
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. See the LICENSE file for details.
UserTag record addAttr
UserTag record attrAlias column col
UserTag record attrAlias code key
UserTag record attrAlias field col
UserTag record PosNumber 0
UserTag record Version 1.4
UserTag record Routine <<EOR
sub {
my ($opt) = @_;
my $db = $Vend::Database{$opt->{table}};
return undef if ! $db;
$db = $db->ref();
# This can be called from Perl
my (@cols, @vals);
my $hash = $opt->{col};
my $filter = $opt->{filter};
return undef unless defined $opt->{key};
my $key = $opt->{key};
return undef unless ref $hash;
undef $filter unless ref $filter;
@cols = keys %$hash;
@vals = values %$hash;
RESOLVE: {
my $i = -1;
for(@cols) {
$i++;
if(! defined $db->test_column($_) ) {
splice (@cols, $i, 1);
my $tmp = splice (@vals, $i, 1);
::logError("bad field %s in record update, value=%s", $_, $tmp);
redo RESOLVE;
}
next unless defined $filter->{$_};
$vals[$i] = filter_value($filter->{$_}, $vals[$i], $_);
}
}
my $status;
eval {
my $status = $db->set_slice($key, \@cols, \@vals);
};
if($@) {
return $@ if $opt->{show_error};
}
return $status;
}
EOR