Another little SQL issue

Jan Schenkel janschenkel at yahoo.com
Wed Dec 28 12:34:53 EST 2005


--- Scott Kane <scott at proherp.com> wrote:
> Hi again!
> 
> [snip]
> 
> Here's the issue.  I can populate a Table Field
> with the array resulting from a Select query with
> no problems.  What I don't seem to be able to get
> right is getting each element of that array into
> a normal Field object (as in an edit box).  It's
> the last issue I face as a matter of fact. 
> Pleasingly
> everything else is slipping into gear for me.
> 
> What I'm trying to do is:
> 
> put "SELECT * FROM users" into tSQL
>   --> EXECUTE SQL
>   put revdb_querylist(,,gConID,tSQL) into tList
> 
>   handleRevDBerror tList
>   if the result is not empty then 
>     answer warning the result
>     exit mouseUp
>   end if
>   
>   put tList into fld "Users"
> 
> ---------------------------
> 
> That works fine.  What I need to do is add the tList
> elements to a group of normal Fields (edit boxes for
> clarity).  In the example there would be three of 
> these:
> 
> edName
> edEmail
> edSubscribed
> 
> So far (I've spent a few hours on this) I've failed
> overall.
> 
> In help greatly appreciated.
> 
> Scott 
> 

Hi Scott,

While the revdb_querylist() function will return a
tab-and-return- delimited list of the results of your
query, you can also use the revdb_query() function.
This returns a database cursor ID, which you can use
in the revdb_movefirst(), revdb_movenext(),
revdb_columnbyname() and some other functions and
names.
So if you want to display the contents of the colulns
of your first record of the query result in a couple
of fields, you can use something like:
--
  put "SELECT * FROM users" into tSQL
  --> EXECUTE SQL
  put revdb_query(,,gConID,tSQL) into tCursorID
  --> EXTRACT SOME FIELDS FROM THE FIRST RECORD IN THE
CURSOR
  put revdb_columnbyname(tCursorID,"edName") \
      into field "edName"
  put revdb_columnbyname(tCursorID,"edEmail") \
      into field "edEmail"
  put revdb_columnbyname(tCursorID,"edSubscribed") \
      into field "edSubscribed"
  --> DON'T FORGET TO CLOSE THE CURSOR WHEN YOU'RE
DONE
  get revdb_closecursor(tCursorID)
--

Hope this helped,

Jan Schenkel.

Quartam Reports for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


	
		
__________________________________ 
Yahoo! for Good - Make a difference this year. 
http://brand.yahoo.com/cybergivingweek2005/



More information about the use-livecode mailing list