You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Flavio Palumbo <f....@silmasoftware.com> on 2006/11/29 09:11:10 UTC

Use SQL parsing

Hi all,

maybe a bit OT ... but I'd like to use the SQL parsing engine of Derby ; my
goal is to validate a string to say it's a correct SQL statement, before to
execute it.

Is it possible with no headache ??

Thank a lot.

Flavio


-----------------------------------------------------------
Il presente messaggio non costituisce un impegno contrattuale tra SILMA S.r.l. ed il destinatario.
Le opinioni ivi espresse sono quelle dell'autore.
SILMA S.r.l. non assume alcuna responsabilita riguardo al contenuto del presente messaggio.
Il messaggio è destinato esclusivamente al destinatario.
Il contenuto e gli allegati sono da considerarsi di natura confidenziale

Nel caso abbiate ricevuto il presente messaggio per errore siete pregati di comunicarlo
alla casella segreteria@silmasoftware.com.


R: R: R: Use SQL parsing

Posted by Flavio Palumbo <f....@silmasoftware.com>.
Hi Dan,

I think you've well summarized what's my aim ;-)) and also that your
proposal of solution seems very handy.

I'll stay "tuned" to try to test this new release as soon as it will be
available.

Thanks a lot

Flavio

> -----Messaggio originale-----
> Da: Daniel John Debrunner [mailto:djd@apache.org]
> Inviato: venerdì 1 dicembre 2006 16.41
> A: Derby Discussion
> Oggetto: Re: R: R: Use SQL parsing
>
>
> Flavio Palumbo wrote:
> > Well, I made a little tool where a user can submit free SQL
> statements ...
> > I'd like to parse it before submitting to trap sintax errors.
>
> So I assume you are looking to make sure that well-formed SQL statements
> are created before the statement is sent to the real database. I guess
> that a statement such as:
>
>    SELECT A,B FROM T
>
> needs to be seen as valid, even if  T does not exist, or A, B are not
> valid columns in T.
>
> Derby does not support that yet, but it's possible to add that type of
> functionality. I could imagine something like a database type of
> 'syntax' that would only provide syntax checking on a prepare, e.g. a
> JDBC URL of
>
>   jdbc:derby:syntax:
>
> There would be no store behind this "database", just the SQL layer of
> Derby. In the past I've run Derby like this to show how the layers are
> independent of each other, i.e. a storeless Derby that could perform any
> SQL query that did not go against a real database object (e..g VALUES 1).
>
> I've been messing with the some code in this area now (and in the past)
> so I'll look into making progress on this for the next major release of
> Derby.
>
> Dan.
>


-----------------------------------------------------------
Il presente messaggio non costituisce un impegno contrattuale tra SILMA S.r.l. ed il destinatario.
Le opinioni ivi espresse sono quelle dell'autore.
SILMA S.r.l. non assume alcuna responsabilita riguardo al contenuto del presente messaggio.
Il messaggio è destinato esclusivamente al destinatario.
Il contenuto e gli allegati sono da considerarsi di natura confidenziale

Nel caso abbiate ricevuto il presente messaggio per errore siete pregati di comunicarlo
alla casella segreteria@silmasoftware.com.


Re: R: R: Use SQL parsing

Posted by Daniel John Debrunner <dj...@apache.org>.
Flavio Palumbo wrote:
> Well, I made a little tool where a user can submit free SQL statements ...
> I'd like to parse it before submitting to trap sintax errors.

So I assume you are looking to make sure that well-formed SQL statements 
are created before the statement is sent to the real database. I guess 
that a statement such as:

   SELECT A,B FROM T

needs to be seen as valid, even if  T does not exist, or A, B are not 
valid columns in T.

Derby does not support that yet, but it's possible to add that type of 
functionality. I could imagine something like a database type of 
'syntax' that would only provide syntax checking on a prepare, e.g. a 
JDBC URL of

  jdbc:derby:syntax:

There would be no store behind this "database", just the SQL layer of 
Derby. In the past I've run Derby like this to show how the layers are 
independent of each other, i.e. a storeless Derby that could perform any 
SQL query that did not go against a real database object (e..g VALUES 1).

I've been messing with the some code in this area now (and in the past) 
so I'll look into making progress on this for the next major release of 
Derby.

Dan.


R: R: Use SQL parsing

Posted by Flavio Palumbo <f....@silmasoftware.com>.
Well, I made a little tool where a user can submit free SQL statements ...
I'd like to parse it before submitting to trap sintax errors.
Thanks
Flavio

> -----Messaggio originale-----
> Da: Bernt.Johnsen@Sun.COM [mailto:Bernt.Johnsen@Sun.COM]
> Inviato: giovedì 30 novembre 2006 16.44
> A: Derby Discussion
> Oggetto: Re: R: Use SQL parsing
>
>
> >>>>>>>>>>>> Flavio Palumbo wrote (2006-11-29 09:55:02):
> > Hi Bernt,
> >
> > I tried this way but it seems to me that the parsing is really
> light ... I'd
> > like to get a deeper parse.
>
> I don't think you can get it any deeper without execuing the
> statement. What kind of errors do you expect to catch?
>
> --
> Bernt Marius Johnsen, Database Technology Group,
> Staff Engineer, Technical Lead Derby/Java DB
> Sun Microsystems, Trondheim, Norway
>


-----------------------------------------------------------
Il presente messaggio non costituisce un impegno contrattuale tra SILMA S.r.l. ed il destinatario.
Le opinioni ivi espresse sono quelle dell'autore.
SILMA S.r.l. non assume alcuna responsabilita riguardo al contenuto del presente messaggio.
Il messaggio è destinato esclusivamente al destinatario.
Il contenuto e gli allegati sono da considerarsi di natura confidenziale

Nel caso abbiate ricevuto il presente messaggio per errore siete pregati di comunicarlo
alla casella segreteria@silmasoftware.com.


Re: R: Use SQL parsing

Posted by "Bernt M. Johnsen" <Be...@Sun.COM>.
>>>>>>>>>>>> Flavio Palumbo wrote (2006-11-29 09:55:02):
> Hi Bernt,
> 
> I tried this way but it seems to me that the parsing is really light ... I'd
> like to get a deeper parse.

I don't think you can get it any deeper without execuing the
statement. What kind of errors do you expect to catch?

-- 
Bernt Marius Johnsen, Database Technology Group, 
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway

R: Use SQL parsing

Posted by Flavio Palumbo <f....@silmasoftware.com>.
Hi Bernt,

I tried this way but it seems to me that the parsing is really light ... I'd
like to get a deeper parse.

Thanks

Flavio

> -----Messaggio originale-----
> Da: Bernt.Johnsen@Sun.COM [mailto:Bernt.Johnsen@Sun.COM]
> Inviato: mercoledì 29 novembre 2006 9.41
> A: Derby Discussion
> Oggetto: Re: Use SQL parsing
>
>
> >>>>>>>>>>>> Flavio Palumbo wrote (2006-11-29 09:11:10):
> > Hi all,
> >
> > maybe a bit OT ... but I'd like to use the SQL parsing engine
> of Derby ; my
> > goal is to validate a string to say it's a correct SQL
> statement, before to
> > execute it.
> >
> > Is it possible with no headache ??
>
> The easiest way is to do
>
> conn.prepareStatement(".....sql string......");
>
> > Thank a lot.
>
> --
> Bernt Marius Johnsen, Database Technology Group,
> Staff Engineer, Technical Lead Derby/Java DB
> Sun Microsystems, Trondheim, Norway
>


-----------------------------------------------------------
Il presente messaggio non costituisce un impegno contrattuale tra SILMA S.r.l. ed il destinatario.
Le opinioni ivi espresse sono quelle dell'autore.
SILMA S.r.l. non assume alcuna responsabilita riguardo al contenuto del presente messaggio.
Il messaggio è destinato esclusivamente al destinatario.
Il contenuto e gli allegati sono da considerarsi di natura confidenziale

Nel caso abbiate ricevuto il presente messaggio per errore siete pregati di comunicarlo
alla casella segreteria@silmasoftware.com.


Re: Use SQL parsing

Posted by "Bernt M. Johnsen" <Be...@Sun.COM>.
>>>>>>>>>>>> Flavio Palumbo wrote (2006-11-29 09:11:10):
> Hi all,
> 
> maybe a bit OT ... but I'd like to use the SQL parsing engine of Derby ; my
> goal is to validate a string to say it's a correct SQL statement, before to
> execute it.
> 
> Is it possible with no headache ??

The easiest way is to do

conn.prepareStatement(".....sql string......");

> Thank a lot.

-- 
Bernt Marius Johnsen, Database Technology Group, 
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway