newsgroups-index (beta)

Current group: dbase.programming

select * from rowset ???

select * from rowset ???  
john noble
 Re: select * from rowset ???  
Roland Wingerter
 Re: select * from rowset ???  
john noble
 Re: select * from rowset ???  
Roland Wingerter
From:john noble
Subject:select * from rowset ???
Date:Mon, 17 Jan 2005 04:38:47 -0500
When trying to use code similar to the following:

q1 = new query()
q1.sql = [select * from table1]
q1.qctive = true
q1r = q1.rowset

q2 = new query()
q2.sql = [select * from "] + q1 + ["]
q2.active = true
q2r = q2.rowset

My question is - How can I use a select statement with a rowset OR a query?

Must it be an actual table?

John
From:Roland Wingerter
Subject:Re: select * from rowset ???
Date:Mon, 17 Jan 2005 12:11:15 +0100
john noble wrote:
> When trying to use code similar to the following:
>
> q1 = new query()
> q1.sql = [select * from table1]
> q1.qctive = true
> q1r = q1.rowset
>
> q2 = new query()
> q2.sql = [select * from "] + q1 + ["]
> q2.active = true
> q2r = q2.rowset
>
> My question is - How can I use a select statement with a rowset OR a
> query?
-----
You can't. You first need to save the results of query1 in a table.

There is more than one way to achieve that, e.g. by using the updateSet
class. The sample below shows another possibility.

Roland

/*
// The first approach I tried does not work, because
// according to the OLH executeSQL does not return a rowset.

d1 = new database("dbasesamples")
d1.active := true

bSuccess = d1.ExecuteSQL([select * from 'fish.dbf' where name like
'%fish%'])
*/


// This works OK
close databases
open database dbasesamples
set database to dbasesamples

cResult = "table2.dbf"
nError = sqlExec("select * from 'fish.dbf' where name like '%fish%'",
cResult)

if nError <> 0
msgbox("Error code: " + nError,"Error")
else
? "Table " + cResult + " successfully created!"
d1 = new database("dbasesamples")
d1.active := true

q2 = new query()
q2.database := d1
q2.sql = [select * from "] + cResult + ["]
q2.active = true

? q2.rowset.fields["name"].value
endif
From:john noble
Subject:Re: select * from rowset ???
Date:Mon, 17 Jan 2005 08:49:21 -0500
Roland Wingerter Wrote:

> john noble wrote:
> > When trying to use code similar to the following:
> >
> > q1 = new query()
> > q1.sql = [select * from table1]
> > q1.qctive = true
> > q1r = q1.rowset
> >
> > q2 = new query()
> > q2.sql = [select * from "] + q1 + ["]
> > q2.active = true
> > q2r = q2.rowset
> >
> > My question is - How can I use a select statement with a rowset OR a
> > query?
> -----
> You can't. You first need to save the results of query1 in a table.
>
>

Its a pity because you cant query a rowset as q1 is already a temproary table (.dbf) and it seems a bit long winded to create a secondary temp table based on an initial temp table.

Will have to consider another approach?

Thanks for your solution Roland,

John


>
From:Roland Wingerter
Subject:Re: select * from rowset ???
Date:Mon, 17 Jan 2005 15:02:07 +0100
john noble wrote:
>
> Its a pity because you cant query a rowset as q1 is already a
> temproary table (.dbf) and it seems a bit long winded to create a
> secondary temp table based on an initial temp table.
>
> Will have to consider another approach?
------
Depends on what you need to do. Can you give us more details?

Roland
   

Copyright © 2006 newsgroups-index   -   All rights reserved   -   Impressum