Dear Friends,
I am using PostgreSQL 7.3.4 Server on RH Linux 7.2. I am
trying to generate a dynamic query to fetch the next month
interval.
select now()+ interval'1 month'; -- This is working
fine.
I wanna dynamically assign the interval number. i,e -->
select now()+ interval'n month'
>
> Dear Friends,
>
> I am using PostgreSQL 7.3.4 Server on RH Linux 7.2. I am trying to generate=
> a dynamic query to fetch the next month interval.
>
> select now()+ interval'1 month'; -- This is working fine.
>
> I wanna dynamically assign the interval number. i,e --> select now()+ inter=
I am using the For controle structure as
follows
FOR i IN 0..23 LOOP
query
END LOOP;
The query is tested and is working OK.
When I launch the loop in psql interface, I get the
error parse error at or near FOR.
As this is the first time I use this kind of
struture I am probably us
Dear Christoph Haller,
The code that u sent is not working
test=> EXECUTE 'select now()+ interval\'' ||to_char(3,'9')|| 'month\'';
ERROR: parser: parse error at or near "'select now()+ interval\''" at
character 9
test=>
Also I tried just to run the now() function with a dynamic query, I got the
On Monday 10 November 2003 11:24, Guillaume Houssay wrote:
> I am using the For controle structure as follows
>
> FOR i IN 0..23 LOOP
>
> query
>
> END LOOP;
>
> The query is tested and is working OK.
>
> When I launch the loop in psql interface, I get the error parse error at or
> near FOR.
The F
Kumar,
why dont you try
prepare fooplan2(int4) as select now() + ($1||' month')::interval;
execute fooplan2(12);
O kyrios Kumar egrapse stis Nov 10, 2003 :
> Dear Christoph Haller,
>
> The code that u sent is not working
> test=> EXECUTE 'select now()+ interval\'' ||to_char(3,'9')|| 'month\''
I like Achilleus' proposal for its elegance,
just in case you are interested in the old-school plpgsql way:
create or replace function future_date(int) returns timestamp as 'declare
future_dat timestamp;
future_off text;
begin future_dat := ''now'' ;
future_off := $1::text;
future_off := future_
That's what I said! :)
Yasir
On Sun, 9 Nov 2003, Christopher Browne wrote:
> Date: Sun, 09 Nov 2003 21:59:14 -0500
> From: Christopher Browne <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Re: [SQL] help me...
>
> The world rejoiced as [EMAIL PROTECTED] (ron_tabada) wrote:
> > Hello every
Kumar,
What about this:
EXECUTE 'select now()+ interval \' || to_char(3,\'9\') || \'month\' ';
George
- Original Message -
From: "Kumar" <[EMAIL PROTECTED]>
To: "Christoph Haller" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, November 10, 2003 5:57 AM
Subject: Re: [SQL] Dyn
On Mon, 10 Nov 2003, Kumar wrote:
> select now()+ interval'1 month'; -- This is working fine.
>
> I wanna dynamically assign the interval number. i,e --> select now()+
> interval'n month';
If n is an integer, I'd suggest something like
select now() + n * interval '1 month';
rather than messing
On Mon, 10 Nov 2003, Holger Jakobs wrote:
> Hi Stephan,
>
> On 9 Nov, Stephan Szabo wrote:
> > On Fri, 7 Nov 2003 [EMAIL PROTECTED] wrote:
> >
> >> Whenever an error occurs within the transaction, PostgreSQL puts the
> >> whole transaction in an *ABORT* state, so that there is no difference
> >>
You will have to use a WHERE clause or a JOIN in query three, so you
will have to include some field, such as itemno, in the result sets of
both query1 and query2 on which you can join with where or join. Such
as:
Select query1.sumofqty as sum1, query2.sumofqty as sum2, query1.sumofqty
- query2.s
Hi Stephan,
On 9 Nov, Stephan Szabo wrote:
> On Fri, 7 Nov 2003 [EMAIL PROTECTED] wrote:
>
>> Whenever an error occurs within the transaction, PostgreSQL puts the
>> whole transaction in an *ABORT* state, so that there is no difference
>> at all between COMMITing or ROLLBACKing it. Even commands
Hi,
I'm usually wrong, but you can create a view for Query1 and Query2. That
is do
create view Query1 [your query for query1];
create view Query2 [your query for query2];
Then what you are doing should work.
Regards,
Yasir
On Sat, 8 Nov 2003, [iso-8859-1] ron_tabada wrote:
> Date: Sat, 8 Nov 20
I am using the For controle structure as
follows
FOR i IN 0..23 LOOP
query
END LOOP;
The query is tested and is working OK.
When I launch the loop in psql interface, I get the
error parse error at or near FOR.
As this is the first time I use this kind of
struture I am probably usi
Holger Jakobs wrote:
Hi Stephan,
On 9 Nov, Stephan Szabo wrote:
On Fri, 7 Nov 2003 [EMAIL PROTECTED] wrote:
Whenever an error occurs within the transaction, PostgreSQL puts the
whole transaction in an *ABORT* state, so that there is no difference
at all between COMMITing or ROLLBACKing it. Even
> be recovered either. When committing a transaction the effects of all
> operations that did not fail will be made permanent. This is how
> transaction processing is described in the literature.
I would be interested in reading that (URLs please) as I didn't see
anything in the spec that was inte
Kumar wrote:
Dear Friends,
I am using PostgreSQL 7.3.4 Server on RH Linux 7.2. I am trying to
generate a dynamic query to fetch the next month interval.
select now()+ interval'1 month'; -- This is working fine.
I wanna dynamically assign the interval number. i,e --> select now()+
interval
Rod Taylor wrote:
be recovered either. When committing a transaction the effects of all
operations that did not fail will be made permanent. This is how
transaction processing is described in the literature.
I would be interested in reading that (URLs please) as I didn't see
> Although i am not aware of the roots of this discussion but would like
> to
> comment at this point .
>
> When we work with sequences an aborted transaction does have
> a permanent effect on the last value of sequence. Is this behaviour
> not a violation of above defination of transaction ?
I
Hi-
I'm suffering from a performance problem, but when I look at my query, I'm
not convinced that there isn't a better way to handle this in SQL. -So I'm
seeking advice here before I go to the performance list.
I have three tables- case, actor and actor_case_assignment.
As the names imply, actor
On Nov 10, 2003, at 1:02 PM, Nick Fankhauser wrote:
Hi-
I'm suffering from a performance problem, but when I look at my query,
I'm
not convinced that there isn't a better way to handle this in SQL. -So
I'm
seeking advice here before I go to the performance list.
An explain analyze would help.
Hi,
I tried CLUSTER and it did improve performance, somewhat. The query against
"clustered" table performs about five (5) times better than the same table but
"non-clustered". However, even after that table was clustered, the difference
in performance between single record query and range query is
--- Stephan Szabo <[EMAIL PROTECTED]> wrote:
> I'm not sure that AK_abc is the best index for check a range on a and
> single values on b and c. I'd think that something like an index
> on (b,c,a) would probably be better for this purpose (without doing any
> testing ;) ).
That would not work fo
ow wrote:
> Hi,
>
> I tried CLUSTER and it did improve performance, somewhat. The query against
> "clustered" table performs about five (5) times better than the same table but
> "non-clustered". However, even after that table was clustered, the difference
> in performance between single record qu
On Mon, 10 Nov 2003, ow wrote:
> --- Stephan Szabo <[EMAIL PROTECTED]> wrote:
> > I'm not sure that AK_abc is the best index for check a range on a and
> > single values on b and c. I'd think that something like an index
> > on (b,c,a) would probably be better for this purpose (without doing any
Hi there!
If I've a table like below.
kk kj pngk vote
01 02 c 10
01 02 b 5
How do I make a query so that I can get a result
like this?
kk kj pngk vote
01 02 c,b 15
Any help pretty much appreciated.
-
--- Bruce Momjian <[EMAIL PROTECTED]> wrote:
> Strange 30 records takes 30x the time than one record. Can you run
> ANALYZE and send us an EXPLAIN of the query to make sure it hasn't
> changed?
>
explain analyze select * from Test
where a >= '2002-06-18'
and a <= '2002-07-18'
and b = 5
and
Abdul Wahab Dahalan wrote:
If I've a table like below.
kk kjpngkvote
01 02 c 10
01 02 b 5
How do I make a query so that I can get a result
like this?
kk kjpngkvote
01 02c,b 15
create or replace function accum_text(tex
ow wrote:
> --- Bruce Momjian <[EMAIL PROTECTED]> wrote:
> > Strange 30 records takes 30x the time than one record. Can you run
> > ANALYZE and send us an EXPLAIN of the query to make sure it hasn't
> > changed?
> >
>
> explain analyze select * from Test
> where a >= '2002-06-18'
> and a <= '2
Bruce Momjian <[EMAIL PROTECTED]> writes:
> Sorry there isn't a simple solution.
But there is: make an index with the column order (b,c,a).
regards, tom lane
---(end of broadcast)---
TIP 8: explain analyze is your friend
Tom Lane wrote:
> Bruce Momjian <[EMAIL PROTECTED]> writes:
> > Sorry there isn't a simple solution.
>
> But there is: make an index with the column order (b,c,a).
Oh, yea, right. If he puts the columns he is doing a straight equals
comparison first, the 'a' comparison will work fine. Great.
-
32 matches
Mail list logo