Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sGn58-00HF2h-8W for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2024 22:01:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sGn56-00GoKh-JC for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2024 22:01:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sGn56-00GoKX-8N for pgsql-general@lists.postgresql.org; Mon, 10 Jun 2024 22:01:37 +0000 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sGn55-00102a-3F for pgsql-general@lists.postgresql.org; Mon, 10 Jun 2024 22:01:36 +0000 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-5b2e93fddafso2290974eaf.0 for ; Mon, 10 Jun 2024 15:01:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718056893; x=1718661693; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=a1BeMf/rHZ1tHI1dJ5N4WvUCTrKsLCkKTgspdL1vnDs=; b=Z1wccR4X4NJcmFP9meP3Tu0KtrsUHy3jkMAHyd26ykbclvNti39eTSBo5j9LFKkkQI qJJ2TrhfHi36b1wXRfLuuMIHN1JXCshxNErqtUTJFpfQ7pNpz1gGeV9r8qmzkXQeU5n7 KdWmrFEnye6356GlDwpt1iMRrtz1BdrvbwN5YC3B4ddjx9JZBd8Am70Zg1yJblGu4e2k naJ9Ocuy58Qqd4e0nx7tNRMBvTq2RKTWl+okGzsSeXqH3i76lP3yjrKPbRTf/fZqsrSs hLIpdJ6NKo0vf36ESJeQ52zIGKD3V1xSOmsLb0eOy2Mva5+R+iW18QBLgIuv+cXApZqR KZ7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718056893; x=1718661693; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=a1BeMf/rHZ1tHI1dJ5N4WvUCTrKsLCkKTgspdL1vnDs=; b=qeKwk9tmkrzBnZOmhgYMA/Rr+no1fuYLYOM6S7pSGSp0SnpM89SHgolmAWbW4mx3nZ B58uNZ+YwDYDsyowjE3TwDiRW2hXKOdFG2f2xoRaMoVIoChqNbNhwJil6gYivc3e/q2c WMMUvoGftUuM8/Pl7hJack/jZ6KeJKbgwbRnmLlNSmmlZnKIWSSDaLHkLMVj2j4gKce1 mWDZBaDsWbQyq8ZXnBnQUwHMe/YI4xisla3aBsPc0PU2RGCneGpUlFHglu1refRuqhYZ qyEmteRoOCs4GW5c7JktgH04gQa61qb13ZhvwaK6MeiOS6uzUhDbaDkbo8V0vFmk8cLT W4dw== X-Gm-Message-State: AOJu0YzYcPnGykuwH9NDec54TfYwY/lhPsmgBXNWYHQqyy1j9iVFZns0 CMQeJo8xZH6bnjpnhfTXLyDeBKcqxjXKv1guTVSXeIsHmk+qR4DhDIGVpR4+7RFefC99NSofRcn JWLTaoUDcctvdJeS6bh99bhkXqce5Lg== X-Google-Smtp-Source: AGHT+IGTy0l2oi2pucz7ONDoU3nmk4ojrDNDXW0URCU+QOpbZvI3tf1fX7rsXsDhM2XMipEGJxAwYsWXlKVLKTFJyp0= X-Received: by 2002:a05:6820:1b8e:b0:5bb:182a:26ab with SMTP id 006d021491bc7-5bb1f557ecbmr448359eaf.0.1718056893291; Mon, 10 Jun 2024 15:01:33 -0700 (PDT) MIME-Version: 1.0 References: <7da8ec9-089-74ce-eb3-c88889b62c64@appl-ecosys.com> <20240610212715.aqpipehoa5xxmrmf@hjp.at> <153620cc-69f4-d850-ae36-2224dbd7f5ae@appl-ecosys.com> In-Reply-To: <153620cc-69f4-d850-ae36-2224dbd7f5ae@appl-ecosys.com> From: "David G. Johnston" Date: Mon, 10 Jun 2024 15:00:55 -0700 Message-ID: Subject: Re: Multiple tables row insertions from single psql input file To: Rich Shepard Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000d4267b061a904a4f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000d4267b061a904a4f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 10, 2024 at 2:58=E2=80=AFPM Rich Shepard wrote: > > INSERT into companies (company_nbr,company_name,industry,status) VALUES > nextval('companies_org_nbr_seq'),'Acme','Manufacturing','Opportunity'), > nextval('companies_org_nbr_seq'),'Baker','Livestock','Opportunity'); > > Running: > $ psql -U rshepard -d bustrac -f test-script.sql > psql:test-script.sql:3: ERROR: syntax error at or near "nextval" > LINE 2: nextval('companies_org_nbr_seq'),'Acme','Manufacturing','Opp... > ^ > What have I missed? > > Values introduces literal records/rows. Rows are written within parentheses. Values (..., ...), (..., ...) You seem to have the closing parenthesis but not the opening one. David J. --000000000000d4267b061a904a4f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Jun 10, 2024 at 2:58=E2=80=AFPM Rich Shepard <<= a href=3D"mailto:rshepard@appl-ecosys.com">rshepard@appl-ecosys.com>= wrote:

INSERT into companies (company_nbr,company_name,industry,status) VALUES nextval('companies_org_nbr_seq'),'Acme','Manufacturing&= #39;,'Opportunity'),
nextval('companies_org_nbr_seq'),'Baker','Livestock'= ;,'Opportunity');

Running:
$ psql -U rshepard -d bustrac -f test-script.sql
psql:test-script.sql:3: ERROR:=C2=A0 syntax error at or near "nextval&= quot;
LINE 2: nextval('companies_org_nbr_seq'),'Acme','Manufa= cturing','Opp...
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^
What have I missed?


Values introduces= literal records/rows.=C2=A0 Rows are written within parentheses.
V= alues (..., ...), (..., ...)

You seem to have the=C2= =A0closing parenthesis but not the opening one.

David = J.

--000000000000d4267b061a904a4f--