The Maginot Line wasn't a wall, but it is similar, a series of connected fortresses designed to make it difficult for the Germans to invade France, or at least slow them considerably to allow France time to respond. And, it worked, tactically. It failed strategically of course, but the Germans didn't come into France that way.
The Berlin Wall largely worked. Walls around the White House and other sensitive establishments work, in part because they are manned and observed. It's not that hard to build a wall no human can feasibly traverse (with taking to air or boat). It has to be manned of course. But I think in some areas of the border a wall isn't needed as such, and in some areas other kind of inhibiting features could work.