0

Hi I need to export these key, values , i m geeting while export, please share your thoughts,

my data file like this

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}}}}

i m not able to add full code here

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);    

output

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.

I've used this code

    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); 

I am getting this error

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.
coolent
  • 21
  • 8

2 Answers2

2

It's the semicolon, it must be this:

my $sth = $dbh->prepare("INSERT INTO GITHUB_AUDIT_HISTORY(id, value) VALUES (?,?)");
Wernfried Domscheit
  • 38,841
  • 5
  • 50
  • 81
1

The problem is the semicolon terminating your statement. This isn't valid.

Semicolons at the end of SQL queries are a feature of SQL editors/command line utilities (e.g. SQL*Plus), not the database itself. They can only be sent to the server as part of a compound statement (e.g. BEGIN...END or creating a procedure).

Community
  • 1
  • 1