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. Aplica-se a todas as causas o procedimento comum, salvo disposição em contrário deste Có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ágrafo único. O procedimento comum aplica-se subsidiariamente aos demais procedimentos especiais e ao processo de execuçã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.
– anonimo
Maybe the comment "-- FOR ORACLE DATABASE, RUN THE LINE BELOW" is a hint.
– anonimo
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
LINE 1: ...,'S','S','N','S','N','N','CPC 2015','1.036, § 1º',textoGrand...
– Alison Andrade
So at the controls
INSERT
replace the occurrences oftextoGrande
for''
.– anonimo
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 theinsert
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.– Alison Andrade
Then replace the guy
CLOB
by a type accepted by Postgresql,text
maybe?– anonimo
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
forTEXT
.– Alison Andrade
Strange, this error code https://www.postgresql.org/docs/10/errcodes-appendix.htmlis not in version 10.
– anonimo
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
– Alison Andrade
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
– anonimo