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.96) (envelope-from ) id 1vyzUE-000bFR-2H for pgsql-general@arkaria.postgresql.org; Sat, 07 Mar 2026 21:47:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vyzUB-009iJm-2f for pgsql-general@arkaria.postgresql.org; Sat, 07 Mar 2026 21:47:00 +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.96) (envelope-from ) id 1vyzUB-009iJS-1X for pgsql-general@lists.postgresql.org; Sat, 07 Mar 2026 21:46:59 +0000 Received: from mail-yx1-xb130.google.com ([2607:f8b0:4864:20::b130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vyzU8-00000001Omg-3rz1 for pgsql-general@lists.postgresql.org; Sat, 07 Mar 2026 21:46:59 +0000 Received: by mail-yx1-xb130.google.com with SMTP id 956f58d0204a3-64ae222d87dso9518849d50.2 for ; Sat, 07 Mar 2026 13:46:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772920015; cv=none; d=google.com; s=arc-20240605; b=NpyEkD5l141RN2hzQMCfxAuOwaPcMaRFFo8CqQ+QAYOWnktR6dBBKSPjBsU7JdFQ0c BTTZ98X9Z8/jKOvArUYyhvubVBbUCC/QwvFIoihCgWi6SOFrvBO/SBWw9NyNgc9qdIEO jDpLz3iV9yjwL+SxfLTQnwg7WKcQBdjlIgq8g01+Li4IzrvNNN0gbzQFdW1ZzTDq48T6 kN9tWCBYC2jD1rY2MP+++dIo8eS00mPxmu6YiLwqB8tfeGdP8NNVsnrAAJT6XJuj4qwo BWP4MmeOs2/vgF+2sRH4i+qkvFvbff1E/L48HUiH7JrjaYrR4kdtQUQGO8QyOe4or8pt Uh4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=TOUNRNReCtd3IEWk+ZIqnOcsGVn7DZrx6K3+/XkgGE4=; fh=baZ/UXZhgDbXi0Nl0RWB9xqnrsZvlKLMUECo8CjhFEg=; b=cJ4XHGLFuaPFYbIf7+Z4zM8SiDNM80IGYFXxcKsHdvNBWPRTsCqyUVfGC7H3Gltglb dCW6Ea6v2t2HKEbZk/NQZiDvBaVu50HnISHcLvEO9SZqzFRywbWPCJ8NZWR3b8G9eE7T p1w43ep4C8YjQ0JHK95v2ogxiIGRrzl+NQVRI1oj5cYPjil+FQ6bZbbaO9veLP+wfKXv f6jKSLxKArPTQtXFmVw5dVa2tYRRr1aEmDTLPima5wsnqt6SyBjGkZIre3wvYNCttTkC OQHcfHNDduE4e0mi2aQM/Se1izEQRvuEGXmai07QglyGRJrSaeSePWek9JKAeGKWBKrK hFhQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772920015; x=1773524815; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TOUNRNReCtd3IEWk+ZIqnOcsGVn7DZrx6K3+/XkgGE4=; b=BhMOEC/ikturCRuY+SY2pR9reiuR6TCRUtUfsqot4/EaFePyAbeKIeuC6fKrx4PQYF mirt+bKksVrcxedGENznMNa/0/jpNtctvZSZE2R8v6OwIEFVc1aj/KNx8BytyZ1imdm3 o8idN34RI9jpNnCiA+3z7JuxqLPMQGbSadG77sGv33IjUPuda8pvP5Jicy2Anc5EboVC RcQ8mZVp9rFOriy64MGsCxv24RyeAjYBcX1x3EO15m9yDHMQu5b77bFtDAK2G5kOh7Wd bylWMR/E/HOii24pggTwnu6vTvi3OWduzS0Rg7K1tAbcM3dJsaIVG4hiG79hc+Pjttf/ KH2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772920015; x=1773524815; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TOUNRNReCtd3IEWk+ZIqnOcsGVn7DZrx6K3+/XkgGE4=; b=LW7ogavkv4hGFuTEr/kYxoeZbricHr6vmkDtYQx7O8hQebDdSMluoCaw9Z1gJAQSPg siaR69R0ZNrf/n5nCRKD2xtUAPs2R0SrMDOxsOz9aetHWKU/g6ImKd2zTAz2hzhpMGD+ 46CmheP7ZI4yUIHUYxEtfrClAJvJgnMN8t3B/+6zJsE5tAyKfglhjNtvlYQ02tYAzmZW t5L09ZRAvthrVFmkggISlivUzyoZvB5wj/iu8DqVcT4f8Tf6LCMzVy70EuZhzAbBZ6D5 no+2SMo+b+oXs6JQdLWi+EpfR+0Jd2Jizmrr5O2znrtQxq3m+gH1PhbsdFTTQxb7jLXf sW6w== X-Forwarded-Encrypted: i=1; AJvYcCWW7+H1OdB3ILtd/vFZI0q1rX39zE5FxScTMxoGrVN+s7tLM/cqnB12/ae8rmELEYI2QsuwAV/qwH7SKVeB@lists.postgresql.org X-Gm-Message-State: AOJu0YxZeuVn6bvIQlL4jaBoF3Tkfj68hJUdmM++AjESEN7R9aJ6JL4s +qRqC4nwqDYm0Bc44wQCviqZ1g0EKfPDPOllcmQwUEteFKqlz98e37zPf/XqdoJIPInac0FKuiT e3qMOdH254NvGDVHHhPI+0TuWNZw7fec= X-Gm-Gg: ATEYQzyekWxTtSTbKTLD1EM9qBm6HHSCcwtMHn37zYvCNiE765OxaG77DNeASlZcuxh 08mxFQCLaHHcJdr9uPdHOu9qaDnf3xd5T5dH/+auQzunSaAbIOeDQ7mMewhyCaLrBAAvRtU19N5 zhME3l3qlsKJh+ymK4VvFXQS2MzGVbwMllnH3kR5e0khZgWildFwTyiAbIZkFz1S+b2AfnIwu8O NWd128oh0uWl2FaPRtykSoQMPmcQQge/1+lUvdTh+AjQD2f/AnCKBH8mrmm8L+wfJaDtNM6svjt DdM= X-Received: by 2002:a05:690c:4486:b0:798:4f55:2c5e with SMTP id 00721157ae682-798dd73a3cbmr63447017b3.30.1772920014728; Sat, 07 Mar 2026 13:46:54 -0800 (PST) MIME-Version: 1.0 References: <8f73ec0b-8f68-4f87-badc-a86939a211e1@aklaver.com> In-Reply-To: <8f73ec0b-8f68-4f87-badc-a86939a211e1@aklaver.com> From: Igor Korot Date: Sat, 7 Mar 2026 15:46:42 -0600 X-Gm-Features: AaiRm53GBszUPaUArGCUVuJTciGqbScK87ftw0FDve2eJOhZoFMgMDTbBy02EMc Message-ID: Subject: Re: How to properly use TRIM()? To: Adrian Klaver Cc: "David G. Johnston" , Rob Sargent , "pgsql-generallists.postgresql.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Adrian, On Sat, Mar 7, 2026 at 3:29=E2=80=AFPM Adrian Klaver wrote: > > On 3/7/26 12:46 PM, Igor Korot wrote: > > Hi, David, > > > > On Sat, Mar 7, 2026 at 12:03=E2=80=AFPM David G. Johnston > > > wrote: > > > > On Sat, Mar 7, 2026 at 12:58=E2=80=AFPM Igor Korot > > wrote: > > > > So I started looking for a way to return SQL_NO_DATA > > on that 4th column... > > > > > > Doesn't "No Data" refer to the result set as a whole, not individua= l > > columns? I'd assume NULL is detected some other way. > > > > > > No, I think it=E2=80=99s column based. > > 1) My knowledge of ODBC is limited. > > 2) This: > > https://learn.microsoft.com/en-us/sql/odbc/reference/develop-app/return-c= odes-odbc?view=3Dsql-server-ver17 > > "SQL_NO_DATA No more data was available. The application calls > SQLGetDiagRec or SQLGetDiagField to retrieve additional information. One > or more driver-defined status records in class 02xxx may be returned. > Note: In ODBC 2.x, this return code was named SQL_NO_DATA_FOUND." > > would seem to indicate that David Johnston is correct: From the SQLGetData() ODBC documentation (https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlgetdata-fun= ction?view=3Dsql-server-ver17): [quote] When it returns the last part of the data, SQLGetData returns SQL_SUCCESS. Neither SQL_NO_TOTAL nor zero can be returned on the last valid call to retrieve data from a column, because the application would then have no way of knowing how much of the data in the application buffer is valid. If SQLGetData is called after this, it returns SQL_NO_DATA. For more information, see the next section, "Retrieving Data with SQLGetData." [/quote] However it looks like the driver does not behave as expected. It keeps returning SQL_SUCCESS continuously... Or am I misinterpreting the docs? Thank you. > > 'Doesn't "No Data" refer to the result set as a whole, not individual > columns? I'd assume NULL is detected some other way.' > > > The call to SQLGetData() returns data in one column. > > > > And as stated it successfully retrieves empty array for column 3 and > > moves on. > > > > Thank you. > > > > > > David J. > > > > > -- > Adrian Klaver > adrian.klaver@aklaver.com