sql-insert

What does the MySQL mean by “Column count doesn't match value count at row 1”

本秂侑毒 提交于 2020-05-24 05:19:09
问题 This is the message I'm getting ER_WRONG_VALUE_COUNT_ON_ROW: Column count doesn't match value count at row 1 This is my whole code. Where is my mistake? DROP TABLE student; CREATE TABLE employee ( emp_id INT PRIMARY KEY, first-name VARCHAR(40), birth_day DATE, sex VARCHAR(1), SALARY INT, super_id INT, branch_id INT ); CREATE TABLE branch ( branch_id INT PRIMARY KEY, branch_name VARCHAR(40), mgr_id INT, mgr_start_date DATE, FOREIGN KEY(mgr_id) REFERENCES employee(emp_id) ON DELETE SET NULL );

PostgreSQL INSERT into an array of enums

谁说胖子不能爱 提交于 2020-05-10 07:35:25
问题 How can I insert an array of enums ? Here is my enum : CREATE TYPE equipment AS ENUM ('projector','PAsystem','safe','PC','phone'); Then my table has an array of equipment: CREATE TABLE lecture_room ( id INTEGER DEFAULT NEXTVAL('lecture_id_seq') , seatCount int , equipment equipment[] ) INHERITS(venue); Here is my ATTEMPT to INSERT: INSERT INTO lecture_room (building_code, floorNo, roomNo, length, width , seatCount, equipment) VALUES ('IT', 4, 2, 10, 15 ,120, ARRAY['projector','PAsystem','safe

SQL SERVER - Trigger to restrict over 3 records

此生再无相见时 提交于 2020-04-30 07:05:06
问题 I am a beginner on SQL and need help setting a Trigger I need to set a trigger so that if 1 tutor has over 3 different schedule ID's this is not allowed!! Table TutorID/ScheduleID/Student 1 1 Tom 1 1 Harry 1 1 Lima 1 2 Zany 1 2 Logan 1 3 Zoe 1 3 Lana Tutor ID/ Tutor Name 1 Sam how can I restrict someone from inserting another class? 回答1: DISCLAIMER: To be completely honest I'm not convinced doing this through a SQL Trigger is the best solution, far better to control this sort of thing through

DB insertion PHP script freezing randomly, no error log

♀尐吖头ヾ 提交于 2020-04-30 06:28:41
问题 I have a script that I run as a cron job every X minutes. It is being run on VPS using Apache, Centos, Maria DB 10.2, 6 Cores and 8GB of RAM. I applied a mechanism to prevent the script from running again if the current run didn't finish yet. It seems to run fine about 99% of the time. However, in a random manner, sometimes the script would just "freeze". The log file that the script is creating will either stop at one point before the EOE, or a 0 bytes log file will be created without

What does the MySQL mean by “Column count doesn't match value count at row 1”

一世执手 提交于 2020-04-30 06:25:19
问题 This is the message I'm getting ER_WRONG_VALUE_COUNT_ON_ROW: Column count doesn't match value count at row 1 This is my whole code. Where is my mistake? DROP TABLE student; CREATE TABLE employee ( emp_id INT PRIMARY KEY, first-name VARCHAR(40), birth_day DATE, sex VARCHAR(1), SALARY INT, super_id INT, branch_id INT ); CREATE TABLE branch ( branch_id INT PRIMARY KEY, branch_name VARCHAR(40), mgr_id INT, mgr_start_date DATE, FOREIGN KEY(mgr_id) REFERENCES employee(emp_id) ON DELETE SET NULL );

Parametized INSERT query with node-mssql

坚强是说给别人听的谎言 提交于 2020-04-16 05:48:31
问题 I want to parametrize an insert query with node.js for SQL Server. Unfortunately it will not work and I don't really know if it's a Node module issue or a syntax failure. Code: server.route({ method: 'POST', path: '/', handler: async (request, h) => { try { await pool.query("INSERT INTO sigfoxmessages(device,data,station,rssi,unix_timestamp) VALUES($1,$2,$3,$4,$5))" [request.payload.device, request.payload.data, request.payload.station, request.payload.rssi, request.payload.time]); return h

Does SQLScript for SAP HANA support the use of INSERT with CTEs (Common Table Expressions)?

旧城冷巷雨未停 提交于 2020-03-25 21:23:05
问题 I know this isn't a specific bit of code or problem, but I am having trouble with a very similar issue to the person asking this (except theirs is for SQL Server): Combining INSERT INTO and WITH/CTE ...and I can't seem to find it out there on any SAP HANA help forums etc. so thought there may be an expert on here who can just give me a simple yes or no answer. The SQL statement I am using contains multiple CTEs, but when I try to insert it tells me there is a Syntax error around the word

python sqlite3 record is not inserting into the database with a placeholder function

余生长醉 提交于 2020-03-25 17:44:11
问题 this code is not inserting my list(self.list2) into the database 'main.db'. I read the the following posts already and they all seem to use the idea of using join() to create # of place holders based on the length of the list. Dynamically creating a placeholder to insert many column values for a row in SQLite table Inserting to sqlite dynamically with Python 3 the code is running without errors. I tested the code by printing return (f"{', '.join('?' * len(input))}") and it prints "?, ?, ?, ?

Insert Python NumPy array into PostgreSQL database

限于喜欢 提交于 2020-02-28 07:19:38
问题 How do I insert a large array of coordinates (x,y) into a postgresSQL table? I don't want to use a for loop. It is a raster with 3601x3601 pixels. import numpy as np import psycopg2 # Data example: east = np.linspace(-180.0,180.0,num=10) north = np.linspace(-90.0,90.0,num=10) coor = np.vstack([east, north]) conn = psycopg2.connect("dbname='postgres' user='dbuser' host='localhost' password='dbpass'") cur = conn.cursor() cur.execute("DROP TABLE IF EXISTS foobar;") cur.execute("CREATE TABLE

Should I trim values in SQL or ColdFusion?

我们两清 提交于 2020-02-25 05:24:47
问题 I have done many inserts/updates and question that always was on the top of my mind is where I should trim the values that I'm inserting or updating. In this case I use ColdFusion as my server-side programming language and SQL Microsoft is my database language. So if I'm doing insert, should I trim the values in ColdFusion or SQL? Do I have to do in both? What is more efficient? I was wondering if this can improve efficiency if I follow some recommended steps. Here is example that I have in