[Interest] How to deal with database specific syntax

Dmitriy Purgin dpurgin at gmail.com
Thu Feb 12 08:04:12 CET 2015


Exactly, that's what I meant by "supporting the stored procedure call
syntax". Sorry, it was a bit vague. Anyway, in this case you're
implementing a single interface for an SP call backed by multiple "syntax
handlers" which is much easier than handling lots of syntactic differences
for any kind of operations one might want to do with a database. It's not
ideal, it has its drawbacks but it also has advantages. Moreover, pmqt71
has explicitly stated that he/she doesn't want to go the ORM way.

Cheers

2015-02-12 12:26 GMT+06:00 alexander golks <alex at golks.de>:

> Am Thu, 12 Feb 2015 08:59:18 +0600
> schrieb Dmitriy Purgin <dpurgin at gmail.com>:
>
> > Hi,
> >
> > Actually I don't think it's a Qt-related question but here's my approach
> to
> > it.
> >
> > Since you struggle with both syntaxes, you may want to try and
> encapsulate
> > SQL code to stored procedures on the DB side and by that I mean not only
> > simple data retrieval or updating but also the business logic. You are
> > still obliged to support both DB backends but at least it will reduce the
> > dependencies in your C++ program down to supporting the stored procedure
> > call syntax which is pretty simple. Here you may also gain a performance
> > boost since the data operations are as close to data as it can be.
>
> ifair, each driver may handle stored procedure calls differently (1).
> some need special handling for multiple result sets, others need special
> handling for in/out values.
> so you may still need to handle different "syntax" foreach driver.
>
> [1] http://doc.qt.io/qt-5/sql-driver.html
>
> >
> > Regards
> > Dmitriy Purgin
> >
> > 2015-02-11 18:54 GMT+06:00 pmqt71 <pmqt71 at gmail.com>:
> >
> > > Hi all,
> > >
> > > in my Qt application I've to duplicate sql instructions for MySql and
> > > Postgres due to different sql syntax.
> > > Most problems are on date types. For instance, MySql has DATEDIFF,
> > > Postgres has EXTRACT, CAST...
> > >
> > > Without using ORMs, is there a way to manage specific sql syntax?
> > >
> > >
> > > Thanks
> > > pm
> > >
> > >
> > > _______________________________________________
> > > Interest mailing list
> > > Interest at qt-project.org
> > > http://lists.qt-project.org/mailman/listinfo/interest
> > >
> > >
>
>
> --
> /*
>  *  "There's definitely something wrong here."
>  *
>  *  Husse Jul 11 2007
>  */
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150212/ef42c530/attachment.html>


More information about the Interest mailing list