The game tries to prevent you from building all the way to the edge of any map you embark on, probably to prevent your blocking of caravans, new immigrants, and goblin invasions.
The restrictions it puts on building close to the edge have limitations that other DF players have discovered:
1) You can build walls 5 tiles from the edge.
2) you can build fortifications 4 tiles from the edge.
3) you can channel 2 tiles from the edge.
4) you can build floors all the way to the edge.
5) You can build a drawbridge and then lower/extend it all the way to the edge.
If you want to create a drain for your river, you have two choices; find a way to empty the river over the edge of your map or channel it to some aquifer tiles, which can absorb any amount of water.
One way to empty water over the edge of the map is to dig down at the map edge and attempt to find one of the cavern layers under that point. If the cavern connects to the map edge, any water dumped down that hole will flow out of the map through the cavern.