Paul Harris wrote:
On 03/08/07, Nikola Miljkovic <[EMAIL PROTECTED]> wrote:
[In the message "Re: [sqlite] Re: Re: how do i declare and use variables in sqlite?" on
Aug 3, 11:47, "Paul Harris" writes:]
create temporary table vars (name text, value something);
--
insert into vars set name="x", value=0;
--
... where something = (select value from vars where name="x")...
I tried doing this, but there doesn't seem to be a way to do the same
thing with an UPDATE command ?
No way to do what with UPDATE command? What exactly are you trying to
do, and failing?
i've just realised the last statement ("...where etc etc") is probably
supposed to be part of a select statement.
Yeap, sorry for being "too conceptual", dislexic (insert/update, thanks Igor)
and obviously too confusing :-).
anyway, this is what i'm trying to do:
eg 1
select @somevar := column1 from table1;
update table2 set column2 = @somevar;
Try:
create temporary table var1 select column1 from table1;
update table2 set column2 = (select column1 from var1);
As written the second comand will likely not do what was intended
since var1 might have more than 1 row and there is no constraint
so every row in table2 will be affected. I assume that real
implementation will deal with this.
ok, so a subselect can be used. not bad, but not as powerful as the
mysql @ variables, which can then be used in all sorts of scenarios
later, without inducing the same query over and over to get the value.
Sqlite is an embedded toolkit, not a complete DBMS server. You can use
it freely to integrate into applications and language processors. If
you have a need for such a capability as you describe you can implement
it any way you choose, perhaps by making a wrapper around some of the
Sqlite API. You could add the MySql extensions to the SQL if you felt
the need.
Meanwhile the core Sqlite library stays relatively sparse so that it can
be embedded into projects without inflicting unecessary bloat.
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------