> -----Original Message-----
> From: Adrian Klaver [mailto:adrian.klaver@aklaver.com]
> Sent: Saturday, May 20, 2017 7:08 AM
> To: Ertan Küçükoğlu <ertan.kucukoglu@1nar.com.tr>;
pgsql-sql@postgresql.org
> Subject: Re: [SQL] SQL conversion help
>
>On 05/19/2017 09:01 PM, Ertan Küçükoğlu wrote:
>> Hello,
>>
>> I have below SQL script used in SQL Server. I would like some help to
>> convert it into PostgreSQL format, please.
>>
>> DECLARE @satirno INT
>> SET @satirno = 0
>> UPDATE urtrecetedet
>> SET @satirno = satirno = @satirno + 1
>> WHERE recetekodu = 'ASD'
>
> I would suggest taking a look at:
>
> https://www.postgresql.org/docs/9.6/static/plpgsql.html
>
> In particular:
>
> https://www.postgresql.org/docs/9.6/static/plpgsql-structure.html
>
> https://www.postgresql.org/docs/9.6/static/plpgsql-declarations.html
>
> https://www.postgresql.org/docs/9.6/static/plpgsql-statements.html
Hi Adrian,
Thanks for documents links. After checking them out. I ended up using
something like following SQL script instead of a function.
create sequence if not exists fsatirno;
alter sequence fsatirno restart;
update urtrecetedet set satirno = nextval('fsatirno') where recetekodu = 'ASD';