pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedTweak sql result set... ?
9+ messages / 5 participants
[nested] [flat]
* Tweak sql result set... ?
@ 2009-07-28 20:49 Axe <info@axier.se>
2009-07-29 00:24 ` Re: Tweak sql result set... ? Tim Landscheidt <tim@tim-landscheidt.de>
2009-07-29 12:39 ` Re: Tweak sql result set... ? Jasen Betts <jasen@xnet.co.nz>
0 siblings, 2 replies; 9+ messages in thread
From: Axe @ 2009-07-28 20:49 UTC (permalink / raw)
To: pgsql-sql
I have a problem where I want to tweak a simple select in an
"unobtrusive way". Imagine I have the following select statement:
"SELECT name FROM customer LIMIT 1" and I get a normal result set from
this. But, could I,maybe by defining some other function or similar,
change the result set *without* changing the query? Suppose I get the
result from the query above, saying: "Peter Peterson". I would
(sometimes) like to get the result "<div>Peter Peterson</div>" but I
should not have to change the original query.
I know I could write "SELECT '<div>' || name || '</div>' as name FROM
customer" but then I have altered the original query and I cannot do
this since it is supposed to function different in two different
situations.
Any ideas on how to achieve this? I would like to let the original sql
code stay original. I can prepare postgres before executing the sql if
this makes it easier to acheive the goal
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Tweak sql result set... ?
2009-07-28 20:49 Tweak sql result set... ? Axe <info@axier.se>
@ 2009-07-29 00:24 ` Tim Landscheidt <tim@tim-landscheidt.de>
2009-07-29 06:35 ` Re: Tweak sql result set... ? Axe <info@axier.se>
1 sibling, 1 reply; 9+ messages in thread
From: Tim Landscheidt @ 2009-07-29 00:24 UTC (permalink / raw)
To: pgsql-sql
(anonymous) wrote:
> I have a problem where I want to tweak a simple select in an
> "unobtrusive way". Imagine I have the following select statement:
> "SELECT name FROM customer LIMIT 1" and I get a normal result set from
> this. But, could I,maybe by defining some other function or similar,
> change the result set *without* changing the query? Suppose I get the
> result from the query above, saying: "Peter Peterson". I would
> (sometimes) like to get the result "<div>Peter Peterson</div>" but I
> should not have to change the original query.
> I know I could write "SELECT '<div>' || name || '</div>' as name FROM
> customer" but then I have altered the original query and I cannot do
> this since it is supposed to function different in two different
> situations.
> Any ideas on how to achieve this? I would like to let the original sql
> code stay original. I can prepare postgres before executing the sql if
> this makes it easier to acheive the goal
Have a look at CREATE RULE.
Tim
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Tweak sql result set... ?
2009-07-28 20:49 Tweak sql result set... ? Axe <info@axier.se>
2009-07-29 00:24 ` Re: Tweak sql result set... ? Tim Landscheidt <tim@tim-landscheidt.de>
@ 2009-07-29 06:35 ` Axe <info@axier.se>
2009-07-30 07:53 ` Re: Tweak sql result set... ? Jasmin Dizdarevic <jasmin.dizdarevic@gmail.com>
2009-07-30 14:19 ` Re: Tweak sql result set... ? Tim Landscheidt <tim@tim-landscheidt.de>
0 siblings, 2 replies; 9+ messages in thread
From: Axe @ 2009-07-29 06:35 UTC (permalink / raw)
To: pgsql-sql
> > Any ideas on how to achieve this? I would like to let the original sql
> > code stay original. I can prepare postgres before executing the sql if
> > this makes it easier to acheive the goal
>
> Have a look at CREATE RULE.
>
> Tim
>
Ok, you mean I could create a rule for the table, then I let the
script go into my "black box",
do the original selects, but get a manipulated result set back, then I
drop the rule so
that the blackbox of scripts can get the not manipulated result set
back?
I need to sometimes get the result "<div>output from query</div>" and
sometimes not
and it would be awesomw to get it with the same query, but maybe by
setting
a rule or similar. Best from performance view would be to make
something
more permanent. Is it possible to activate/deactivate a rule?
Axe
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Tweak sql result set... ?
2009-07-28 20:49 Tweak sql result set... ? Axe <info@axier.se>
2009-07-29 00:24 ` Re: Tweak sql result set... ? Tim Landscheidt <tim@tim-landscheidt.de>
2009-07-29 06:35 ` Re: Tweak sql result set... ? Axe <info@axier.se>
@ 2009-07-30 07:53 ` Jasmin Dizdarevic <jasmin.dizdarevic@gmail.com>
2009-07-30 15:25 ` Re: Tweak sql result set... ? Rob Sargent <robjsargent@gmail.com>
1 sibling, 1 reply; 9+ messages in thread
From: Jasmin Dizdarevic @ 2009-07-30 07:53 UTC (permalink / raw)
To: Axe <info@axier.se>; pgsql-sql
i think jasen is thinking of manipulating the result set in your programming
enviroment not in the database.
btw from the point of "clean programming" it's a bad idea to integrate
html-elements directly into your database quereis. you're mixing data layer
and design layer.
what do you mean with sometimes?
2009/7/29 Axe <info@axier.se>
>
> > > Any ideas on how to achieve this? I would like to let the original sql
> > > code stay original. I can prepare postgres before executing the sql if
> > > this makes it easier to acheive the goal
> >
> > Have a look at CREATE RULE.
> >
> > Tim
> >
> Ok, you mean I could create a rule for the table, then I let the
> script go into my "black box",
> do the original selects, but get a manipulated result set back, then I
> drop the rule so
> that the blackbox of scripts can get the not manipulated result set
> back?
>
> I need to sometimes get the result "<div>output from query</div>" and
> sometimes not
> and it would be awesomw to get it with the same query, but maybe by
> setting
> a rule or similar. Best from performance view would be to make
> something
> more permanent. Is it possible to activate/deactivate a rule?
>
> Axe
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
--
Mit freundlichen Grüßen
Dizdarevic Jasmin
Sonnenbergstr. 3
6714 Nüziders, AUT
jasmin.dizdarevic@gmail.com
+43 664 411 79 29
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Tweak sql result set... ?
2009-07-28 20:49 Tweak sql result set... ? Axe <info@axier.se>
2009-07-29 00:24 ` Re: Tweak sql result set... ? Tim Landscheidt <tim@tim-landscheidt.de>
2009-07-29 06:35 ` Re: Tweak sql result set... ? Axe <info@axier.se>
2009-07-30 07:53 ` Re: Tweak sql result set... ? Jasmin Dizdarevic <jasmin.dizdarevic@gmail.com>
@ 2009-07-30 15:25 ` Rob Sargent <robjsargent@gmail.com>
2009-08-03 11:13 ` Re: Tweak sql result set... ? Axe <info@axier.se>
0 siblings, 1 reply; 9+ messages in thread
From: Rob Sargent @ 2009-07-30 15:25 UTC (permalink / raw)
To: Jasmin Dizdarevic <jasmin.dizdarevic@gmail.com>; +Cc: Axe <info@axier.se>; pgsql-sql
I agree. All clients issue the same sql and deal with it as they will.
The psql client for example can format the results in various ways (pset
variations etc). Your client(s) need(s) to interpret their identical
results differently. Doesn't seem to me to be the job of SQL?
Jasmin Dizdarevic wrote:
> i think jasen is thinking of manipulating the result set in your
> programming enviroment not in the database.
> btw from the point of "clean programming" it's a bad idea to integrate
> html-elements directly into your database quereis. you're mixing data
> layer and design layer.
>
> what do you mean with sometimes?
> 2009/7/29 Axe <info@axier.se <mailto:info@axier.se>>
>
>
> > > Any ideas on how to achieve this? I would like to let the
> original sql
> > > code stay original. I can prepare postgres before executing
> the sql if
> > > this makes it easier to acheive the goal
> >
> > Have a look at CREATE RULE.
> >
> > Tim
> >
> Ok, you mean I could create a rule for the table, then I let the
> script go into my "black box",
> do the original selects, but get a manipulated result set back, then I
> drop the rule so
> that the blackbox of scripts can get the not manipulated result set
> back?
>
> I need to sometimes get the result "<div>output from query</div>" and
> sometimes not
> and it would be awesomw to get it with the same query, but maybe by
> setting
> a rule or similar. Best from performance view would be to make
> something
> more permanent. Is it possible to activate/deactivate a rule?
>
> Axe
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org
> <mailto:pgsql-sql@postgresql.org>)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
>
>
>
> --
> Mit freundlichen Grüßen
>
> Dizdarevic Jasmin
> Sonnenbergstr. 3
> 6714 Nüziders, AUT
>
> jasmin.dizdarevic@gmail.com <mailto:jasmin.dizdarevic@gmail.com>
> +43 664 411 79 29
>
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Tweak sql result set... ?
2009-07-28 20:49 Tweak sql result set... ? Axe <info@axier.se>
2009-07-29 00:24 ` Re: Tweak sql result set... ? Tim Landscheidt <tim@tim-landscheidt.de>
2009-07-29 06:35 ` Re: Tweak sql result set... ? Axe <info@axier.se>
2009-07-30 07:53 ` Re: Tweak sql result set... ? Jasmin Dizdarevic <jasmin.dizdarevic@gmail.com>
2009-07-30 15:25 ` Re: Tweak sql result set... ? Rob Sargent <robjsargent@gmail.com>
@ 2009-08-03 11:13 ` Axe <info@axier.se>
0 siblings, 0 replies; 9+ messages in thread
From: Axe @ 2009-08-03 11:13 UTC (permalink / raw)
To: pgsql-sql
It seems not trivial to acheive what I wanted so I have decided to
move on
to get a grip of the smarty object that is also around but after the
blackbox
of scripts has run instead of before. This obejct can be parsed and is
generic
enough for my purposes.
Thanks for your time and suggestions.
/ Axe
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Tweak sql result set... ?
2009-07-28 20:49 Tweak sql result set... ? Axe <info@axier.se>
2009-07-29 00:24 ` Re: Tweak sql result set... ? Tim Landscheidt <tim@tim-landscheidt.de>
2009-07-29 06:35 ` Re: Tweak sql result set... ? Axe <info@axier.se>
@ 2009-07-30 14:19 ` Tim Landscheidt <tim@tim-landscheidt.de>
1 sibling, 0 replies; 9+ messages in thread
From: Tim Landscheidt @ 2009-07-30 14:19 UTC (permalink / raw)
To: pgsql-sql
(anonymous) wrote:
>> > Any ideas on how to achieve this? I would like to let the original sql
>> > code stay original. I can prepare postgres before executing the sql if
>> > this makes it easier to acheive the goal
>> Have a look at CREATE RULE.
> Ok, you mean I could create a rule for the table, then I let the
> script go into my "black box",
> do the original selects, but get a manipulated result set back, then I
> drop the rule so
> that the blackbox of scripts can get the not manipulated result set
> back?
No, I meant that you should have a look at CREATE RULE. From
a design perspective, I'd probably rename the old table and
put an updatable view in its place.
> I need to sometimes get the result "<div>output from query</div>" and
> sometimes not
> and it would be awesomw to get it with the same query, but maybe by
> setting
> a rule or similar. Best from performance view would be to make
> something
> more permanent. Is it possible to activate/deactivate a rule?
Of course, DROP RULE.
Tim
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Tweak sql result set... ?
2009-07-28 20:49 Tweak sql result set... ? Axe <info@axier.se>
@ 2009-07-29 12:39 ` Jasen Betts <jasen@xnet.co.nz>
1 sibling, 0 replies; 9+ messages in thread
From: Jasen Betts @ 2009-07-29 12:39 UTC (permalink / raw)
To: pgsql-sql
On 2009-07-28, Axe <info@axier.se> wrote:
> I have a problem where I want to tweak a simple select in an
> "unobtrusive way". Imagine I have the following select statement:
> "SELECT name FROM customer LIMIT 1" and I get a normal result set from
> this. But, could I,maybe by defining some other function or similar,
> change the result set *without* changing the query? Suppose I get the
> result from the query above, saying: "Peter Peterson". I would
> (sometimes) like to get the result "<div>Peter Peterson</div>" but I
> should not have to change the original query.
>
> I know I could write "SELECT '<div>' || name || '</div>' as name FROM
> customer" but then I have altered the original query and I cannot do
> this since it is supposed to function different in two different
> situations.
>
> Any ideas on how to achieve this? I would like to let the original sql
> code stay original. I can prepare postgres before executing the sql if
> this makes it easier to acheive the goal
put a wrapper round whatever it is you use to send the queries that
modifies the returned values.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Tweak sql result set... ?
@ 2009-07-30 13:31 Axe <info@axier.se>
0 siblings, 0 replies; 9+ messages in thread
From: Axe @ 2009-07-30 13:31 UTC (permalink / raw)
To: pgsql-sql
> i think jasen is thinking of manipulating the result set in your programming
> enviroment not in the database.
> btw from the point of "clean programming" it's a bad idea to integrate
> html-elements directly into your database quereis. you're mixing data layer
> and design layer.
>
> what do you mean with sometimes?
> 2009/7/29 Axe <i...@axier.se>
>
I am aware of this "clean programming" and this is a part of why
I am trying to keep my blackbox of script intact since I want to keep
a good standard in those scripts. Why I need it "sometimes" is beacuse
I want to use the set of production scripts for test purposes.
"Intact" and
when I am doing some tests, I would benefit from manipulating the
result
set I am getting out from postgres for testing purposes by just
prepend
my test-workbench on top of the production script.
/ Axe
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2009-08-03 11:13 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-07-28 20:49 Tweak sql result set... ? Axe <info@axier.se>
2009-07-29 00:24 ` Tim Landscheidt <tim@tim-landscheidt.de>
2009-07-29 06:35 ` Axe <info@axier.se>
2009-07-30 07:53 ` Jasmin Dizdarevic <jasmin.dizdarevic@gmail.com>
2009-07-30 15:25 ` Rob Sargent <robjsargent@gmail.com>
2009-08-03 11:13 ` Axe <info@axier.se>
2009-07-30 14:19 ` Tim Landscheidt <tim@tim-landscheidt.de>
2009-07-29 12:39 ` Jasen Betts <jasen@xnet.co.nz>
2009-07-30 13:31 Re: Tweak sql result set... ? Axe <info@axier.se>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox