Postgresql Declare Variable In Function In R