Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iTSiX-0001Aw-AY for pgsql-general@arkaria.postgresql.org; Sat, 09 Nov 2019 15:32:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iTSiU-0006CF-5U for pgsql-general@arkaria.postgresql.org; Sat, 09 Nov 2019 15:31:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iTSiT-0006C8-SG for pgsql-general@lists.postgresql.org; Sat, 09 Nov 2019 15:31:57 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iTSiR-0002Bj-8Y for pgsql-general@lists.postgresql.org; Sat, 09 Nov 2019 15:31:57 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 972891383; Sat, 9 Nov 2019 16:31:53 +0100 (CET) Date: Sat, 9 Nov 2019 16:31:53 +0100 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: type SERIAL in C host-struct Message-ID: <20191109153153.GA21937@hjp.at> References: <20191107113939.GA130862@sh4-5.1blu.de> <20191107191447.GA2407@c720-r342378> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="AhhlLboLdkugWU4S" Content-Disposition: inline In-Reply-To: <20191107191447.GA2407@c720-r342378> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2019-11-07 20:14:47 +0100, Matthias Apitz wrote: > At the end of the day we came up with the following solution: >=20 > strcpy(host_struct.name, "Sigrid"); > EXEC SQL select nextval('lina_lid_seq') into :host_struct.ser; >=20 > EXEC SQL INSERT INTO lina VALUES ( :host_struct ); =20 >=20 > which seems to work fine. Any comments about side effects? You are performing two queries instead of one, so you have to wait for one extra round trip. Not a problem if client and server are on the same network or you insert a few host_structs per second. May be a problem if client and server are in different datacenters and you want to do hundreds of inserts per second. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --AhhlLboLdkugWU4S Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAl3G2+QACgkQ8g5IURL+ KF2x/A/+JBTisxzjjkKU0LBo2DEVvVzTT6OOt2wSFGXUNY6P3lg6AsYvjELXtZXF XfFPTm6JLJ5FtR0fAGSyG66tU6pWimE+zgwz7l/qUdnXZ8Nhj8pHYDFt42FaGB7F I2vKmS/ZxNMdsyKTdNA77JLs9lAYd6Df6rhgLY7L56dTlLljDUsgB6RSI2iQB7U0 EHL62yc00JlXxye29q2lGJH+0FP9RikqaSKEE/VHVX6WPxrCuZkOT8xT5cJwNV/7 wKkJ3smwKgPvzZ0ajHFZ35ZsdoWRotnRSi7PZh/jCKZTGlYicsw93PTKjR28WXnD vn8kwLQPLMQ2GLxtQ/ldJ82AKkn9lcxa2mBZ9gbNTWplrY3oRCUSDnezQWQ7/PYf 47NCrkIbuEkn1ZHp3R4tkKFz29q3x89fUS1jn2Tg4HDbXUU/mLU1JjM0yVsl0aQG kHiHChCopWoImszPA2ynv92+kp8IgQrzYQp+pquIJujKKsti2/Ee9qMB1xadPVk4 x3yWMSYMq9UWYhe4v54ByoIlZgzWiighQ75SKaOzF8753VYQsLcudslpPXw28c04 aTV8i57K/vQ6dLLafbFFM3rqq0HP5yCMiz10ErJANowCUTLyc03TTmgXucu2+jIr mCX+kN+3/F/cdho7HnmjiuC6K4EtrIVy9Ln1ZWk5MTsL6SvibiE= =nT3q -----END PGP SIGNATURE----- --AhhlLboLdkugWU4S--