sql interface

M

mpeters

Hello,

I am sure this has been done lots of times but I can't seem to find some
examples. I need to write an SQL interface that allows the user to
specify fairly straightforward conditional clauses. Like,


first_name='john' and age < 30


I imagine I would have a list of field names on one side and a list of
entry fields on the other where the user could specify the data. I
guess the trick is how to let the user specify the connectors like
"and", "or", or even put them in parentheses. I am thinking some
Javascript library would come in handy here.


Is there something like this that I can re-use or take as a starting point?
 
E

Evertjan.

wrote on 24 feb 2009 in comp.lang.javascript:
Hello,

I am sure this has been done lots of times but I can't seem to find
some examples. I need to write an SQL interface that allows the user
to specify fairly straightforward conditional clauses. Like,


first_name='john' and age < 30

yes that can be part of a sql string
I imagine I would have a list of field names on one side and a list of
entry fields on the other where the user could specify the data. I
guess the trick is how to let the user specify the connectors like
"and", "or", or even put them in parentheses. I am thinking some
Javascript library would come in handy here.

Is there something like this that I can re-use or take as a starting
point?

You will first have to specify the platform you use.

Serverside javascript, under ASP?
Cscript/wscript?
probably not clientside in a browser?
on an open inernet connection?

etc.
 
M

mpeters

Evertjan. said:
You will first have to specify the platform you use.

Serverside javascript, under ASP?
Cscript/wscript?
probably not clientside in a browser?
on an open inernet connection?


This is on Windows XP, using MySQL as the database. The trick is that
the condition will be specified by the user on the client side through
the browser. Most of the action will take place on the client side.
So, the interaction is:

- user logs in
- user sees a list of columns
- with the browser, user enters simple "x=y" type conditions or combines
those simple ones into larger ones using parentheses, "and", "or", etc.
- user clicks on a button then, the whole condition gets processed, and
results returned to the user via the browser.


I guess the challenge is that we do not want to simply provide the user
with a large text field to type in. We want to simplify it so that they
can just click and enter a few data elements.


We can use HTML, CSS, Javascript and AJAX.
 
D

David Mark

 wrote on 24 feb 2009 in comp.lang.javascript:




yes that can be part of a sql string



You will first have to specify the platform you use.

Serverside javascript, under ASP?
Cscript/wscript?
probably not clientside in a browser?

Webkit has it. I use it in lieu of cookies whenever possible. Adds a
lot of possibilities for offline apps.

I imagine others will follow as it is part of some proposed standard.
 
E

Evertjan.

wrote on 24 feb 2009 in comp.lang.javascript:
This is on Windows XP, using MySQL as the database. The trick is that
the condition will be specified by the user on the client side through
the browser. Most of the action will take place on the client side.
So, the interaction is:

- user logs in
- user sees a list of columns
- with the browser, user enters simple "x=y" type conditions or combines
those simple ones into larger ones using parentheses, "and", "or", etc.
- user clicks on a button then, the whole condition gets processed, and
results returned to the user via the browser.


I guess the challenge is that we do not want to simply provide the user
with a large text field to type in. We want to simplify it so that they
can just click and enter a few data elements.


We can use HTML, CSS, Javascript and AJAX.

Sorry, clientside databases are not my piece of cake.

Perhaps David Mark, see the other post, can help you on?
 
D

David Segall

Hello,

I am sure this has been done lots of times but I can't seem to find some
examples. I need to write an SQL interface that allows the user to
specify fairly straightforward conditional clauses. Like,


first_name='john' and age < 30


I imagine I would have a list of field names on one side and a list of
entry fields on the other where the user could specify the data. I
guess the trick is how to let the user specify the connectors like
"and", "or", or even put them in parentheses. I am thinking some
Javascript library would come in handy here.


Is there something like this that I can re-use or take as a starting point?

Unless your users are similar to programmers, engineers or actuaries I
think you should provide something much simpler. The filters in your
news reader (Thunderbird) provide a good model. They have reduced the
AND/OR/NOT and parentheses to a simple "match all" or "match any" of
the following rules. The rules consist of a drop-down list of fields,
a drop-down list of conditions and a value field. Augmented with a
"search in results" facility I believe that you will satisfy any
likely query. If anyone complains, provide the option to input the SQL
:) I'm sorry, I don't know of any existing code that you can use to
implement this.

P.S. Are you aware that the cybersqatters at nospammers.com are
dealing with the spam that this post might generate? If not, perhaps
you should change your Usenet email address to conform with RFC2606
<http://tools.ietf.org/html/rfc2606>.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top