vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Please, help me! My code: "IF char_length(substring(str from '^[a-zA-Z]*://'))=0 THEN str:= 'http://'||str; END IF;" If str= http://www.msn.com then nothing happen (all is OK), but if str= just www.msn.com then nothing happen too! Why? Then I experimen with that: I change '=' to '<>' results: str=http://www.msn.com -> http://http://www.msn.com str=www.msn.com -> http://www.msn.com Thank you. ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match |
| ||||
| On Thu, 26 Jul 2007, [UTF-8] ТÑ^CÑ^Gков Ð^\иÑ^Eаил wrote: > Please, help me! > My code: > "IF char_length(substring(str from '^[a-zA-Z]*://'))=0 THEN > str:= 'http://'||str; > END IF;" > > If str= http://www.msn.com then nothing happen > (all is OK), but if str= just www.msn.com then nothing happen too! > > Why? According to: http://www.postgresql.org/docs/8.2/i...-matching.html a non-match returns NULL, whose char_length is also NULL. Using one of the regexp operators ~ or ~* would probably be easier, but if you really wanted to do this with substring, you should be checking for no match, not a 0 length match. ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend |