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.92) (envelope-from ) id 1jH51V-0002k0-GI for pgsql-general@arkaria.postgresql.org; Wed, 25 Mar 2020 12:20:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jH51U-0005IG-9a for pgsql-general@arkaria.postgresql.org; Wed, 25 Mar 2020 12:20:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jH51T-0005I8-ML for pgsql-general@lists.postgresql.org; Wed, 25 Mar 2020 12:20:40 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jH51L-0006w1-UA for pgsql-general@postgresql.org; Wed, 25 Mar 2020 12:20:38 +0000 Received: by mail-ed1-x529.google.com with SMTP id i16so1086469edy.11 for ; Wed, 25 Mar 2020 05:20:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zunibal-com.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=0po/oUu9yX/3UQWGZmMyIE7OT8/Db0zfHhG9v+30t7M=; b=RwEfoAeKfQEsHjZWw+Qfnv++Qd/rjGO3ei2oscqnKG68x2r1QYvYmGn6FLKVtI/sqV Q0bWW59/mC2RXcL1KTPiOKnRpYAHqWX1DrrKPBAf9TPV16FBQqrFhDCUsFPXh13phq4s aJawNElhgbMrGmX7D/RAQE1ue9BZb01ebKXq09wa3ZXMABEbz7zMhVjrB9chRK2OG6Gb GQfcHMoygn0w8/JvW93DoD5Xzif59h7nbtxZWmBall7t+3qlGZL2YA1GlZ0sNnT2tWN2 9f41sj3LMxcH6S4W/ym1xPsGhspElKzkpBw4IUSFytD2FLlm7Ie0M/vLMo9mkcWpVaQL 1CHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=0po/oUu9yX/3UQWGZmMyIE7OT8/Db0zfHhG9v+30t7M=; b=aIAA72BpXiQwuFDpci44A5v5K58s6f5kHOuhOic5kRHq2Xg0ulyvg7opbWwOZt8Sog U83gDAVBspvrZsXW2NOcVxWHCeqK1OiRp6FwOb6i+UTXHUKdkGRg9xB7j7edTkZ2fom1 53vs1qehqAJQ94IZtrbWhe9QKy5QLlcIWIWcBtJvHQwXfdaylBp+pZt5NwuJcX7rdbwm sTus94PybfAWhRw/a0fRLqIP7qwirhUENTKA9FWEP3nPmIVMWYKHiMiVpoL4OV5gz1av LhHsP9QRjZL50kQTQIKgCTfnv+3SIwP2cbZ7xvS33sjgN41GeM5B4GENkawePlWK3D3I 9Deg== X-Gm-Message-State: ANhLgQ1YJOiCyJoxtnlQFuXXf9OeSRODsQ3FYjQIEFrRBldyLXl4FdnE Jla7AF8xYg5owuv8hG4aEieyzrt3OwE= X-Google-Smtp-Source: ADFU+vu//4kqqqrR7cxKDog4TlFCn0Pc2QCM253FejuTIao3+9JKu+1Gk2qNE8u/eBSFm2NA6InvgQ== X-Received: by 2002:a05:6402:b7b:: with SMTP id cb27mr2538086edb.343.1585138825537; Wed, 25 Mar 2020 05:20:25 -0700 (PDT) Received: from [192.168.1.60] (169.red-81-35-166.dynamicip.rima-tde.net. [81.35.166.169]) by smtp.gmail.com with ESMTPSA id p17sm341246edq.57.2020.03.25.05.20.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Mar 2020 05:20:25 -0700 (PDT) To: pgsql-general From: Ekaterina Amez Subject: How to plpgsql scripting Message-ID: Date: Wed, 25 Mar 2020 13:20:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------381EF79833032DEC555D3F69" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------381EF79833032DEC555D3F69 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi List, I'm used to make my own scripts in Oracle plsql, Sql Server tsql... but I'm unable to make one simple script in Postgres. Objective version is 8.4 (I know, I know... it's a legacy server, I'm planning upgrade this server as soon as I can). I have a test server with 9.2 version where I've succesfully run this code from psql: DO $$ DECLARE    a integer := 10;    b integer := 20;    c integer; BEGIN    c := a + b;     RAISE NOTICE'Value of c: %', c; END $$; But this syntax is (anonymous code block?) is available since 9.0 so I'm trying to adapt this to v8.4 A per documentation [https://www.postgresql.org/docs/8.4/plpgsql-structure.html], the structure of a code block is defined as: [<