| From: | Pascal Bourguignon <pjb(at)informatimago(dot)com> |
|---|---|
| To: | tgl(at)sss(dot)pgh(dot)pa(dot)us |
| Cc: | pgsql-bugs(at)postgresql(dot)org |
| Subject: | Re: problem with plpgsql |
| Date: | 2001-08-20 15:50:53 |
| Message-ID: | 20010820155053.DAA3A5D327@thalassa.informatimago.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
> Pascal Bourguignon <pjb(at)informatimago(dot)com> writes:
> > I'm trying to write a function to either insert a new row, or update
> > an existing row. However, the test "if not found" is always true,
>
> I believe you're getting burnt by the fact that lim.login is declared
> as char(8) --- so it has trailing blanks --- whereas the first parameter
> of lim_update is declared as text --- so it doesn't have trailing
> blanks. What's more, the comparison login=plogin will be done under
> "text" rules wherein trailing blanks are significant. So 'pjb' is not
> equal to 'pjb '.
>
> The ip and mac columns have the same problem.
>
> Advice: don't use char(n) for data that's not really fixed-width.
>
> regards, tom lane
Thank you very much. I overlooked that.
Changing the attributes type from char to varchar solves the problem.
create table lim (
login varchar(8),
ip varchar(15),
mac varchar(17),
last_date date,
logcnt integer
);
--
__Pascal_Bourguignon__ (o_ Software patents are endangering
() ASCII ribbon against html email //\ the computer industry all around
/\ and Microsoft attachments. V_/ the world http://lpf.ai.mit.edu/
1962:DO20I=1.100 2001:my($f)=`fortune`; http://petition.eurolinux.org/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT d? s++:++(+++)>++ a C+++ UB+++L++++$S+X++++>$ P- L+++ E++ W++
N++ o-- K- w------ O- M++$ V PS+E++ Y++ PGP++ t+ 5? X+ R !tv b++(+)
DI+++ D++ G++ e+++ h+(++) r? y---? UF++++
------END GEEK CODE BLOCK------
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2001-08-20 15:53:39 | Re: Various doc errors and shortcomings |
| Previous Message | Stephan Szabo | 2001-08-20 15:39:02 | Re: problem with plpgsql |