Re: [sqlite] selecting uncommited rows

2008-04-17 Thread Alex Katebi
Hi Dennis,

I am sorry I was wrong about triggers. My understanding of triggers was
incorrect. Triggers are part of the same connection. I will take your
suggestions. I will let you know.
Thanks so much for helping out!
-Alex

On Thu, Apr 17, 2008 at 6:11 PM, Dennis Cote <[EMAIL PROTECTED]> wrote:

> Alex Katebi wrote:
> > My problem is that triggers don't trigger until after commit.
> >
>
> No, that is not your problem. You haven't tried anything yet.
>
> This is a trace of SQlite executing the code I posted. There is not a
> commit in sight, and yet it works as expected. I added an unqualified
> select to dump the entire table so you can see the difference.
>
> SQLite version 3.5.7
> Enter ".help" for instructions
> sqlite> create table t1(name);
> sqlite> insert into t1 values('Alex');
> sqlite>
> sqlite> create table change_log (id integer primary key);
> sqlite>
> sqlite> create trigger in_t1 after insert on t1
>...> begin
>...> insert into change_log values(new.rowid);
>...> end;
> sqlite>
> sqlite> delete from change_log;
> sqlite> begin;
> sqlite> insert into t1 values('Dennis');
> sqlite> select * from t1 where rowid in (select id from change_log);
> Dennis
> sqlite> select * from t1;
> Alex
> Dennis
> sqlite>
>
> Try it before you decide it won't work.
>
> Dennis Cote
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] selecting uncommited rows

2008-04-17 Thread Dennis Cote
Alex Katebi wrote:
> My problem is that triggers don't trigger until after commit.
> 

No, that is not your problem. You haven't tried anything yet.

This is a trace of SQlite executing the code I posted. There is not a 
commit in sight, and yet it works as expected. I added an unqualified 
select to dump the entire table so you can see the difference.

SQLite version 3.5.7
Enter ".help" for instructions
sqlite> create table t1(name);
sqlite> insert into t1 values('Alex');
sqlite>
sqlite> create table change_log (id integer primary key);
sqlite>
sqlite> create trigger in_t1 after insert on t1
...> begin
...> insert into change_log values(new.rowid);
...> end;
sqlite>
sqlite> delete from change_log;
sqlite> begin;
sqlite> insert into t1 values('Dennis');
sqlite> select * from t1 where rowid in (select id from change_log);
Dennis
sqlite> select * from t1;
Alex
Dennis
sqlite>

Try it before you decide it won't work.

Dennis Cote
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] selecting uncommited rows

2008-04-17 Thread Alex Katebi
My problem is that triggers don't trigger until after commit.

On Thu, Apr 17, 2008 at 4:52 PM, Dennis Cote <[EMAIL PROTECTED]> wrote:

> Alex Katebi wrote:
> > I will give a simple example:
> >
> > create table t1(name);
> > insert into t1('Alex');
> > begin;
> > insert into t1 values ('Dennis');
> > select * from t1;
> >
> > How can I see only the 'Dennis' row in this simple example.
> >
>
> As I said before, use a trigger to keep track of the changes.
>
> create table t1(name);
> insert into t1('Alex');
>
> create table change_log (id integer primary key);
>
> create trigger in_t1 after insert on t1
> begin
> insert into change_log values(new.rowid);
> end;
>
> delete from change_log;
> begin;
> insert into t1 values ('Dennis');
> select * from t1 where rowid in (select id from change_log);
>
> Now either commit or rollback to end your transaction.
>
> Dennis Cote
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] selecting uncommited rows

2008-04-17 Thread Dennis Cote
Alex Katebi wrote:
> I will give a simple example:
> 
> create table t1(name);
> insert into t1('Alex');
> begin;
> insert into t1 values ('Dennis');
> select * from t1;
> 
> How can I see only the 'Dennis' row in this simple example.
> 

As I said before, use a trigger to keep track of the changes.

 create table t1(name);
 insert into t1('Alex');

 create table change_log (id integer primary key);

 create trigger in_t1 after insert on t1
 begin
 insert into change_log values(new.rowid);
 end;

 delete from change_log;
 begin;
 insert into t1 values ('Dennis');
 select * from t1 where rowid in (select id from change_log);

Now either commit or rollback to end your transaction.

Dennis Cote

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] selecting uncommited rows

2008-04-17 Thread Derrell Lipman
On Thu, Apr 17, 2008 at 3:15 PM, Alex Katebi <[EMAIL PROTECTED]> wrote:

> I will give a simple example:
>
> create table t1(name);
> insert into t1('Alex');
> begin;
> insert into t1 values ('Dennis');
> select * from t1;
>
> The above will show two rows. How can I see only the 'Dennis' row in this
> simple example.
>

Here's one possibility:

sqlite> CREATE TABLE t1(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT);
sqlite> INSERT INTO t1(name) VALUES ('Alex');
sqlite> BEGIN;
sqlite> CREATE TEMPORARY TABLE start AS
   ...>   SELECT COALESCE(MAX(id), 0) AS v FROM t1;
sqlite> INSERT INTO t1(name) VALUES ('Dennis');
sqlite> SELECT name FROM t1 WHERE id > (SELECT v FROM start);
 name = Dennis
sqlite>

Derrell
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] selecting uncommited rows

2008-04-17 Thread Alex Katebi
I will give a simple example:

create table t1(name);
insert into t1('Alex');
begin;
insert into t1 values ('Dennis');
select * from t1;

The above will show two rows. How can I see only the 'Dennis' row in this
simple example.



On Thu, Apr 17, 2008 at 2:57 PM, Dennis Cote <[EMAIL PROTECTED]> wrote:

> Alex Katebi wrote:
> > Actually I am not interested on rows that have been committed. I am
> > interested on the rows that have been changed but not commited yet. As I
> > understand the triggers trigger of of a commit.
> > The example that you are refering to is for undoing the already commited
> > rows. I am merely interested in seeing the rows that are in my
> transaction
> > queue before the commit.
> >
>
> SQLite does not have a transaction queue.
>
> The data that you have changed is already stored in the database before
> you do the commit. The commit simply removes the information that would
> be used to do a rollback.
>
> The page I referred you to was an example of using triggers to track
> changes to tables. This is what you want to do if I understand you
> correctly.
>
> Use triggers to track the rows that are changed by your transaction's
> insert, update, and delete statements. Then use a select to display the
> current values (i.e. the value that will be committed) for these rows
> only.
>

> HTH
> Dennis Cote
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] selecting uncommited rows

2008-04-17 Thread Alex Katebi
Actually I am not interested on rows that have been committed. I am
interested on the rows that have been changed but not commited yet. As I
understand the triggers trigger of of a commit.
The example that you are refering to is for undoing the already commited
rows. I am merely interested in seeing the rows that are in my transaction
queue before the commit.

On Thu, Apr 17, 2008 at 1:54 PM, Dennis Cote <[EMAIL PROTECTED]> wrote:

> Alex Katebi wrote:
> >Can you give an example on how to use this. Basically I want to see
> > (select) only the uncommited rows.
> >
>
> You will have to keep track of the rows that have been changed yourself.
>
> You can have SQLite do it for you if you create a change_log table and
> then setup triggers to add the rowids of any rows modified during the
> transaction. You clear this table at the beginning of your transaction.
> The triggers will insert rows for each change to the table. At the end
> of the transaction you can select all the rows from the main table that
> have their rowids stored in the change_log table.
>
> If you want to get fancier you can look at this page for more ideas
> http://www.sqlite.org/cvstrac/wiki?p=UndoRedo
>
> HTH
> Dennis Cote
>  ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] selecting uncommited rows

2008-04-17 Thread Dennis Cote
Alex Katebi wrote:
>Can you give an example on how to use this. Basically I want to see
> (select) only the uncommited rows.
> 

You will have to keep track of the rows that have been changed yourself.

You can have SQLite do it for you if you create a change_log table and 
then setup triggers to add the rowids of any rows modified during the 
transaction. You clear this table at the beginning of your transaction. 
The triggers will insert rows for each change to the table. At the end 
of the transaction you can select all the rows from the main table that 
have their rowids stored in the change_log table.

If you want to get fancier you can look at this page for more ideas 
http://www.sqlite.org/cvstrac/wiki?p=UndoRedo

HTH
Dennis Cote
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] selecting uncommited rows

2008-04-17 Thread Alex Katebi
Martin,
   Can you give an example on how to use this. Basically I want to see
(select) only the uncommited rows.

Thanks!
-Alex

On Thu, Apr 17, 2008 at 11:58 AM, Ken <[EMAIL PROTECTED]> wrote:

> I believe the pragma read_uncommitted only works for shared cache mode and
> threads.
>
> You'll have to select the data from the same connection that created the
> data.
>
>
>
> "Martin.Engelschalk" <[EMAIL PROTECTED]> wrote: Hi,
>
> there is a pragma: PRAGMA read_uncommitted = 1;
> You can select the uncommitted data and show ist before commit.
>
> Have a look here: http://www.sqlite.org/pragma.html
>
> Martin
>
> Alex Katebi schrieb:
> > Hi All,
> >
> > Let's say I start a transaction and do bunch of insertions etc. Before
> my
> > commit I like to show (select) what I have configured.
> > How can I accompilish this?
> >
> > Thanks,
> > -Alex
> > ___
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> >
> >
>
> --
>
> * Codeswift GmbH *
> Traunstr. 30
> A-5026 Salzburg-Aigen
> Tel: +49 (0) 8662 / 494330
> Mob: +49 (0) 171 / 4487687
> Fax: +49 (0) 12120 / 204645
> [EMAIL PROTECTED]
> www.codeswift.com / www.swiftcash.at
>
> Codeswift Professional IT Services GmbH
> Firmenbuch-Nr. FN 202820s
> UID-Nr. ATU 50576309
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] selecting uncommited rows

2008-04-17 Thread Ken
I believe the pragma read_uncommitted only works for shared cache mode and 
threads.

You'll have to select the data from the same connection that created the data.  



"Martin.Engelschalk" <[EMAIL PROTECTED]> wrote: Hi,

there is a pragma: PRAGMA read_uncommitted = 1;
You can select the uncommitted data and show ist before commit.

Have a look here: http://www.sqlite.org/pragma.html

Martin

Alex Katebi schrieb:
> Hi All,
>
> Let's say I start a transaction and do bunch of insertions etc. Before my
> commit I like to show (select) what I have configured.
> How can I accompilish this?
>
> Thanks,
> -Alex
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>   

-- 

* Codeswift GmbH *
Traunstr. 30
A-5026 Salzburg-Aigen
Tel: +49 (0) 8662 / 494330
Mob: +49 (0) 171 / 4487687
Fax: +49 (0) 12120 / 204645
[EMAIL PROTECTED]
www.codeswift.com / www.swiftcash.at

Codeswift Professional IT Services GmbH
Firmenbuch-Nr. FN 202820s
UID-Nr. ATU 50576309

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] selecting uncommited rows

2008-04-17 Thread Martin.Engelschalk
Hi,

there is a pragma: PRAGMA read_uncommitted = 1;
You can select the uncommitted data and show ist before commit.

Have a look here: http://www.sqlite.org/pragma.html

Martin

Alex Katebi schrieb:
> Hi All,
>
> Let's say I start a transaction and do bunch of insertions etc. Before my
> commit I like to show (select) what I have configured.
> How can I accompilish this?
>
> Thanks,
> -Alex
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>   

-- 

* Codeswift GmbH *
Traunstr. 30
A-5026 Salzburg-Aigen
Tel: +49 (0) 8662 / 494330
Mob: +49 (0) 171 / 4487687
Fax: +49 (0) 12120 / 204645
[EMAIL PROTECTED]
www.codeswift.com / www.swiftcash.at

Codeswift Professional IT Services GmbH
Firmenbuch-Nr. FN 202820s
UID-Nr. ATU 50576309

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] selecting uncommited rows

2008-04-17 Thread Alex Katebi
Hi All,

Let's say I start a transaction and do bunch of insertions etc. Before my
commit I like to show (select) what I have configured.
How can I accompilish this?

Thanks,
-Alex
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users