Re: oracle to postgres
От | Jim Nasby |
---|---|
Тема | Re: oracle to postgres |
Дата | |
Msg-id | 54D03CCC.8040204@BlueTreble.com обсуждение исходный текст |
Ответ на | Re: oracle to postgres (Adrian Klaver <adrian.klaver@aklaver.com>) |
Ответы |
Re: oracle to postgres
|
Список | pgsql-general |
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. -- Jim Nasby, Data Architect, Blue Treble Consulting Data in Trouble? Get it in Treble! http://BlueTreble.com
В списке pgsql-general по дате отправления: