Postgresql - sql:4862: ERROR: syntax error at or near "textGrande"

Asked

Viewed 549 times

0

Good night, you guys.

I am trying to import to my Postgres database an sql from an external database and am suffering the following error:

.sql:4862: ERROR:  syntax error at or near "textoGrande"

The sql structure is as follows:

-- PARA BANCO DE DADOS ORACLE, EXECUTAR A LINHA ABAIXO
-- SET DEFINE OFF;
DECLARE
textoGrande CLOB;
BEGIN
textoGrande := '';
INSERT INTO SGT_CONSULTA.CLASSES VALUES ('2','','','','ProcCivTrab',NULL,'','',textoGrande,'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','S','N','N','N','N','N','N','N','C','marivaldodantas',to_date('04/09/2012','DD/MM/YYYY HH24:MI:SS'),NULL,'pedro.amorim');
textoGrande := '';
INSERT INTO SGT_CONSULTA.CLASSES VALUES ('5','','','','STJ',NULL,'','',textoGrande,'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','C','pedro.amorim',to_date('15/10/2018','DD/MM/YYYY HH24:MI:SS'),NULL,NULL);
textoGrande := '<p align="justify" class="Artigo" style="color: rgb(0, 0, 0); font-family: Arial; font-size: small; text-indent: 35px;">
    Art. 318. &nbsp;Aplica-se a todas as causas o procedimento comum, salvo disposi&ccedil;&atilde;o em contr&aacute;rio deste C&oacute;digo ou de lei.</p>
<p align="justify" class="Artigo" style="color: rgb(0, 0, 0); font-family: Arial; font-size: small; text-indent: 35px;">
    Par&aacute;grafo &uacute;nico. &nbsp;O procedimento comum aplica-se subsidiariamente aos demais procedimentos especiais e ao processo de execu&ccedil;&atilde;o.</p>
'; [...]
END
-- SET DEFINE ON;

sql gives a syntax error stating that there is no such field textoGrande. Does anyone know how to overcome this mistake? The code used in the import terminal is: psql -h localhost -d databasename -U username -f dump_dados_postgres.sql The database is public and the full version is on the link: https://www.cnj.jus.br/sgt/versoes.php.

  • The Postgresql https://www.postgresql.org/docs/current/errcodes-appendix.html error table does not contain the 4862 error code. Which version of Postgresql? Which Operating System? I believe that the CBLOB data type does not exist in Postgresql.

  • Maybe the comment "-- FOR ORACLE DATABASE, RUN THE LINE BELOW" is a hint.

  • The Postgres version is 10.12. I’m using Mint 19.3. Really the type CLOB does not exist in Postgresql, but only in Oracle. But even if I delete these initial lines the error persists. psql:/home/alison/Downloads/dump_dados_postgres.sql:54793: ERROR: column "textogrande" does not exist&#xA;LINE 1: ...,'S','S','N','S','N','N','CPC 2015','1.036, § 1º',textoGrand...

  • So at the controls INSERT replace the occurrences of textoGrande for ''.

  • But if I do this I will lose the data that is in the variable textoGrande. The bank manager left this field as a kind of variable because it has a really large text and the insert could be illegible. I thought about replacing manually, as you said, but the BD has more than 93,000 records and hundreds of Inserts with this variable. It is unviable.

  • Then replace the guy CLOBby a type accepted by Postgresql, text maybe?

  • I’ve done that, too, but it didn’t work. The error continued. Including the logo of the error I posted above in the comments has already occurred with the field change CLOB for TEXT.

  • Strange, this error code https://www.postgresql.org/docs/10/errcodes-appendix.htmlis not in version 10.

  • Debugging around here I realized that this code before the name error is not a postgres error code, but the sql line that is triggering the error, understand? The exit from the same error is just ERROR: column "textogrande" does not exist

  • I took a look at the data file and I believe you can put the file data inside an anonymous block. See: https://www.postgresql.org/docs/current/sql-do.html

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.