Re: oracle to postgres

Поиск
Список
Период
Сортировка
От Jim Nasby
Тема Re: oracle to postgres
Дата
Msg-id 54D03D27.5070305@BlueTreble.com
обсуждение исходный текст
Ответ на Re: oracle to postgres  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Ответы Re: oracle to postgres  (BladeOfLight16 <bladeoflight16@gmail.com>)
Список pgsql-general
On 2/2/15 9:13 PM, Jim Nasby wrote:
> On 1/29/15 3:02 PM, Adrian Klaver wrote:
>> On 01/29/2015 03:16 AM, Ramesh T wrote:
>>> hello,
>>> can any one help me to convert oracle to postgres script..?
>>> following code ..
>>> BEGIN
>>>     EXECUTE IMMEDIATE 'DROP TABLE CONTAINER';
>>> EXCEPTION
>>>     WHEN OTHERS THEN
>>>        IF SQLCODE != -942 THEN
>>>           RAISE;
>>>        END IF;
>>> END;
>>> advance thanks,
>>
>> For hints and tips see:
>>
>> http://www.postgresql.org/docs/9.3/interactive/plpgsql-porting.html
>>
>> In this case I believe the following is what you want:
>>
>> BEGIN
>>     DROP TABLE CONTAINER;
>> EXCEPTION
>>     WHEN OTHERS THEN
>>        IF RETURNED_SQLSTATE != -942 THEN
>>           RAISE;
>>        END IF;
>> END;
>
> It would be even better to instead do...
>
> EXCEPTION
>      WHEN blah THEN
>          NULL; -- Ignore this error
>
> See other comments about the correct error code to use. Also, note that
> this is a risky pattern; it will ignore that error no matter what object
> generated it. I much prefer to also sanity-check the actual error
> message to make sure the error is on the object we expect it to be.

Or even better yet... just use DROP IF EXISTS...
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com


В списке pgsql-general по дате отправления:

Предыдущее
От: Jim Nasby
Дата:
Сообщение: Re: oracle to postgres
Следующее
От: Jim Nasby
Дата:
Сообщение: Re: Versioning Schema SQL ideas needed