This might help you So I have found the error. I created the table without the product index and then tried to add it. Then I recieved the error : Error code: 1005. Can't create the table 'schema.name'.#sql-24b8_25 (errorno: 150)
Creating TEMP TABLE dynamically in Postgresql and selecting the same table in FOR loop. But getting the error near PIPE
I think the issue was by ths following , The query in for ... loop statement also has to be dynamic, so you should use execute twice. Use the format() function which is very convenient in conjunction with execute:
y := to_char(current_timestamp, 'YYYYMMDDHHMMSS');
raise notice '%', y;
create temp table somenewtable%s
as select * from (
) as t (key, value)
for i in
select * from somenewtable%s
raise notice '%',i.key;
$xyz$ language 'plpgsql';
Using TCL: Sqlite syntax error when creating table in memory temp table
With these it helps Temporary tables go into the temporary database (which is named temp). While that database is stored in a disk file, the file is not actually written to until the cache overflows (because the temporary database is not required to be durable through a crash). If you want to put the table into some other database, do not use CREATE TEMP TABLE but the normal CREATE TABLE.
CREATE TABLE things([...]); -- creates the table in the DB "main"
CREATE TABLE memdb.things([...]); -- creates the table in the specified DB
CREATE TEMP TABLE things([...]); -- creates the table in the DB "temp"
CREATE TABLE temp.things([...]); -- creates the table in the DB "temp"
SQLITE Database error when creating a table with prepopulated information (Table has 3 columns but 2 values were supplie
should help you out The error, as has been mentioned, arises because you are inserting into a table that has three columns but your stored procedure is only providing values for two. You expect the database to provide the id value for you. Your database can do that, and your stored procedure will work just fine, if you set your table up to do that. You need to tell the database to autoincrement (using the internal rowid at the id value) on the USER table. This is done as part of the database table definition by either adding INTEGER PRIMARY KEY or INTEGER AUTOINCREMENT ad the data type for the ID column.