您好,我需要导出这些密钥,值,导出时即可,请分享您的想法,
我的数据文件
Oct 1 06:25:45 github.com: { "pid":14428, "ppid":14397, "program":"upload-pack", "git_dir":"/data/repo/testorg/testrepo.git", "cmdline":"git-upload-pack --stateless-rpc .", "repo_name":"testrepo", "hostname":"github.com", "pusher":"testuserusha", "real_ip":"192.168.1.", "user_agent":"git/1.7.0", "transaction_id":"c0124fc145ffgwss677", "frontend":"github.com", "frontend_pid":20470, "frontend_ppid":20029, "repo_id":1355, "repo_public":true, "repo_guest_branches_enabled":false, "repo_config":"{}", "user_id":7068, "user_login":"testuser", "user_operator_mode":false, "pgroup":"13428", "status":"create_pack_file", "features":"", "cloning":true, "uploaded_bytes":4223321, "uploaded_bytes_rate":2929, "uploaded_bytes_last":1412222qq556 }
Oct 2 06:35:45 github.com github_audit: {"actor_ip":"127.0.0.1","note":"From Git","user":"testuser","user_id":null,"actor":"testuser","actor_id":null,"org_id":null,"action":"user.failed_login","created_at":141225644589,"data":{"actor_location":{"location":{"lat":null,"lon":null}}}}
Oct 2 06:40:45 github.com github_audit: {"actor_ip":"127.0.0.1","note":"From Git","user":"Username for 'https","user_id":null,"actor":"Username for 'https","actor_id":null,"org_id":null,"action":"user.failed_login","created_at":1412256464790,"data":{"actor_location":{"location":{"lat":null,"lon":null}}}}
我无法在此处添加完整代码
my @values = values %hash;
my $dbh = DBI->connect("DBI:Oracle:host=$host;port=1500;SID=$sid",$user,$passwd);
my $sth = $dbh->prepare("INSERT INTO AUDIT_TABLE(id, value) VALUES (?,?);");
$sth->execute_array({},\@keys, \@values);
输出
VALUE:
DBD::Oracle::st execute_array failed: ORA-00911: invalid character (DBD ERROR: error possibly near <*> indicator at char 60 in 'INSERT INTO AUDIT_TABLE(id, value) VALUES (:p1,:p2)<*>;') [for Statement "INSERT INTO AUDIT_TABLE(id, value) VALUES (?,?);"] at 1.pl line 43, <IN> line 1.
我已经使用了这段代码
my @values = @hash{qw(id value)};
my $dbh = DBI->connect("DBI:Oracle:host=$host;port=1521;SID=$sid",$user,$passwd);
my $sth = $dbh->prepare("INSERT INTO AUDIT_TABLE(id, value) VALUES (?,?)");
$sth->execute_array({},\@keys, \@values);
我收到此错误
DBD::Oracle::st execute_array failed: ORA-00911: invalid character (DBD ERROR: error possibly near <*> indicator at char 60 in 'INSERT INTO GITHUB_AUDIT_HISTORY(id, value) VALUES (:p1,:p2)<*>;') [for Statement "INSERT INTO AUDIT_TABLE(id, value) VALUES (?,?);"] at 1.pl line 44, <IN> line 1.
答案 0 :(得分:1)
问题是分号终止你的陈述。 This isn't valid
SQL查询结束时的分号是SQL编辑器/命令行实用程序(例如SQL * Plus)的一个功能,而不是数据库本身。它们只能作为复合语句的一部分发送到服务器(例如BEGIN...END
或创建过程)。
答案 1 :(得分:1)
它是分号,必须是这样的:
my $sth = $dbh->prepare("INSERT INTO GITHUB_AUDIT_HISTORY(id, value) VALUES (?,?)");