Re: Dynamic sql real examples

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Gabriel Filipiak <gabriel(dot)filipiak(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Dynamic sql real examples
Date: 2011-10-13 06:31:30
Message-ID: CAFj8pRA6nS0V5=BcouMYh+oVKMOydGu4eKuTxisz0d10DHRtJQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

It's really depends on client software and architecture. Dynamic SQL
is interesting for some use cases when you use a stored procedures,
when you dynamically create tables based on metadata and when you
access these tables.

We had a object oriented database with interface in stored procedures.
Some classes was stored with own tables, some classes was stored in
common tables. But a format was transparent for client.

Some-times you have to use a dynamic sql as workaround - there is no
other way - like this

http://stackoverflow.com/questions/7711432/how-to-set-value-of-composite-variable-field-using-dynamic-sql

Regards

Pavel Stehule

2011/10/13 Gabriel Filipiak <gabriel(dot)filipiak(at)gmail(dot)com>:
> Hi all,
>
> I have lately learned what is dynamic sql and one of the most interesting
> features of it to me is that we can use dynamic columns names and tables.
> But I cannot think about useful real life examples. The only one that came
> into my mind is statistical table.
>
> Let`s say that we have table with name, type and created_data. Then we want
> to have a table that in columns are years from created_data column and in
> row type and number of names created in years. (sorry for my English)
>
> What can be other useful real life examples of using dynamic sql with column
> and table as parameters? How do you use it?
>
> I am particulary interested in examples that do not contain administrative
> things or database convertion or something like that, I am looking for
> examples where the code in example java is more complicated than using a
> dynamic sql in for example stored procedure.
>
> Thanks for any suggestions and help :) regards Gabe
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sergey Konoplev 2011-10-13 08:18:35 Re: how to list or array of key value pairs
Previous Message John R Pierce 2011-10-13 06:06:08 Re: Dynamic sql real examples