[SQL] Tweak sql result set... ?
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 "Peter Peterson" but I should not have to change the original query. I know I could write "SELECT '' || name || '' 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 -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] Tweak sql result set... ?
> > 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 "output from query" 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 ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] Tweak sql result set... ?
> 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 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 -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
Re: [SQL] Tweak sql result set... ?
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 -- Sent via pgsql-sql mailing list ([email protected]) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql
