Sqlite doesn't have variable. While last row id is available other ways, a
trick to emulate a variable is to create a temp table with one field. You put
the value in to the that field. You can then cross join with the rest of your
table as need be, or do a sub-select to value a SET command.
David
From: mikeegg1 <[email protected]>
To: SQLite mailing list <[email protected]>
Sent: Sunday, September 11, 2016 5:48 PM
Subject: [sqlite] Does sqlite3 have variables like Oracle?
I think Oracle (a long distant memory) has variables like @variable or
@@variable where you can do something like '@variable = select rowid from table
where field = 4' and then later do 'insert into othertable (field2)
value(@variable)’. Does this make sense? I’m wanting to in the shell select
lastrowid then update a bunch of inserted rows in a different table with the
previously inserted lastrowid.
I don’t have an example at the moment of what I’m trying to do. I’m generating
a bunch of statements into a file that I will then ‘sqlite3 data.sqlite3 <
data.sql’. I’m using the value of -14 (just a number) as a place holder in a
bunch of insert statements then at the end of each group I do an update to the
actual rowid.
Mike
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users