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 1h4r3a-0000cG-P7 for pgsql-general@arkaria.postgresql.org; Fri, 15 Mar 2019 17:55:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h4r3Y-0007nZ-DP for pgsql-general@arkaria.postgresql.org; Fri, 15 Mar 2019 17:55:44 +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 1h4r3X-0007gY-Tv for pgsql-general@lists.postgresql.org; Fri, 15 Mar 2019 17:55:44 +0000 Received: from fiedler.schlittermann.de ([212.80.235.136] helo=ikarus.unix-solution.de) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4r3U-0004ks-7M for pgsql-general@postgresql.org; Fri, 15 Mar 2019 17:55:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=unix-solution.de; s=mx; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Date:Message-ID:Subject:From:To:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=bRoQVdcJHN2ASZjzv1o0sbE9PQR3WLq+TRKJElaDAKE=; b=SLOH617WkRSpZwfzfRj6EZpS1W +5OOTOWHaPvhS0QZZk2A9blMqB//V2r4KKGAy3EjP8gh1DZODot0UbPnWu9s21LmK0EXen2fLShMM WymHXsSpkJRMEBfOCzwyGVUGYuYEidfVtZF8DmxOJPLPv/k5w870oiRZyRn4qevFNm1U=; Received: from x4e367480.dyn.telefonica.de ([78.54.116.128] helo=[192.168.30.100]) by ikarus.unix-solution.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1h4r3P-0006YR-JN for pgsql-general@postgresql.org; Fri, 15 Mar 2019 18:55:35 +0100 To: Postgres General From: basti Subject: Conditional INSERT Message-ID: <68951fae-3281-c9ad-09b7-205e0bb1c5ae@unix-solution.de> Date: Fri, 15 Mar 2019 18:55:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, I want to insert data into table only if condition is true. For example: INSERT into mytable (domainid, hostname, txtdata) VALUES (100,'_acme.challenge.example', 'somedata'); The insert should only be done if Hostname like %_acme.challenge%. How can it be done? I dont want that the user/script can insert any value. Best regards.