Re: [SQL] Recursive pl/pgsql function ...

2006-10-16 Thread Markus Schaber
Hi, Marc,
Hi, Tom,

Tom Lane wrote:
> "Marc G. Fournier" <[EMAIL PROTECTED]> writes:
>> More then one Record:
>> # select get_next_billing_date(activated, 12) from company_details;
>> ERROR:  control reached end of function without RETURN
>> CONTEXT:  PL/pgSQL function "get_next_billing_date"
> 
> Hm, what PG version is this?  I couldn't duplicate that in HEAD, though
> I did find out that a zero or negative payment_period makes it recurse
> until "stack depth exceeded".

And this is the reason why that function is a nice example where the
recursive design approach is not necessary, and even hurts.

A simple while-Loop will do the same, more efficient, and without any
stack problems.

Btw, it may even be possible to use an explicit formula to calculate
this problem, but date and time calculations are always crazy.

HTH,
Markus
-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


[SQL] hi i want help on levels

2006-10-16 Thread Penchalaiah P.








CREATE TABLE admin_activity

(

  activity_id int4 NOT NULL,

  Activity_name varchar NOT NULL,

  URL varchar,

  parent_activity_id int4);

 

1 
Administration
 
0

2 
Activities  
1

3 
Manage
Activity
2

4  Map
Activity Role   2

5 
Allowance
1

6 
Bank
1

7  Code
Head   
1

8 
Corps   
1

9 
DSOP  
1

10
Entitlements 
1

 

These r the values to that table…

 

 

I want like this… tell me the query for this…

 

Administration -> Manage Actvities
-> Create Activity

è
Update
Activity

è
Delete Activity

 

Admin 1

 

Activity_id
activity_name   
    parent_id

_

1 
Admin  
    null

2 
`   Manage
activities   1

3 
    Create
Activity  
2

4 
    Update
Activity 
2 

5

Admin1
null

6 
    Delete
Activity  
2

   

 

 

 

Thanks  &  Regards

Penchal reddy | Software Engineer
  

Infinite Computer Solutions | Exciting Times…Infinite Possibilities... 

SEI-CMMI level 5 | ISO 9001:2000

IT SERVICES |
BPO  


Telecom | Finance
| Healthcare | Manufacturing
| Energy & Utilities | Retail
& Distribution | Government   


Tel +91-80-5193-(Ext:503)| Fax  +91-80-51930009 | Cell No  +91-9980012376|www.infics.com  

Information transmitted by this e-mail is
proprietary to Infinite Computer Solutions and/ or its Customers and is
intended for use only by the individual or entity to which it is addressed, and
may contain information that is privileged, confidential or exempt from
disclosure under applicable law. If you are not the intended recipient or it
appears that this mail has been forwarded to you without proper authority, you
are notified that any use or dissemination of this information in any manner is
strictly prohibited. In such cases, please notify us immediately at [EMAIL PROTECTED] and delete this mail from your records.

 







Information transmitted by this e-mail is proprietary to Infinite Computer Solutions and / or its Customers and is intended for use only by the individual or the entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at [EMAIL PROTECTED] and delete this email from your records.


Re: [SQL] deleting rows in specific order

2006-10-16 Thread Bruno Wolff III
On Wed, Oct 11, 2006 at 21:31:37 +0200,
  Daniel Drotos <[EMAIL PROTECTED]> wrote:
> On Wed, 11 Oct 2006, Markus Schaber wrote:
> 
> After inserting new rows into this table, very old rows are going to 
> be deleted. But value of deleted info should be remembered somehow, so 
> there is a trigger on delete which keeps sum of the deleted info 
> values in a separate table. This makes the application happy.

You need to be careful if two of these can run at the same time if you
are adding the values to prexisting sums otherwise you might end up summing
just the values from one of the delete sets.

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faq


Re: [SQL] Assigning a timestamp without timezone to a timestamp

2006-10-16 Thread chrisj

Thanks Tom that's great!!

When I first saw your solution I thought it was logically going to do
(notice the parentheses):
select ('2006-07-13 09:20:00'::timestamp) at time zone 'EST5EDT';  
which does not help

So I was not hopeful, but when I tried it it did exactly what I needed which
is:
select '2006-07-13 09:20:00'::(timestamp at time zone 'EST5EDT');  

My adjusted SQL is:

select start_datetime
  , cast(start_datetime as timestamp(0) without time zone)::timestamp at
time zone B.timezone_ch
   from reservation A
  , location B 
where  A.appt_key = 7 
   and B.locn_key = 102;

thank-you so much


Tom Lane-2 wrote:
> 
> chrisj <[EMAIL PROTECTED]> writes:
>> Did not seem to help:
>> ERROR:  invalid input syntax for type timestamp with time zone:
>> "2006-07-13
>> 09:20:00 America/New_York"
> 
> Sorry, I was thinking in terms of CVS HEAD ... the ability to use a full
> timezone spec in timestamptz input is new for 8.2.  You might be able to
> use this, which does work in 8.1:
> 
> select '2006-07-13 09:20:00'::timestamp at time zone 'EST5EDT';   
> 
>   regards, tom lane
> 
> ---(end of broadcast)---
> TIP 6: explain analyze is your friend
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Assigning-a-timestamp-without-timezone-to-a-timestamp-with-timezone-tf2373845.html#a6847852
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org