jeudi 3 septembre 2015

How to handle column default value insert in SQLIte?

Below is the table structure. Insert query and Error message.

Table Structure

CREATE TABLE d0000ke_c_name (
    c_name INTEGER PRIMARY KEY NOT NULL,
    value VARCHAR(255) ,
    sc_version INTEGER ,
    sc_state INTEGER 
);

Insert Query

$sql  = "INSERT INTO d0000kv_c_name SELECT 3 AS 'c_name','manash' AS 'value'   UNION SELECT 2,'ram' UNION SELECT 1,'rahim'";
$statement = $this->odb->prepare($sql);
if (!$statement) {
    echo "\nPDO::errorInfo():\n";
    print_r($this->odb->errorInfo());
}

$statement->execute();

Error message

PDO::errorInfo(): Array ( [0] => HY000 [1] => 1 [2] => table d0000kv_c_name has 4 columns but 2 values were supplied )

Aucun commentaire:

Enregistrer un commentaire