X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 98094D1B8B6 for ; Sat, 16 Aug 2003 09:49:51 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 59388-02 for ; Sat, 16 Aug 2003 06:49:43 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id 10FA2D1B8BF for ; Sat, 16 Aug 2003 06:49:41 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h7G9neek080192 for ; Sat, 16 Aug 2003 09:49:40 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h7G9cHgq079019 for pgsql-sql@postgresql.org; Sat, 16 Aug 2003 09:38:17 GMT From: "Hal Davison" X-Newsgroups: comp.databases.postgresql.sql Subject: Do it exist? Date: Sat, 16 Aug 2003 05:38:09 -0400 Lines: 28 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: <3f3ca9e7_1@newsfeed> X-Original-NNTP-Posting-Host: 66.209.32.56 To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/202 X-Sequence-Number: 14818 PostgreSQL Version 7.3.0 I hope I am not Cross Posting..with psql-novice..If so..sorry.. We have a situation where in our application the user provides the Order Number for a delivery document. When the Order Number is entered we need to determine if the Order Number already exists and raise a flag if it does exist. In another language I would do: find first Order where Order.Order_num = "1111". if avaialble Order then it_exists = true. In PostgreSQL ?: SELECT DISTINCT Order_num from Order_header where Order_num = '1111'; Is this close? If so, how to raise flage that row exists? How we do somthing like this in SQL? -- Hal Davison Davison Consulting