Database ERROR QLSTATE[HY000] in cake php - sql

I am trying to create the new data for our project in cakephp. i am having the following database error.
Database Error
Error: SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value
Notice: If you want to customize this error message, create app\View\Errors\pdo_error.ctp
it's keep showing the ID doesn't have the default value and we can't make any change to the ID since it's our PK . Any help would be appreciate !!!!

Related

ActiveRecord::StatementInvalid in Summaries#index

PG::UndefinedColumn: ERROR: column summaries.user does not exist
LINE 1: SELECT "summaries".* FROM "summaries" WHERE "summaries"."use...
I'm trying to make a view restriction, where only the admin can see all the records in an app

Invalid predecessor when editing task in snowflake

I keep getting an error when trying to edit a task on snowflake: whenever I want to edit the task I keep getting the following error message:
SQL-Fehler [91085] [42601]: Invalid predecessor
TableNameA_001_update_newdata was specified.
The task itself looks like this:
CREATE OR REPLACE TASK "TableNameA_001_update_newdata"
WAREHOUSE = marketing_wh
AFTER "TableNameA_001_delete" AS
INSERT INTO tableA
...
By now I do not understand what is triggering the error.
Thanks for your help!
You don't use qualified TASK names (with database and schema in the TASK name).
If you inadvertedly change context (switch database or schema) the new context will not contain any task named "TableNameA_001_delete".
That will result in the error message "Invalid predecessor <TASK name> was specified."

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

Why is my Deployment script causing me errors?

I am working on a project in visual studio 2012. Recently, I added a database project to the solution. The database already existed before I added it to the solution and everything worked fine.
Now, however, when I try to run the application I get errors. The errors are being caused by a computer-generated file called [database name].sql. At the top of the tile, it reads:
/*
Deployment script for [the database name here]
This code was generated by a tool.
Changes to this file may cause incorrect behavior and will be lost if
the code is regenerated.
*/
This file gets re-created every time the application runs. The errors that occur appear to be syntax errors. I cannot fix them because any changes I make to the file are irrelevant because a new file gets generated with each run and the errors re-appear.
I tried looking into this more online but had trouble. This is all rather new to me.
Here are some of the errors being created:
GO
:setvar DatabaseName "(the database name is here)"
which gives me three errors that read:
Error 88 SQL80001: Incorrect syntax near ':'.
Error 89 SQL80001: 'DatabaseName' is not a recognized option.
Error 90 SQL80001: Incorrect syntax near '"(the database name is here in the code)"'.
Also, there is a line of code that reads:
CREATE USER [(the domain)\(the username)] FOR LOGIN [(the domain)\(the username)];
GO
which gives the following error:
Error 119 SQL72014: .Net SqlClient Data Provider: Msg 15401, Level 16, State 1, Line 1 Windows NT user or group '(the domain)\(the username)' not found. Check the name again.
From the errors you have posted it looks like there are two issues:
Windows NT user or group '(the domain)\(the username)' not found. - The user being used to access the database doesn't exist. As it's a Windows user I'm guessing that it uses the current user's credentials.
Make sure that your instance of SQL can accept Windows logins and that you (and anyone else building the software) has the necessary access rights.
'DatabaseName' is not a recognized option. - This is more than likely also caused by the first issue, but double check that the database exists.
The error message caught me out recently as it did not relate to the cause of my problem at all. It turns out my SQL script was incorrectly written (for my case - I forgot to add IDENTITY (1,1) to my PK column) to begin with.
Moral of the story for me was to test out the SQL data file in SSMS first.

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

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.