Yii CDbException.. invalid input syntax for integer: "1,075" - sql

I started receiving this error from a production site since this morning and I'm wondering why I don't get the same in UAT or the developer environment..
Is any one familiar with an error like this ?
CDbException
Description
CDbCommand failed to execute the SQL statement: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "1,076"
Source File
C:\inetpub\wwwroot\framework1.0\db\CDbCommand.php(372)
00360: }
00361:
00362: if($this->_connection->enableProfiling)
00363: Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');
00364:
00365: return $result;
00366: }
00367: catch(Exception $e)
00368: {
00369: if($this->_connection->enableProfiling)
00370: Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');
00371: Yii::log('Error in querying SQL: '.$this->getText().$par,CLogger::LEVEL_ERROR,'system.db.CDbCommand');
00372: throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
00373: array('{error}'=>$e->getMessage())));
00374: }
00375: }
00376: }
Attached a screenshot too.. the application is based on yii framework and postgress database.
Quick reply is highly appreciated.

The issue was actually because used number_format() function to a primary key and later in a code section it inputs the formatted number to search query.. i.e select * from user where id = 1,075 (instead of id = 1075)
Changing the number_format() function to apply only on selected areas worked.

Related

apex addError - remove default error message

I have added addError to my record like in the following.
v.addError('My Error message');
But I get the error message like in the following.
I don't want the default part "Error: Invalid Data. Review all error messages to correct your data".
I tried adding to some field instead of adding it to the whole record.
But in this case, it implies that the error is specific to what the user has entered in that field. But this is not what I want. My error is record specific.
In a nutshell, based on some condition, I want to stop a record being inserted. This is actually to be added to before insert of my trigger.
Please help.
Try this Code for field level error message:
trigger AccountTrigger on Account (before insert) {
for(Account accIns :trigger.new){
if(accIns.Rating == 'Hot'){
accIns.Rating.addError('My Error message');
}
}
}

Unable to query using file in Data Proc Hive Operator

I am unable to query with .sql file in DataProcHiveOperator.
Though the documentation tells that we can query using file. Link of the documentation Here
It is working fine when I give query directly
Here is my sample code which is working fine with writing query directly:
HiveInsertingTable = DataProcHiveOperator(task_id='HiveInsertingTable',
gcp_conn_id='google_cloud_default',
query='CREATE TABLE TABLE_NAME(NAME STRING);',
cluster_name='cluster-name',
region='us-central1',
dag=dag)
Querying with file :
HiveInsertingTable = DataProcHiveOperator(task_id='HiveInsertingTable',
gcp_conn_id='google_cloud_default',
query='gs://us-central1-bucket/data/sample_hql.sql',
query_uri="gs://us-central1-bucket/data/sample_hql.sql
cluster_name='cluster-name',
region='us-central1',
dag=dag)
There is no error on sample_hql.sql script.
It is reading file location as a query and throwing me the error as:
Query: 'gs://bucketpath/filename.q'
Error occuring - cannot recognize input near 'gs' ':' '/'
Similar issue has also been raised Here
The issue is because you have passed query='gs://us-central1-bucket/data/sample_hql.sql' as well.
You should pass exactly 1 of query or queri_uri.
The code in your question has both of them, so remove query or use the following code:
HiveInsertingTable = DataProcHiveOperator(task_id='HiveInsertingTable',
gcp_conn_id='google_cloud_default',
query_uri="gs://us-central1-bucket/data/sample_hql.sql",
cluster_name='cluster-name',
region='us-central1',
dag=dag)

java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist error message in netbeans 8.0.1

when i was trying to delete all records form Oracle database using the following code i got this exception,
QUERYY:: delete from DMUSER.CAMERA_DATA1
java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
Actually here I wanted to create a data mining application using oracle SQL developer and the netbeans IDE. So my workflow is looks like as follow in oracle SQL developer,
The code part that I have used to delete a record from database as follows,
public void deleteData()throws SQLException {
Statement stmt = null;
String query = "delete from DMUSER.CAMERA_DATA1";
System.out.println("QUERYY:: " + query);
try {
stmt = getConnection().createStatement();
int rs = stmt.executeUpdate(query);
if (rs > 0) {
System.out.println("<-------------------Record Deleted--------------->");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (stmt != null) {
stmt.close();
}
}
}
I'm very new to the environment and searched many related questions even in stack but couldn't find exact answer which makes my work successful. Please help me to solve this.
QUERYY:: delete from DMUSER.CAMERA_DATA1
java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not
exist
You need to check, if CAMERA_DATA1 table/view exists in DMUSER schema or not.
Try connecting to same database and schema and check, if table exist or not. If not, then you need to create this table/view in same schema.
Referring to your screenshot provided, I can see CAMERA_DATA table instead of CAMERA_DATA1. So, you can either correct the SQL query to below
String query = "delete from DMUSER.CAMERA_DATA";

SQLExecDirect failed but SQLGetDiagRec has no data

I'm trying to setup some useful error handling in a program that used ODBC. According to documentation if SQLExecDirect returns SQL_ERROR I should be able to call SQLGetDiagRec to get SQL_STATE and possibly some messages, but in my tests when I call SQLGetDiagRec right after getting an error from SQLExecDirect I get SQL_NO_DATA returned and no information.
Code:
result = SQLExecDirect(hstmt, <SQL Statement>, SQL_NTS);
if(result == SQL_ERROR)
{
SQLSMALLINT msg_len = 0;
SQLCHAR sql_state[6], message[256];
SQLINTEGER native_error = 0;
result = SQLGetDiagRec(SQL_HANDLE_DBC, hDbc, 1, sql_state, &native_error, message, countof(message), &msg_len);
// Here 'result' is SQL_NO_DATA
....
}
It works in other cases, just not for SQLExecDirect for some reason. I'm also aware that one should cycle through the SQLGetDiagRec results, but if the very first one returns SQL_NO_DATA, according to documentation it means that there are no further ones.
The specific error that I was testing it with was requesting a non-existent table.
Is there anything else that I need to do in order obtain at least an error code, or does the diagnostic not work for errors that result from incorrect SQL requests?
When you call SQLGetDiagRec, pass SQL_HANDLE_STMT and your statement handle (hstmt in your example). That should return errors associated with that specific statement.

java.sql.SQLException: ORA-03115: unsupported network datatype or representation

I'm Using Oracle 11g database. When i try to access data from db it was showing the error java.sql.SQLException: ORA-03115: unsupported network datatype or representation. I'm not understanding what this error means..
my code is :
String uname,pass;
ResultSet rs = null;
response.setContentType("text/html");
PrintWriter out=response.getWriter();
try
{
uname=request.getParameter("uname");
pass=request.getParameter("pass");
Connection con=prepareConnection();
String Query="select uname from passmanager where pass=?";
PreparedStatement ps=con.prepareStatement(Query);
ps.setString(1,pass);
rs=ps.executeQuery(Query);
if (rs.next() && uname.equalsIgnoreCase(rs.getString("uname")) || uname.equalsIgnoreCase(rs.getString("email"))) {
HttpSession session = request.getSession(true);
session.setAttribute("uname", rs.getString(1));
ServletContext context = getServletContext();
RequestDispatcher dispatcher = context
.getRequestDispatcher("/profile");
dispatcher.forward(request, response);
}
Any one help me to solve this problem..
Instead of:
rs = ps.executeQuery(Query);
you should execute:
rs = ps.executeQuery();
Otherwise, you unprepare your statement and lose all parameters because you assign it a new SQL statement (even though it's the same).
This error appears when you try to get a field by name ( rs.getString("uname") in your case) which is not in the resultset.
And like igr said, you are trying to get the email field ( with rs.getString("email") ) and it's not in the query, so this is your error.
I found this conversation because I was getting the same error in an application when I was trying to get a field with an whitespace at the end of the string ( rs.getString("uname ") instead of rs.getString("uname" ).
And I just fix it using the correct name for the field I was getting from the query.
I hope it is useful! ;)
Add email column
select uname, email from passmanager where pass=?