So if a select into returns no records you get the no data found error. You can put that piece of sql into its own function then catch the no data found error and when it gets thrown return a default value.