Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kn3HX-0008TE-4F for pgsql-general@arkaria.postgresql.org; Wed, 09 Dec 2020 17:29:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kn3HW-0000DY-1u for pgsql-general@arkaria.postgresql.org; Wed, 09 Dec 2020 17:29:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kn3HV-0000DR-Na for pgsql-general@lists.postgresql.org; Wed, 09 Dec 2020 17:29:37 +0000 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kn3HP-00043K-GD for pgsql-general@lists.postgresql.org; Wed, 09 Dec 2020 17:29:36 +0000 Received: by mail-oo1-xc30.google.com with SMTP id t23so570776oov.4 for ; Wed, 09 Dec 2020 09:29:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=UwDL0TxIBuL7yVNHpF3Vx4qlB3I/B0IUaGCtZkX8Ytw=; b=Oe//vFPUuKOQrVj3W+MkKzQyg1R6kGqDuC8gt/UTLcP2/KjVrQNuvcI4mkY7rmTKn8 oYy9KdUNT4/gfGvU9KgJnBTgtghrF20jZSLJNAgwDE9SjR0NWgFg9ZMUZqlmaryeKs/U mdv4/oy8FIGkWpiGbPKvHL1ZnJz0STcxuyOMOpc59qpFIGrPYIo5IW20Y3kyyXz+hnMO hl/Yla8bjR4/6JgtDqircSTaqAi9bSBCTmZrigMGIa2xYkX7Qo80G/1eSkVSWrN6B86R Lbu/3CWnC9J7AaRLJkxjsKUaUGV3KTlyPb7UW22517bASUBTOPsaVduMezPJf5hPRYuH lbCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=UwDL0TxIBuL7yVNHpF3Vx4qlB3I/B0IUaGCtZkX8Ytw=; b=JYYr4inzFdqYT1F+qm7bsY1zgzalU/G3RIDeLl66SchufBvWT+HzIj2o9l4DTjY2FJ 9xTT2PuxJ0x+V8YMuZHaGK4Kaj018X6TQpd/O6rpmnbEm2Dg4DajLwuxqZ3X6xlTn+ex P78Gn/bkkoUYaAcPudjQ3i+KpCDUV8mxHFcxejiLA981eu6B0Aq0RkB1WmlGKKIAsZhx SXefwrZlKsM/c9JHl4qidas7hcnd4w0+XvI3lvlFxAOW0PWeK3zcTvcBN7kSqA6+KoSp HqgyxpqbN3b4SBMF+VgzWWVGhWvvCnOlez3yHHtYzhHhfNBJa0VcvJ6qGLVYvkZY8j8I Tuxw== X-Gm-Message-State: AOAM531OEVo+71vguv29uXUNXG6Q0SSmhwdGo8l3kNURsEFNGXcVnLxv qERSsHYV7AdlfUx7rAT80xG2tOqzo4o= X-Google-Smtp-Source: ABdhPJzs/gl2fMN9J9qsBr88kSvbtUoaHXYSfatEYFEKEQHAmGsT7YRASARScK/73qU75ovAQLwfGw== X-Received: by 2002:a4a:a3cb:: with SMTP id t11mr2771012ool.30.1607534970476; Wed, 09 Dec 2020 09:29:30 -0800 (PST) Received: from ?IPv6:2601:681:5500:dde0:e871:4117:9783:1535? ([2601:681:5500:dde0:e871:4117:9783:1535]) by smtp.gmail.com with ESMTPSA id e12sm506722otp.25.2020.12.09.09.29.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Dec 2020 09:29:30 -0800 (PST) Subject: Re: User input to queries To: pgsql-general@lists.postgresql.org References: From: Rob Sargent Message-ID: <8e5a9074-eca1-c926-2af0-22f3a5f7a3a9@gmail.com> Date: Wed, 9 Dec 2020 10:29:24 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------B225B205AC09BA5DA5E2397D" Content-Language: en-CA List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------B225B205AC09BA5DA5E2397D Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 12/9/20 10:03 AM, Rich Shepard wrote: > While I develop the application's GUI I use the database from the command > line (psql). While some queries are self-contained others need user > input. > I've not found a search term that locates this information in the > postgres-12 user manual and my web searches suggest that using '&' should > work. > > I tried the latter with this query but postgres didn't like it. (There > may > well be other errors in it so don't hesitate to point out my mistakes.) > > ------ > /* This query selects all activity information for a named person */ > > /* Specify columns */ > SELECT p.lname, p.fname, p.loc_nbr, p.job_title, p.direct_phone, > p.active, >        o.org_name, >        l.loc_nbr, l.loc_name, >        a.act_date, a.act_type, a.notes, a.next_contact > /* Specify tables. */ FROM People AS p >      JOIN Organizations AS o ON o.org_nbr = p.org_nbr >      JOIN Locations AS l ON l.org_nbr = o.org_nbr and l.loc_nbr = > p.loc_nbr >      JOIN Activities AS a ON a.person_nbr = p.person_nbr > /* Specify rows */ WHERE p.lname = &p.lname AND p.fname = &p.fname; > ----- > > Suggestions on what I should read to learn more about this subject are > appreciated. > > Regards, > > Rich > > Put the query in a file, set the desired name, then from psql \i filename Edit pfname, repeat --------------B225B205AC09BA5DA5E2397D Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit


On 12/9/20 10:03 AM, Rich Shepard wrote:
While I develop the application's GUI I use the database from the command
line (psql). While some queries are self-contained others need user input.
I've not found a search term that locates this information in the
postgres-12 user manual and my web searches suggest that using '&' should
work.

I tried the latter with this query but postgres didn't like it. (There may
well be other errors in it so don't hesitate to point out my mistakes.)

------
/* This query selects all activity information for a named person */

/* Specify columns */
SELECT p.lname, p.fname, p.loc_nbr, p.job_title, p.direct_phone, p.active,
       o.org_name,
       l.loc_nbr, l.loc_name,
       a.act_date, a.act_type, a.notes, a.next_contact
/* Specify tables. */ FROM People AS p
     JOIN Organizations AS o ON o.org_nbr = p.org_nbr
     JOIN Locations AS l ON l.org_nbr = o.org_nbr and l.loc_nbr = p.loc_nbr
     JOIN Activities AS a ON a.person_nbr = p.person_nbr
/* Specify rows */ WHERE p.lname = &p.lname AND p.fname = &p.fname;
-----

Suggestions on what I should read to learn more about this subject are
appreciated.

Regards,

Rich



Put the query in a file, set the desired name, then from psql

\i filename

Edit pfname, repeat



--------------B225B205AC09BA5DA5E2397D--