[GENERAL] Are there limits to number of INSERTS inside a Transaction?

2000-07-12 Thread Ken Causey

I can tell this is going to be a good day, it's my second stupid question
of the day.  Thanks to Alex Bolenok for a complete, concise answer to my
first question!

Now the question:  Can I do too much inside a transaction?  In other
words, say I was importing a file with 100,000 records and I wanted
to make sure either the whole thing imported or none of it; would it
be a bad idea to do ALL of the inserts within a single transaction?

Are there any limits to the number of inserts/updates within a transaction?

Ken Causey 



Re: [GENERAL] Getting number of days in a month

2000-04-12 Thread Ken Causey

Here's my perl implementation:

###
#
#  lastday( month, year (4 digit) )
#
#  Returns: last day of the month
#
###

sub lastday {
   my $month=shift;
   my $year= shift;

   $month--;

   my @days = (31,0,31,30,31,30,31,31,30,31,30,31);

   if($days[$month] != 0){
  return $days[$month];
   } else {
   # It's Feb, test for leap year
  if($year % 4 != 0){
 return 28;
  } elsif($year % 400 == 0){
 return 29;
  } elsif($year % 100 == 0){
 return 28;
  } else {
 return 29;
  }
   } 
}

Ken Causey
ineffable

At 02:26 PM 4/12/00 +0200, you wrote:
>To obtain the number of days in a month, I wrote this function:
>
>CREATE FUNCTION dayCountOfMonth(datetime) RETURNS float AS
>'  DECLARE
>   theDate ALIAS FOR $1;
>   monthStart  date;
>   monthEnddate;
>   BEGIN
>   monthStart := DATE_TRUNC(''month'', theDate);
>   monthEnd := monthStart + ''1 month''::timespan - ''1 day''::timespan;
>   RETURN DATE_PART(''doy'', monthEnd) - DATE_PART(''doy'', monthStart) + 
>1;
>   END;
>'  LANGUAGE 'PL/pgSQL';
>
>It seems to work, except with the month of October (10).
>
>dayCountOfMonth('1997-10-1') => 30 
>dayCountOfMonth('1998-10-1') => 30 
>dayCountOfMonth('1999-10-1') => 31
>dayCountOfMonth('2000-10-1') => 30 
>dayCountOfMonth('2001-10-1') => 30
>dayCountOfMonth('2002-10-1') => 30
>dayCountOfMonth('2003-10-1') => 30
>dayCountOfMonth('2004-10-1') => 31
>
>Just one question: WHY??
>(Note: no trouble with February)
>
>Is there a function that give the number of days of a month?
>
>Thanks,
> 
>Guillaume Perréal - Stagiaire MIAG
>Cemagref (URH), Lyon, France
>Tél: (+33) 4.72.20.87.64
>
>