| От | Mario Splivalo |
|---|---|
| Тема | Trapping 'invalid input syntax for integer' |
| Дата | |
| Msg-id | 4AA8EFAB.8070509@megafon.hr обсуждение исходный текст |
| Ответы |
Re: Trapping 'invalid input syntax for integer'
|
| Список | pgsql-sql |
Is there a way to trap this error in plpgsql code? I have a function that accepts integer and character varying. Inside that function I need to cast that varchar to integer. Of course, sometimes that is not possible. When I run function like that, I get this errror: fidel=# select * from get_account_info_by_tan(1, 'mario'); ERROR: invalid input syntax for integer: "mario" CONTEXT: SQL statement "SELECT user_id FROM user_tans WHERE user_tan =$1 ::bigint" PL/pgSQL function "get_account_info_by_tan" line 8 at assignment Now, I know I could change the SELECT so it looks like: SELECT user_id FROM user_tans WHERE user_tan::varchar = $1 But, is there a way to trap above error usin EXCEPTION WHEN keyword in plpgsql? Mike
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера