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.
It's the semicolon, it must be this:
my $sth = $dbh->prepare("INSERT INTO GITHUB_AUDIT_HISTORY(id, value) VALUES (?,?)");
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).
Related
here is my statement in jupyter notebook
##check time frame to fill shift feature
t2=dfOriginal['From']
time1=np.datetime64('1900-01-01T07:00:00')
time2=np.datetime64('1900-01-01T15:00:00')
time3=np.datetime64('1900-01-01T23:00:00')
for index in dfOriginal.iterrows():{
if(t2>=time1 & t2 <time2):
}
example of what i have in From column '1900-01-01T07:00:00'
From data type is datetime64[ns]
i get this error
File "<ipython-input-64-2685fa7977d0>", line 7
if(t2>=time1 & t2 <time2):
SyntaxError: invalid syntax
I have a Google Apps Script linked to a Sheet that takes Form responses. I'm getting this error:
I've figured out that 104 is the line number where the error occurs. What does 14 represent? Both numbers are the same every time the error occurs. For context's sake, here's some of the code:
if (Renaming) {
Debug("Renaming Began")
var Section = Values[4]
var Name = Values[5].replace(/\//g, "-").concat(" ", Values[3], "-", Values[2].substring(0, 1)) // Date, space, last name, hyphen, first initial
Debug("Renaming Files...")
DriveApp.getFileById(Documents[0]).setName(Section.concat(" Session Plan ", Name)) // Session plan naming (this is line 104)
Debug("Session Plan Renamed")
DriveApp.getFileById(Documents[1]).setName(Section.concat(" Sign-in ", Name))
Debug("Sign-in Sheet Renamed")
if (Documents.length > 2) {
Debug("Worksheets Detected")
Debug(Documents.length)
for (i = 2; Documents.length; i++) {
if (i > 13) {break}
Debug(("Began ").concat(i))
if (!Documents[i]) {continue}
Debug(("Exists ").concat(i))
DriveApp.getFileById(Documents[i]).setName(Section.concat(" Worksheet #", i - 1, " ", Name))
Debug(("Renamed ").concat(i))
}
Debug("Worksheets Renamed")
}
Debug("Renaming Completed")
} else {
Debug("Renaming Disabled")
}
Explanation:
From this expression: 104:14:
104: represents the row where the error occured.
14: represents the column where the error occured.
Column is defined as the position of each character in the document on the horizontal axis. Each symbol/space/letter/number occupies one column of space.
Example:
the error here is in the 2nd row and there are 2 spaces (columns) before the word error.
But the error starts at the letter e of the word error. So you have 2 spaces (columns) before error plus a letter which is the position where the error started. Two spaces and one letter equals to 3 columns. Therefore, you have an error that is located in the 3rd column.
In your case, the error is located at the row 104 and there are 13 symbols/spaces/letters or numbers before the command that introduces the error. Everything before column 14 is correct. The error starts at column 14.
I am trying load a csv file into the oracle database and facing this error :
cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number
Can you please help to understand the root cause and possible fix for this issue?
def main():
ConStr = 'UserName/PWD#END_POINT'
con = cx_Oracle.connect(ConStr)
cur = con.cursor()
with open('Persons.csv','r') as file:
read_csv = csv.reader(file,delimiter= '|')
sql = "insert into Persons (PERSONID,LASTNAME,FIRSTNAME,ADDRESS,CITY) values (:1,:2,:3,:4,:5)"
for lines in read_csv :
print(lines)
cur.executemany(sql,lines)
cur.close()
con.commit()
con.close();
My csv file looks like below :
PERSONID|LASTNAME|FIRSTNAME|ADDRESS|CITY
001|abc|def|ghi|jkl
002|opq|rst|uvw|xyz
From the Oracle documentation:
import cx_Oracle
import csv
. . .
# Predefine the memory areas to match the table definition
cursor.setinputsizes(None, 25)
# Adjust the batch size to meet your memory and performance requirements
batch_size = 10000
with open('testsp.csv', 'r') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
sql = "insert into test (id,name) values (:1, :2)"
data = []
for line in csv_reader:
data.append((line[0], line[1]))
if len(data) % batch_size == 0:
cursor.executemany(sql, data)
data = []
if data:
cursor.executemany(sql, data)
con.commit()
I am trying to execute an oracle sql query in while loop of a PERL script as follows --
my $dbh = DBI->connect( 'dbi:Oracle:'.$dbname,
$dbusername,
$pass,
{ PrintError => 0,
RaiseError => 1
}
) || die "Erreur lors de la connexion: $DBI::errstr";
print ("Connexion à la base de données $dbname avec $dbusername OK \n");
$requete = "select distinct to_char(date_appli,'yyyymmdd') from DATE_APPLI ".
"where frequence = 'Q' and actif = 1";
$sth_sql = $dbh->prepare($requete);
$sth_sql->execute();
#row=$sth_sql->fetchrow_array;
$datesitu=#row[0];
$sth_sql->finish;
print "La date de situation est $datesitu \n";
# SQL to get validation script and table names
$requete = "select SCRIPT_NAME, table_name from fdf_scripts";
$sth_sql = $dbh->prepare($requete);
$sth_sql->execute();
$sth_sql->bind_columns(undef, \$script_name, \$table_name);
while ($sth_sql->fetch()) {
$script_sql="$sql_path\\"."FDF_Test_scripts\\".$script_name.".sql"; #validation script path
$script_log="$log_path\\".$script_name.".log"; #log files path
$rep_file_name="$sql_path\\"."FDF_Test_scripts\\".$table_name.".sql"; #reports SQL path
$csv_file="$sql_path\\"."FDF_Test_scripts\\".$table_name.".csv"; #report CSV path
#Load data into validation tables using validation scripts
$CmdText="sqlplus -s $connect \#$script_sql $script_log";
print "Inserting data into table : $table_name \n";
#system ("$CmdText");
$col_sql = "select COLUMN_NAME from all_tab_cols where TABLE_NAME = upper(\'$table_name\')\n";
print "$col_sql\n";
$sth_sql = $dbh->prepare($col_sql);
$sth_sql->execute();
$sth_sql->bind_columns(undef, \$COLUMN_NAME);
while ($sth_sql->fetch()) {
print "$COLUMN_NAME\n";
}
if (open (my $fh, '<:encoding(UTF-8)', $script_log)){
while (my $line = <$fh>){
if ($line=~m/\bERROR\b/){
print "Error While Loading $table_name table Please Check log file for errors at: $script_log \n";
}
}
}
else {
warn "Could open file: $script_log \n"
}
}
in above code i am fetching table names from a table and then looping them to get the column names of each table which is present in that table.
The code got executed for one iteration of inner while loop but throw error for next iteration as below --
DBD::Oracle::st fetch failed: ERROR no statement executing (perhaps you need to call execute first) [for Statement "select COLUMN_N\
AME from all_tab_cols where TABLE_NAME = upper('FDF_Bond_validation_results')
I am not proficient in PERL and just started to using this and not sure how can i overcome this problem.
Please let me know if more information is required.
In the loop, the line $sth_sql = $dbh->prepare($col_sql); overwrite the content of the $sth_sql variable. The second time the loop run, the content of $sth_sql isn't the same and the statement that overwrote it has already been exhausted (trying to fetch from it again is what causes the error).
To correct this issue you should either use a different name for the second $sth_sql variable or simply declare the second $sth_sql variable with my to keep it inside the loop (see perldoc -f my).
Note: This solution has been identified by JGNI in the comment of the question. My role has only be to summarize the issue to provide a proper answer to this question.
I am facing the field in data file exceeds maximum length in sql loader error while loading the data to oracle.
//Below control file is used for sqlldr
// Control File: Product_Routing_26664.ctl
//Data File: phxcase1.pr
//Bad File: Product_Routing_26664.bad
LOAD DATA
APPEND INTO TABLE PEGASUSDB_SCHEMA.PRODUCT_ROUTING
FIELDS TERMINATED BY "^"
TRAILING NULLCOLS
(
OID_INST
,SEQ
,ROUTING_TYPE CHAR "(CASE WHEN trim(:ROUTING_TYPE) IS NULL THEN ' ' ELSE trim(:ROUTING_TYPE) END)"
,ODPD_KEY
,PROD_OFFSET
,EFF_DAYS_Z CHAR "(CASE WHEN trim(:EFF_DAYS_Z) IS NULL THEN ' ' ELSE trim(:EFF_DAYS_Z) END)"
,NETWORK_RTG_ID "substr(trim(:NETWORK_RTG_ID), 3, 26)"
,WT0
,WT1
,WT2
,WT3
,WT4
,WT5
,WT6
,WT7
,WT8
,WT9
,WT10
,WT11
,WT12
,WT13
,WT14
,WT15
,WT16
,WT17
,WT18
,WT19
,WT20
,WT21
,WT22
,WT23
,WT24
,WT25
,WT26
,WT27
,WT28
,WT29
,WT30
,WT31
,WT32
,WT33
,WT34
,WT35
,PCS0
,PCS1
,PCS2
,PCS3
,PCS4
,PCS5
,PCS6
,PCS7
,PCS8
,PCS9
,PCS10
,PCS11
,PCS12
,PCS13
,PCS14
,PCS15
,PCS16
,PCS17
,PCS18
,PCS19
,PCS20
,PCS21
,PCS22
,PCS23
,PCS24
,PCS25
,PCS26
,PCS27
,PCS28
,PCS29
,PCS30
,PCS31
,PCS32
,PCS33
,PCS34
,PCS35
,PR_TYPE CHAR "(CASE WHEN trim(:PR_TYPE) IS NULL THEN ' ' ELSE trim(:PR_TYPE) END)"
,PRODUCT_ROUTING_OID "PRODUCT_ROUTING_SQ.nextval"
,COMMON_CASE_OID CONSTANT "1"
,NETWORK_RTG_OID "(select NETWORK_RTG_OID from NETWORK_RTG where NETWORK_RTG_ID = substr(TRIM(:NETWORK_RTG_ID), 3, 26) and COMMON_CASE_OID = 1)"
)
Error: Record 2: Rejected - Error on table
PEGASUSDB_SCHEMA.PRODUCT_ROUTING, column OID_INST. Field in data file
exceeds maximum length
I have tried changing the OID_INST column to OID_INST CHAR(4000) but it shows the same error.
Please help me in resolving this.