'Columname' cannot be modified because it is either a computed column or is the result of a UNION operator - edmx

I keep getting the following error when I try to insert a record into a table:
[ColumnName] cannot be modified because it is either a computed column or is the result of a UNION operator.
This column is actually a computed column, but I simply added the table to the EDMX and now it gives this error when I insert. Obviously I am not trying to insert into the computed column, but it still throws this error.
Does anyone know how I can solve this?

Related

Create table with some column's type defined as some function's returning type

The following SQL statement will create a table t, with a column c1, whose type is defined as bigint(21) unsigned, which is the returning type of function INET_ATON:
CREATE TABLE t AS SELECT INET_ATON('0.0.0.0') AS c1;
But the statement also inserts a row. I wonder if there is a way to create the table and make its columns' type defined as some function's returning type, without inserting a row.
I tried the following:
CREATE TABLE t LIKE SELECT INET_ATON('0.0.0.0') AS c1;
But this doesn't match the SQL syntax.
Any ideas on how to achieve this? Thanks!
PS: Any standard SQL statement is OK, the MariaDB or MySQL supported statement is also OK.
use where clause to create a condition which will never be true like below:
CREATE TABLE t AS SELECT INET_ATON('0.0.0.0') AS c1 where 1=2;
This will create the table without adding any rows into it.

Update view from function when function calculate value using the same view

I have a View that that contains two columns. Column c1, and column c2.
c1 is updated by a function getPrice().
The problem is that get getPrice() calculate is´s value by using column c2.
This causes mysql to send out error message :
ERROR 1424 (HY000): Recursive stored functions and triggers are not allowed
Is there any way to resolve this?
SELECT and UPDATE can be decoupled through a temporary table: select new values into temporary table and update source table from it.

unexpected error 1054 in sql

After table setup, I suddenly remember to update it by adding one column and assign all the same value to that column. So I wrote the queries on Workbench like this
ALTER TABLE sthebc3_cle ADD COLUMN Species char(30) AFTER Genome_ACC;
SET SQL_SAFE_UPDATES=0;
UPDATE cle.sthebc3_cle
SET Species='StHe';
But it reported error like
error 1054: unknown column "Species" in "field list
I checked table after ALTER, The new column "Species" was indeed added to the column and values are NULL.
How could be the error reported?
You need to make sure that the current session is the database you want. There is always a selected database in MySQL.
If you want to be 100% sure which database you are using you Always put nameofthedatabase.tablename,
For the table
ALTER TABLE cle.sthebc3_cle ADD COLUMN Species char(30) AFTER Genome_ACC;
SET SQL_SAFE_UPDATES=0;
UPDATE cle.sthebc3_cle
SET Species='StHe';
For you view, try this
USE cle;
CREATE VIEW all_cle AS
(SELECT Species, Genome_ACC, CLE_start, CLE_end, CLE_domain
FROM nameofdatabase.cowpea_cle)
UNION
(SELECT Species, Genome_ACC, CLE_start, CLE_end, CLE_domain
FROM nameofdatabase.sthebc3_cle);

Inserting datetime value into sql server table column

I'm attempting to insert a datetime('2013-08-30 19:05:00') value into a SQL server database table column(smalldatetime) and the value stays "NULL" after the insert.
I'm doing this to 6 other columns that are the exact same type. What is this only occuring on one column? I've triple checked that the names of the columns are correct. Any ideas?
Assuming the situation is as you describe
CREATE TABLE T
(
S SMALLDATETIME NULL
)
INSERT INTO T
VALUES('2013-08-30 19:05:00')
SELECT *
FROM T /*Returns NULL*/
There are only two ways I can think of that this can happen.
1) That is an ambiguous datetime format. Under the wrong session options this won't cast correctly and if you have some additional options OFF it will return NULL rather than raise an error (e.g.)
SET LANGUAGE Italian;
SET ansi_warnings OFF;
SET arithabort OFF;
INSERT INTO T
VALUES('2013-08-30 19:05:00')
SELECT *
FROM T /*NULL inserted*/
2) You may have missed the column out in an INSTEAD OF trigger, or have an AFTER trigger that actually sets the value back to NULL.

MySQL 'Subquery returns more than 1 row Error'

I have run the following query over 200 times without an error:
INSERT INTO tempAbsenceClientUpload SELECT FirstName, LastName, UserID, UserIsActive, Email, TopClient, ClientGroup, isUpdated, MainProcessID, rownumber FROM temporaryAbsClientTable
Which simply takes from one table to another.
However, I now get the following error message: Subquery returns more than 1 row Error
Can anyone help me to understand why?
I don't really want alternative code suggestions, just why it happened.
Thanks.
There was an 'on insert' trigger on the destination table. The data being entered was referenced against a third table in an expression expecting a single result (two results were being generated).
So the 'sub routine' was connected to a function in a trigger on the destination table firing due to the insert.
Thanks for everyone's ideas.
You might have duplicates in the second table.
IN that case you could do this to eliminate them:(create a copy of your table first)
ALTER IGNORE TABLE tableName ADD UNIQUE KEY keyName (`columnName`);
OR to check for duplicates:
select columnNameWithDuplicates, count(*) from tableName group by (columnNameWithDuplicates) having count(*)>1;
I think you are missing a WHERE clause which is giving this error