sql-insert

One INSERT with multiple SELECT

喜你入骨 提交于 2019-12-24 14:02:42
问题 I've already read this, this and this, but I cant make this SQL work: INSERT INTO main_phrase (description) VALUES ('Mot commun féminin pluriel animaux'); /* ERROR: */ WITH t1 AS ( SELECT id FROM main_phrase WHERE description='Mot commun féminin pluriel animaux' ), t2 AS ( SELECT id FROM main_groupecategories WHERE description='Mot commun féminin pluriel animaux' ) INSERT INTO main_phrasegroupecategories (phrase_id, groupe_categories_id) VALUES (t1.id, t2.id); I get: ERROR: missing entry for

Return value cross join

瘦欲@ 提交于 2019-12-24 11:35:23
问题 I have two tables, one is a table #1 contains user information, email, password, etc.. the other table #2 contains item information when I do a insert into table #2 , and then use the returning statement, to gather what was inserted (returning auto values as well as other information), I also need to return information from table #1 . (excuse the syntax) example: insert into table #1(item,user) values('this item','the user') returning *, select * from table 2 where table #1.user = table #2

How to solve a syntax error when using this INSERT INTO statement and the .NET OleDb namespace?

…衆ロ難τιáo~ 提交于 2019-12-24 06:01:36
问题 I keep getting an error when I attempt to insert values into a Access database. The error is syntactic, which leads to the following exception: OleDbException was unhandled Syntax error in INSERT INTO statement. private OleDbConnection myCon; public Form1() { InitializeComponent(); myCon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\File.mdb"); } private void insertuser_Click(object sender, EventArgs e) { OleDbCommand cmd = new OleDbCommand(); myCon.Open(); cmd

PostgreSQL: LEFT JOIN creates blank row

情到浓时终转凉″ 提交于 2019-12-24 05:30:26
问题 See important new discoveries 1 and 2 at end of this explanation. I am running Postgres 9.1.3 and am having a weird left join issue. I have a table named consistent.master with over 2 million rows. It has a column named citation_id , and that column has no nulls. I can verify that with this: SELECT COUNT(*) FROM consistent.master WHERE citation_id IS NULL That returns 0 . Here's where it gets weird: if I LEFT JOIN this table to a temporary table, I get an error that I am trying to insert a

PostgreSQL: LEFT JOIN creates blank row

与世无争的帅哥 提交于 2019-12-24 05:30:12
问题 See important new discoveries 1 and 2 at end of this explanation. I am running Postgres 9.1.3 and am having a weird left join issue. I have a table named consistent.master with over 2 million rows. It has a column named citation_id , and that column has no nulls. I can verify that with this: SELECT COUNT(*) FROM consistent.master WHERE citation_id IS NULL That returns 0 . Here's where it gets weird: if I LEFT JOIN this table to a temporary table, I get an error that I am trying to insert a

Web SQL insert data into multiple rows

拈花ヽ惹草 提交于 2019-12-24 04:09:31
问题 I've tried to insert variables into multiple rows at once in Web SQL database but with all known to me methods I'm getting errors: ("INSERT INTO tab (a,b) VALUES (?,?),(?,?)",[v1,v2,v3,v4]) >> could not prepare statement (1 near ",": syntax error) ("INSERT INTO tab (a,b) VALUES (?,?,?,?)",[v1,v2,v3,v4]) >> could not prepare statement (1 4 values for 2 columns) ("INSERT INTO tab (a,b) VALUES (?,?)",[v1,v2,v3,v4]) >> number of '?' does not match arguments count Which one is correct for Web SQL

SELECT * FROM NEW TABLE equivalent in Postgres

北城以北 提交于 2019-12-24 02:35:12
问题 In DB2 I can do a command that looks like this to retrieve information from the inserted row: SELECT * FROM NEW TABLE ( INSERT INTO phone_book VALUES ( 'Peter Doe','555-2323' ) ) AS t How do I do that in Postgres? There are way to retrieve a sequence, but I need to retrieve arbitrary columns. My desire to merge a select with the insert is for performance reasons. This way I only need to execute one statement to insert values and select values from the insert. The values that are inserted come

JAVA: sqlite throws exception after writing a few records?

扶醉桌前 提交于 2019-12-23 12:51:18
问题 I am trying to write a few thousand records to sqlite DB. However after writing a random number of records - 122 / 45 / 180, it throws following exception: java.sql.SQLException: unable to open database file The random number of records get populated on DB but this error stops further record writing. What am I doing wrong? EDIT: Class loginModel: private connection; public loginModel(){ connection = SqLiteConnection.connector(); if(connection == null) System.exit(1); } public boolean

Error: The conversion of a nvarchar data type to a smalldatetime data type resulted in an out-of-range value

时光毁灭记忆、已成空白 提交于 2019-12-23 11:20:30
问题 Hey all I'm trying to do the following insert query SqlDataSource userQuizDataSource = new SqlDataSource(); userQuizDataSource.ConnectionString = "Data Source=localhost\\SQLEXPRESS;Initial Catalog=quizApp;Integrated Security=True"; userQuizDataSource.InsertCommand = "INSERT INTO [UserQuiz] ([DateTimeComplete], [Score], [UserName]) VALUES (@DateTimeComplete, @Score, @UserName)"; userQuizDataSource.InsertParameters.Add("DateTimeComplete", DateTime.Now.ToString()); userQuizDataSource

Dapper multi insert returning inserted objects

烂漫一生 提交于 2019-12-23 07:50:09
问题 Using Dapper I would like to implement a method that takes an IEnumberable of objects of type User . Now, User looks as follows: public class User { public int UserId { get; internal set; } public DateTime DateCreated { get; internal set; } public DateTime DateChanged { get; internal set; } public string Username { get; set; } } The point here is that UserId , DateCreated and DateChanged shall never be set via object, hence the internal keyword. Instead the database will populate these values