[ALL] let's think about Query Language for 2.0

Andy Fuchs andy at foxwerk.de
Fri May 16 18:33:34 CDT 2003


at 16.05.2003 16:51 Uhr, Ruslan Zasukhin wrote:

hi Ruslan, hi folks,

my idea would be to allow the query in XML-Format. This would have give us
some power to manipulate queries outside Valentina (or any IDE) using any
textprocessor. The advantage of XML in this sense would be to either create
an XML-command 'on the fly', load it from a template (even on a server) or
combine different techniques.

a commandtemplate would be an empty XML-document containing solely a root
node:

<?xml version="1.0" encoding="UTF-8" ?>
<root>
</root>

after adding a simple command it would be something like that:

<?xml version="1.0" encoding="UTF-8" ?>
<root>
    <query locale="de"  encoding="UTF-8">
        <cmd table="Person" field="name" value="Bill" />
    </query>
</root>


adding some other statements and encoding information would result in
something like that:

<?xml version="1.0" encoding="UTF-8" ?>
<root>
   <query locale="de" encoding="UTF-8">
      <cmd>
        <step table="Person" field="name"  operator="" value="Bill">
        <step table="Person" field="name"  operator="AND" value="Gates">
      </cmd>
     <cmd>
        <step table="age" field="age" value="32" operator="OR" />
        <step table="age" field="age" value="44" operator="OR" />
        <step table="age" field="age" value="42" operator="OR" />
     </cmd>
     <orderdef>
        <order field="name" ascending="true" />
        <order field="age"  descending="true" />
     </orderdef>
   </query>
</root>

Well sure, this could be much more sophisticated...

The idea is to have the queries in an extensible (readable) format, where
statements can easily be nested...

Creating a statement like this could be easy too:

query = vdb.createNewQuery()    // create an empty query template
query.appendCommandAND(cmd1())  // append (or insert) a command
query.appendCommandAND(cmd2())
query.appendCommandOR(cmd3(Macintosh HD:Templates:germanCities.xml")
query.appendOrder("name",true)
query.appendOrder("age", false)
query.executeASYNC()


vCommandTemplate cmd1() {
 cmd = new commandTemplate()   // get an empty commandtemplate
 cmd.table       =  "Person"   // add definition
 cmd.field       =  "lastname"
 cmd.addString("Bill")
 cmd.addString("Gates", "AND")
 return cmd
}

vCommandTemplate cmd2() {
  cmd = new commandTemplate()
  cmd.table       =  "Person"
  cmd.field       =  "age"
  cmd.operator    =  'or'  // setting an operator for all following
  cmd.addInteger(32)       // attributes
  cmd.addString(44)
  cmd.addString(42)
  return cmd
}

vCommandTemplate cmd3(filepath){
    cmd = new commandTemplate(filepath)  // loading a template from a file
    return cmd
}

vCommandTemplate cmd4(url){
    cmd = new commandTemplate(url)  // loading a template from a server
    cmd.insert("table", "town", "Kiev")  // add something
    cmd.insert("table", "town", "New York", "OR")  // add something
    return cmd
}

myPushCommand{
    alert "Ready"
}

NOTE: This is just an idea for query-templates an maybe has nothing to do
with your original question, but I thought I will share my ideas anyway ;-)

have a nice weekend

-- Andy Fuchs
-- silent movie media
-- mailto:andy at foxwerk.de
-- http://www.silent-movie-media.com

-------------------------------------

Helfende Hand benötigt? -> Im August hätte ich noch Zeit...
Need some helping hand? -> I'm free in August...




More information about the Valentina mailing list