Re: problem with plpgsql
От | Pascal Bourguignon |
---|---|
Тема | Re: problem with plpgsql |
Дата | |
Msg-id | 20010820155053.DAA3A5D327@thalassa.informatimago.com обсуждение исходный текст |
Ответ на | Re: problem with plpgsql (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-bugs |
> Pascal Bourguignon <pjb@informatimago.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------
В списке pgsql-bugs по дате отправления: