I keep getting the message “ORA-02290: check constraint violated” whenever I try to insert values into my table. Here’s the code for the table STORE: And here’s the INSERT statements I am trying to accomplish: It has created the 4th, 6th, and 7th values, but not the rest. What is going…
Tag: sql-insert
how to INSERT new record with SELECT value in sql
How can i insert a value into table A using return value from table B. I know i can use INSERT INTO SELECT statement but this requires that data types in source and target tables match and the columns are in order but i have the below table like thus: Table A: Table B: Now i want to count all
INSERT INTO a table comparing two other tables using Not EXISTS
I have 3 tables: Server_db_relation DatabaseList DatabaseList_Archive The goal is to compare table Server_db_relation and DatabaseList based on the values in column ServerName and DatabaseName. If the values do not exists in the table Server_db_relation, but do exist in DatabaseList, then it should insert the…
How do I add 1 to a column value on an insert into statement in a stored procedure?
I have a table that is updated every hour (RPT.SummaryAggregates). I need to create a stored procedure that fills a table (RPT.WeeklyAggregates) with a snapshot of the total records in (RPT.SummaryAggregates) once a week (this SP will be setup with a SQL Agent Job). I need the Week column of (RPT.WeeklyAggreg…
SQL concatenate – INSERT MANY VALUES TO ONE ROW
I’m currently trying to add 3 rows in to 1 row so that the information is separated by a ‘,’like using a concatenation. However, I’m new to this and any help will be useful. Below is my current code and what I have tried. This code below does not work: I have also tried this code below…
Update row if exists or insert
I’m working on a web based PHP form that’s currently connect to an Oracle database. I’m trying to get the functionality working so that after a user submits the form it’ll check if a row exists based on the Job Number, if it does then update, otherwise insert the values. It’s bri…
inserting into table with conditions
SQL. i have two tables residents (primary key rid) and dependents (primary key did). dependents is connected to residents through rid. I want to insert rows into dependents table only if the rid in the insert statement matches with any of the rid in the residents table. i tried the code below, but there is so…
How do I update if exist, else insert in MySQL
I have table with AUTO_INCREMENT field defined as PRIMARY_KEY. I have columns like: vote_id,vote_user_id,vote_ask_id,vote_comment_id,vote_post_id,vote_type,vote_status I want to INSERT new records but before I do that I want to check if there is a row with columns(vote_user_id,vote_ask_id,vote_type) as same a…
Postgresql: UPSERT / INSERT INTO defining a conflict
this is my first post on the platform. I hope this image explains what I am trying to do. I am trying to merge table B into table A. If the condition is met that (A.cell = B.cell AND A.object = B.objet) then I want to update A.cost with the corresponding cost from table B. If the condition is not
The INSERT statement conflicted with the FOREIGN KEY constraint “FK__…”
I’m a very new beginner with SQL and I’m battling a problem I can’t seem to find the answer to. I’ve found similar questions here on Stack Overflow but I still can’t see what I’m supposed to change in my code to make it work. I’ve got 4 tables in a relation as follows…