internal SQL queries

Josh Mellicker josh at dvcreators.net
Mon Aug 7 14:47:53 EDT 2006


Here is a function I wrote to retrieve data from a table field.

All it needs is:

whichDataFld -  the long name of the data field
locatorColumnHeader - assumes the top row is a header row with the  
column name, this is which column to use to locate the correct row
locatorValue - this is the value in the column with the header  
"locatorColumnHeader" that tells you you have the right row
headerOfDataToGet - this is the column containing the data you want


FUNCTION getDataFromDataFld  
whichDataFld,locatorColumnHeader,locatorValue,headerOfDataToGet
     put the text of whichDataFld into p
     set itemdel to tab
     put itemOffset(locatorColumnHeader,p) into locatorColNo
     put itemOffset(headerOfDataToGet,p) into dataColNo
     REPEAT with x = 2 to the number of lines of p
         IF item locatorColNo of line x of p = locatorValue THEN exit  
REPEAT
     END REPEAT
     return item dataColNo of line x of p
END getDataFromDataFld



So if your table field is:

ID     name     color     food
5        Ken        blue     cheese
7       Jerry      green    pizza
21    Sarah      red        sushi


you could say

put getDataFromDataFld(whichDataFld,ID,7,"food") into tData

RESULT: "pizza"


What I don't like about this handler is that it must scan every line  
to find the right row... there must be a faster way to write this, no?




On Jul 21, 2006, at 1:01 PM, Viktoras Didziulis wrote:

> Dear group,
>
> is it possible to query [tab] delimited data stored in fields or  
> containers
> within a stack using SQL? e.g. without any external database engine or
> database files or connections...
>
> All the best!
> Viktoras
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list