I'm pretty sure someone already answered this, but the mail archive isn't very searchable at the moment. How can you if(update row fails because doesn't exist, ie. returns 0)then(insert row) in SQL? Or am I misremembering and it was in some other language? Cheers, Patrick
> How can you
>
> if(update row fails because doesn't exist, ie. returns 0)then(insert row)
Depends on what interface you are using.
In perl DBI, the return value of the a $dbh->do("update...") should be
the nomber of rows inserted. Same with doing a sequence of
$sth=$dbh->prepare("updated...");
$rc=$sth->execute;
$rc will be the number of rows updated. Then just do the insert if $rc is 0.
In php, you use the function pg_NumRows.
In libpg, the number of rows is obtained from PGntuples after the update;
Karl
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера