Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, Edson Carlos Ericksson Richter wrote: Are you sure it should be 127.0.1.1, not 127.0.0.1? AFAIK, localhost should be 127.0.0.1 May be an issue in /etc/hosts for "salmo" host? Edson, salmo, 127.0.0.1 is the server/workstation that has everything installed. It is localhost.

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, Tom Lane wrote: We removed the pg_attrdef.adsrc catalog column a couple versions back. You're evidently using quite an old version of whichever client-side library is issuing this command. You need to get a more up-to-date copy that knows what to do instead. Tom, I appear

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, David G. Johnston wrote: Those are PostgreSQL versions...but it's your non-psql client software that needs upgrading, not PostgreSQL. David, Ah! Now I understand. Given that the messages above indicate you are presently running 12.2 you should be upgrading to the current

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, Adrian Klaver wrote: No this is because you did not use an actual connection string e.g: psycopg2.connect("host=salmo user=rshepard dbname=bustrac") Instead you used an undefined variable bustrac per the error message: NameError: name 'bustrac' is not defined Adrian, First

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, Adrian Klaver wrote: The code snippet I showed is not tied to PyQt5, it is using psycopg2 and was just a way of seeing if you could connect to the database via Python and get results. Adrian, Yes, it's a PyQt5 version issue. Thanks, Rich

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, Tom Lane wrote: We removed the pg_attrdef.adsrc catalog column a couple versions back. You're evidently using quite an old version of whichever client-side library is issuing this command. You need to get a more up-to-date copy that knows what to do instead. Tom, In what v

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, Adrian Klaver wrote: See: https://www.postgresql.org/docs/11/catalog-pg-attrdef.html https://www.postgresql.org/docs/12/catalog-pg-attrdef.html So in version 12. Adrian, Then it doesn't matter which minor version's installed. I've asked on the PyQt mail list about this b

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, David G. Johnston wrote: If all you did was upgrade the server, and not the client that is issuing the query, then, yes, you will get the same error, since the server isn't the problem. David, I also upgraded the client from PyQt5-5.13.2 to PyQt5-5.15.2. I'm hoping for an

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, Adrian Klaver wrote: How did you upgrade? Exact command please. Adrian, Because slackware64-14.2 had python3-PyQt-5.13.2 and the latest version in -current64 is PyQt5-5.15.2-x86_64-3, I removed the former and installed the latter. The commands are 'removepkg ' and 'instal

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, Adrian Klaver wrote: Alright. What is the version of Qt installed on the machine. Do in terminal: $ ls /var/log/packages/ | grep qt qt5-5.12.8-x86_64-1_SBo among others. Rich

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, Adrian Klaver wrote: That will show what is currently installed, not what has been installed over time. The bottom line is that this is Qt issue and to solve it is going to require working from the Qt side and that is only going to work by knowing what version of Qt(not PyQt

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, Adrian Klaver wrote: I'm guessing qt5-5.12.8 is not recent enough to deal with the changes in Postgres 11+. Adrian, I agree. I've overlooked that PyQt is a wrapper around Qt and that's where the drivers are installed. Does your version of Slackware allow you to upgrade t

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, David G. Johnston wrote: The version 12 compatibility commit was done in 5.15 only (5.12 works up to v11). David, Thanks for that information. I'll see if I can upgrade to 5.15. Regards, Rich

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, Sam Gendler wrote: It still looks a lot like the salmo hostname is going to be a problem once you have the client version sorted out. Postgresql is listening only on 127.0.0.1:5432 and pg_hba.conf only has entries for 127.0.0.1:5432, not 127.0.1.1 You can tell it to listen on

Re: Database issues when adding GUI

2021-06-07 Thread Rich Shepard
On Mon, 7 Jun 2021, Rich Shepard wrote: The only use of 127.0.1.1 is for slrn, a newsreader I've not used in years. Ah, I was looking in the wrong directory. /usr/share/postgresql-12/ should have only the templates. The conf file postgres uses is in /var/lib/pgsql/12/data/ and has

Re: Database issues when adding GUI

2021-06-08 Thread Rich Shepard
On Mon, 7 Jun 2021, Adrian Klaver wrote: 2021-06-07 10:36:38.330 PDT [29537] LOG: database system is ready to accept connections 2021-06-07 14:19:45.491 PDT [31353] ERROR: column pg_attrdef.adsrc does not exist at character 128 " Adrian, Postgres dropped the pg_attrdev.adsrc column from t

Re: Aw: Re: Database issues when adding GUI

2021-06-08 Thread Rich Shepard
On Tue, 8 Jun 2021, Karsten Hilbert wrote: The problem source is postgres telling me it cannot connect to the database via TCP/IP but I can do so directly using psql: via UNIX domain sockets. Karsten, That's because psql is direct while PyQt5-5.12.3 cannot access postgres-12.x tables. I'm wor

Use of '&' as table prefix in query

2021-07-12 Thread Rich Shepard
Long ago I wrote a query which was greatly improved (i.e., it actually worked as intended) by help here): /* This query selects all activity information for a named person */ SELECT p.lname, p.fname, p.loc_nbr, p.job_title, p.direct_phone, p.active, o.org_name, l.loc_nbr, l.loc_nam

Re: Use of '&' as table prefix in query

2021-07-12 Thread Rich Shepard
On Mon, 12 Jul 2021, Tom Lane wrote: AFAICS this is invoking a prefix operator named "&". There is no such operator built into Postgres. Maybe psql's "\do+ &" would jog your memory about where yours came from. tom, I thought it wasn't part of postgres. I've no idea why it's there, but I'll re

Re: Use of '&' as table prefix in query

2021-07-12 Thread Rich Shepard
On Mon, 12 Jul 2021, Rob Sargent wrote: These look like value substitutions, usually done on the client at it sends the sql. How is this sql getting to the server (presumably after substitution). Rob, I was running queries from the psql back then. Now I'm adding a GUI (tkinter) and using psyc

Re: Use of '&' as table prefix in query

2021-07-12 Thread Rich Shepard
On Mon, 12 Jul 2021, Adrian Klaver wrote: You should also follow Tom's suggestion and do: \do+ & in psql. It's the bitwise 'and': # \do+ & List of operators Schema | Name | Left arg type | Right arg type | Result type | Function | Description -

Re: Use of '&' as table prefix in query

2021-07-12 Thread Rich Shepard
On Mon, 12 Jul 2021, Rob Sargent wrote: Having a hard time seeing the value in p.lname = p.lname and straight sql. Me, too. That's why I wanted an explanation. Seems to me I added it sometime for no valid reason. As I've not run that query in a very long time I'll clean up the query and test i

Re: Use of '&' as table prefix in query [RESOLVED]

2021-07-12 Thread Rich Shepard
On Mon, 12 Jul 2021, Rich Shepard wrote: Long ago I wrote a query which was greatly improved (i.e., it actually worked as intended) by help here): Ah! It finally came back to me as I looked to revise it. What I want both &p.lname and &p.fname are specific names passed in from the use

psycopg2 mail list subscription issues

2021-07-13 Thread Rich Shepard
I apologize for writing to the list, but my attempts to subscribe to the psycopg2 mail list fail and I've not seen a response to my email message sent to the mail list owner. I don't know my postgres mail list password as I've not had a reason to use it ... until now. Subscribing to the psycopg2

Re: psycopg2 mail list subscription issues

2021-07-13 Thread Rich Shepard
On Tue, 13 Jul 2021, Diego wrote: Here is the link to reset your password and manage your account: https://www.postgresql.org/account/reset/ Diego, I tried the list management link and that didn't work. The URL you sent has the same results as the password reset link on the community account

Re: psycopg2 mail list subscription issues

2021-07-13 Thread Rich Shepard
On Tue, 13 Jul 2021, Tom Lane wrote: Is it possible that you're sending the list request mail out of some other IP address? tom, No. I have a personal domain but use my business domain for all business-related mail lists. Thanks, Rich

Formating psql query output

2021-07-19 Thread Rich Shepard
Until I finish building the python/tkinter/psycopg2 front end to my business tracking tool I continue to work using the psql shell.' I have a working .sql script that reports my contacts between two dates; the script returns more columns than I want included in the report. I want to pipe the outp

RE: Formating psql query output

2021-07-19 Thread Rich Shepard
On Mon, 19 Jul 2021, Basques, Bob (CI-StPaul) wrote: -F separator --field-separator=separator Use separator as the field separator for unaligned output. This is equivalent to \pset fieldsep or \f. Bobb, I should have mentioned that I tried that. Without the --csv option the results have the

Re: Formating psql query output [RESOLVED]

2021-07-19 Thread Rich Shepard
On Mon, 19 Jul 2021, David Santamauro wrote: echo 'select 1,2,3,4;' | psql -At -F'|' 1|2|3|4 -A Switches to unaligned output mode. (The default output mode is aligned.) This is equivalent to \pset format unaligned. -t Turn off printing of column names and result row count footers, etc. This is

Re: Formating psql query output

2021-07-19 Thread Rich Shepard
On Mon, 19 Jul 2021, Adrian Klaver wrote: Is there a reason you can't just restrict the query to the columns you want? Adrian, As far as I know I need to specify FK and PK columns when tables are joined; I don't need those key columns in the output. Thanks, Rich

Re: Formating psql query output

2021-07-19 Thread Rich Shepard
On Mon, 19 Jul 2021, Rob Sargent wrote: Can we see on line of the csv output? The field with commas should be in quotes, no? You’ll have write a “real” csv importer. awk =F”\”*,*\”” might, heavy on the might. Rob, Here's a redacted output line: 8,2019-04-08,Phone,Went to voice mail @ 14:48;

Re: Formating psql query output

2021-07-19 Thread Rich Shepard
On Mon, 19 Jul 2021, Rob Sargent wrote: Postgres version? postgresql-12.7-x86_64-1_SBo

Re: Formating psql query output

2021-07-19 Thread Rich Shepard
On Mon, 19 Jul 2021, Adrian Klaver wrote: You need them in the JOIN and/or WHERE sections, but not necessarily in the field list in the SELECT portion. Adrian, I wondered about that and thought I needed to include them in the SELECT phrase. Thanks for the lesson. Regards, Rich

Selecting table row with latest date

2021-08-19 Thread Rich Shepard
I have a table of contacts (PK is the person_nbr and contact_date) and I want to select only the row with the latest (most recent) contact_date. The Comparison Date/Time sections in the postgres 12 doc doesn't appear to have what I want, and when I try to use the max() aggregate function it throws

Re: Selecting table row with latest date

2021-08-19 Thread Rich Shepard
On Thu, 19 Aug 2021, Rich Shepard wrote: Please point me to the proper place in the docs where I can learn how to do this. If I use DISTINCT ON would this produce the most recent date for each person_nbr? Rich

Re: Selecting table row with latest date

2021-08-19 Thread Rich Shepard
On Thu, 19 Aug 2021, David G. Johnston wrote: Select distinct on (person_nbr) ….. order by person_nbr, contact_date desc; David, Please clarify: would this produce the most recent contact_date for each person_nbr? The manual reads that two rows (e.g., for the same person_nbr) are considered d

Re: Selecting table row with latest date

2021-08-19 Thread Rich Shepard
On Thu, 19 Aug 2021, Tom Lane wrote: The best way is usually like select * from mytable order by contact_date desc limit 1; If you have an index on contact_date this should work very well indeed. Tom, I don't have an index on that table. I'll add one and try you suggestion. Thanks, Ric

Re: Selecting table row with latest date

2021-08-19 Thread Rich Shepard
On Thu, 19 Aug 2021, Tom Lane wrote: The best way is usually like select * from mytable order by contact_date desc limit 1; If you have an index on contact_date this should work very well indeed. tom, I added an index on contact_date and the query returned only one row. Huh! Not what I exp

Re: Selecting table row with latest date

2021-08-19 Thread Rich Shepard
On Thu, 19 Aug 2021, Adrian Klaver wrote: Alright now I am confused. You keep referring to contact_date, yet the query is referring to next_contact. Are they the same thing, different things or other? Adrian, The table has 5 columns: person_nbr, contact_date, contact_type, notes, and next_con

Re: Selecting table row with latest date

2021-08-19 Thread Rich Shepard
On Thu, 19 Aug 2021, Rob Sargent wrote: Did you try David J’s suggestion? or maybe Rob, Yes. select person_nbr, max(next_contact) group by person_nbr where next_contact < now(); A table with person_nbr (pk), next_contact would make this much easier. Seems to me a person can only have one

Re: Selecting table row with latest date

2021-08-19 Thread Rich Shepard
On Thu, 19 Aug 2021, Rob Sargent wrote: Yeah, but my quibble is the the table you described up-thread. Your contact table contains next_contact? I think that column should be normalized out. Rob, Why should I have a separate table with one column: next_contact? The next_contact date is associ

Re: Selecting table row with latest date

2021-08-19 Thread Rich Shepard
On Thu, 19 Aug 2021, Adrian Klaver wrote: So take David Johnston's query: Select distinct on (person_nbr) ….. order by person_nbr, contact_date desc; Adrian, contact_date -- 2021-08-17 2019-05-14 2019-05-15 2021-08-17 2018-04-05 2021-08-17 2018-04-05 2021-07-23 2019-04-

Re: Selecting table row with latest date

2021-08-19 Thread Rich Shepard
On Thu, 19 Aug 2021, Rob Sargent wrote: sorry, wasn’t clear: person_nbr, next_contact On the premise that there can only be one next date. Rob, I wasn't sufficiently clear. The contacts table has a row for each (person_nbr, contact_date). For each row there's also either a next_contact date o

Re: Selecting table row with latest date [RESOLVED]

2021-08-19 Thread Rich Shepard
On Thu, 19 Aug 2021, David G. Johnston wrote: Yeah, you wrote two from clauses… David, Mea culpa! I did. Got that fixed. Now, this query: --- Select distinct on (p.person_nbr) p.person_nbr, c.contact_date, max(c.next_contact) as next_contac from contacts, people as p, contacts as c where

Re: Selecting table row with latest date [RESOLVED]

2021-08-19 Thread Rich Shepard
On Thu, 19 Aug 2021, David G. Johnston wrote: I thought you said (p.person_nbr, c.contact_date) is already unique? David, Yes, that's the PK for the contacts table. I'm still unsure what needs to be explicitly included in a query. Quite often I leave out a column and postgres tells me it need

Re: Selecting table row with latest date [RESOLVED]

2021-08-19 Thread Rich Shepard
On Thu, 19 Aug 2021, David G. Johnston wrote: Well, in this case I suspect you had made a different mistake which caused the error message (probably the max(c.next_contact)) but instead of solving the original problem (removing the max(...)) you decided that two wrongs (adding or extending a gro

Re: Selecting table row with latest date

2021-08-20 Thread Rich Shepard
On Fri, 20 Aug 2021, Francisco Olarte wrote: Is your next_contact really dependent on the contact record ( person+contact_date? ). Francisco, Yes. I mean, your tables seem CRM like. You stated next_contact for old contacts is not interesting. It seems next_contact is associated just by a pe

Re: The tragedy of SQL

2021-09-14 Thread Rich Shepard
On Mon, 13 Sep 2021, Guyren Howe wrote: They are making a decent decision. SQL is a *fucking terrible* language, which I don’t blame them for not wanting to learn. SQL is not the problem. Problem are the devs. I love SQL. I hate orms. The problem with databases is people refuse to treat it as

Re: SQL queries as sets: was The tragedy of SQL

2021-09-15 Thread Rich Shepard
On Wed, 15 Sep 2021, Steve Litt wrote: Rich, could you please elaborate on SQL queries being based on sets? I never thought of it that way, and would like to hear your related thoughts. SteveT, In the 1980s, when there were computer magazines such as Byte and Database Administrator (among man

Need help understanding error message

2021-10-26 Thread Rich Shepard
In a database table I have these rows: # select * from contacts where person_nbr=6; person_nbr | contact_date | contact_type | not es | next_contact +--+---

Re: Need help understanding error message

2021-10-26 Thread Rich Shepard
On Tue, 26 Oct 2021, Rob Sargent wrote: What do you get when you select * where person_nbr = 6 and contact_date = ‘2021-10-26’ and contact_type = ‘Email’ from activities; ? Rob, person_nbr | contact_date | contact_type | notes | next_contact +--+--+--

Re: Need help understanding error message

2021-10-26 Thread Rich Shepard
On Tue, 26 Oct 2021, Ron wrote: Show us the actual UPDATE statement. Ron, insert into contacts (person_nbr,contact_date,contact_type,notes,next_contact) values (1,'2021-10-26','Email','message 3','2012-11-16'), (4,'2021-10-26','Email','message 3','2012-11-16'), (6,'2021-10-26','Email','messa

Re: Need help understanding error message

2021-10-26 Thread Rich Shepard
On Tue, 26 Oct 2021, Rob Sargent wrote: Are you doing a batch of updates, Yes, ... and including/generating a duplicate in there? No. Rich

Re: Need help understanding error message [RESOLVED]

2021-10-26 Thread Rich Shepard
On Tue, 26 Oct 2021, Rob Sargent wrote: Aren’t lines 3 and 6 duplicates? Ah, shoot! The second was supposed to be 16 and that's how I saw it when I scanned the list. Thanks! Rich

Re: Design database schemas around a common subset of objects

2021-11-07 Thread Rich Shepard
On Mon, 8 Nov 2021, Erik Wienhold wrote: One thing I already know that may differ is how modelled objects are named in the real world. We deal with plots of land, hence the geographic data. Depending on the region, these plots may use different naming schemes relevant to legal documents. The c

Re: Migration to PGLister - After

2017-11-20 Thread Rich Shepard
On Mon, 20 Nov 2017, Joshua D. Drake wrote: Yep, but that is why the list-id filter is bad advice (at least for me). I filter on the list email address and it works flawlessly. Joshua, This does not work if the procmail recipe is for pgsql-gene...@postgresql.org and the source includes the

Re: Migration to PGLister - After

2017-11-20 Thread Rich Shepard
On Mon, 20 Nov 2017, Stephen Frost wrote: Yes, for a while both of those addresses will work and therefore you'd need to handle both addresses (there's a few different ways you could do that; with a regexp, I'd suggest something more specific, eg: (lists.)? ). Stephen, Yes, I changed the po

Re: Procmail recipe for new setup

2017-11-20 Thread Rich Shepard
On Mon, 20 Nov 2017, Steve Litt wrote: The following procmail recipe works for me: === :0: * ^(To|Cc).*pgsql-gene...@postgresql.org .Postgres/ === Hi, Steve! Here's an alternative recipe: :0: * ^TO_.*pgsql-gen

Need to fix one more glitch in upgrade to -10.2

2018-02-17 Thread Rich Shepard
Hi folks, Today I upgraded from -9.6.6 to -10.2 on my Slackware-14.2 desktop. The user and group IDs changed from before, but I have that all fixed now. Starting postgres (as user postgres) succeeded, but the role for me (as a use and owner of most databases) seems to have become lost during th

Re: Need to fix one more glitch in upgrade to -10.2

2018-02-17 Thread Rich Shepard
On Sat, 17 Feb 2018, Adrian Klaver wrote: How did you upgrade, dump/restore or pg_upgrade? Adrian, Ran 'pg_dumpall -c -f .sql' prior to doing anything. Then built, installed the new version, upgraded rc.postgresql (only differences were version numbers), and ran 'pg_upgrade ...' with the ap

Re: Need to fix one more glitch in upgrade to -10.2

2018-02-17 Thread Rich Shepard
On Sat, 17 Feb 2018, Adrian Klaver wrote: Did pg_upgrade spit out any warnings/errors? Adrian, Yes. The uid and gid were mis-matched and, because of that, the data/directory and all its files were owned by group user, not group postgres. In your previous post you showed: # /etc/rc.postgre

Re: Need to fix one more glitch in upgrade to -10.2

2018-02-17 Thread Rich Shepard
On Sat, 17 Feb 2018, Adrian Klaver wrote: From a previous post: POSTGRES=/usr/lib${LIBDIRSUFFIX}/@PRGNAM@/$PG_VERSION/bin/postgres From here: http://slackbuilds.org/slackbuilds/14.1/system/postgresql/postgresql.SlackBuild The desktop runs 32-bit 14.2. You could also try using pg_ctl to

Re: Need to fix one more glitch in upgrade to -10.2

2018-02-17 Thread Rich Shepard
On Sat, 17 Feb 2018, Adrian Klaver wrote: Got to thinking that given the issues with the upgrade I would be leery about the state of the new cluster as a whole. Might want to consider doing it over again or just use the pg_dumpall output to recreate the database(s). Adrian, That's what I wa

Re: Need to fix one more glitch in upgrade to -10.2

2018-02-18 Thread Rich Shepard
On Sun, 18 Feb 2018, Tim Cross wrote: This may not be relevant, Tim, Nope. Pat goes for stability, not cutting edge. No systemd in the forthcoming 15.0, either. Thanks, Rich

Re: Need to fix one more glitch in upgrade to -10.2

2018-02-18 Thread Rich Shepard
On Sun, 18 Feb 2018, Tim Cross wrote: # ll /usr/bin/postgres lrwxrwxrwx 1 root root 35 Feb 17 09:30 /usr/bin/postgres -> ../lib/postgresql/10.2/bin/postgres* Try doing an 'll' on the second part of that output i.e. ll /usr//lib/postgresql/10.2/bin/postgres* See my message, repeated above

Re: Need to fix one more glitch in upgrade to -10.2

2018-02-18 Thread Rich Shepard
On Sat, 17 Feb 2018, Rich Shepard wrote: That's what I was thinking, too. I can remove the 10.2 package, rebuild and re-install it. Run initdb, then, as postgres, read in the .sql file. This is probably the pragmatic thing to do. Rather than doing this my reading of the 10.2 initdb

Re: Need to fix one more glitch in upgrade to -10.2

2018-02-18 Thread Rich Shepard
On Sun, 18 Feb 2018, Adrian Klaver wrote: Is this appropriate? Yes. Adrian, Thanks for confirming They could not have been removed as they are in the file. I am guessing you are saying they are not in use as far as you know. Just a warning(from experience), memory is a tricky thing and

Re: Need to fix one more glitch in upgrade to -10.2 [FIXED]

2018-02-18 Thread Rich Shepard
On Sun, 18 Feb 2018, Rich Shepard wrote: Thanks for confirming Removed all files in the data/ directory, re-initialized the cluster, and restored the dumped .sql file (minus three databases and their roles manually deleted). All works well now. Thanks, Adrian! Best regards, Rich

Re: Need to fix one more glitch in upgrade to -10.2

2018-02-18 Thread Rich Shepard
On Mon, 19 Feb 2018, Tim Cross wrote: It is possible for the target of a symbolic link to be changed, deleted etc (a dangling sym link). Tim, Broken symlinks display in a different color, black on a red background if I remember correctly, rather than the light cyan of a working symlink. I'v

Re: initdb when data/ folder has mount points

2018-02-21 Thread Rich Shepard
On Wed, 21 Feb 2018, Ron Johnson wrote: Apparently, initdb assumes that data/ is one big mount point. However, we have four mount points: /var/lib/pgsql/9.6/data/backup /var/lib/pgsql/9.6/data/base /var/lib/pgsql/9.6/data/pg_log /var/lib/pgsql/9.6/data/pg_xlog Ron, What command do you use?

Re: CURRENTE_DATE

2024-10-23 Thread Rich Shepard
On Tue, 22 Oct 2024, Rossana Ocampos wrote: I am new with PostgreSQL and I have a bug. I have created a function that has an input variable of type date , in case it does not receive value , it has to assume by default the current date. ERROR: invalid input syntax for type date: "CURRENT_DATE

Re: CURRENTE_DATE

2024-10-23 Thread Rich Shepard
On Tue, 22 Oct 2024, Rossana Ocampos wrote: ERROR: invalid input syntax for type date: "CURRENT_DATE" LINE 1: ...extsupplydate ('1085018'::bigint, '5278'::bigint, 'CURRENT_D... ^ ERROR: invalid input syntax for type date: "CURRENT_DATE" SQL status: 22007 Characters: 78 Rossana, Also, I sugges

Using psql's \prompt command

2025-01-30 Thread Rich Shepard
I want to use the \prompt command to get user input for a query. My script fails: -- Display person_nbr, lname, fname, direct_phone, email from people, contact history from contacts. -- prompt for person_nbr before selecting rows: \prompt 'Enter person_nbr: ' store select p.person_nbr, p.lname

Re: Using psql's \prompt command [RESOLVED]

2025-01-30 Thread Rich Shepard
On Thu, 30 Jan 2025, Rich Shepard wrote: Thanks again, David. I didn't know that's the section I need. David/Ron, et al.: Got it (example on page 2126 of the doc): -- Display person_nbr, lname, fname, direct_phone, email from people, contact history from contacts. -- prompt for

Re: Lookup tables

2025-02-04 Thread Rich Shepard
On Tue, 4 Feb 2025, Rob Sargent wrote: I would definitely add an Id for each of the looked up values. The code can use the Id (for the join or lookup) and the string value can safely be changed (think typo) without ripple effect.  It also prevents other tables from referencing the lookup witrh b

Re: Lookup tables

2025-02-04 Thread Rich Shepard
On Tue, 4 Feb 2025, David G. Johnston wrote: Most do (have a surrogate PK) since it removes cascading updates and is a smaller value. Lots of alter tables and update queries. David, That's a good point. Thanks, Rich

Re: Lookup tables

2025-02-04 Thread Rich Shepard
On Tue, 4 Feb 2025, David G. Johnston wrote: The point of a lookup table is to provide a unique list of authoritative values for some purpose. Kinda like an enum. But having the label serve as the unique value is reasonable - we only add surrogates for optimization. David, The industrytypes t

Lookup tables

2025-02-04 Thread Rich Shepard
Should lookup tables have a numeric FK column as well as the description column? If so, how should I add an FK to the two lookup tables in my database? TIA, Rich

Re: Lookup tables

2025-02-04 Thread Rich Shepard
On Tue, 4 Feb 2025, Ron Johnson wrote: Does your lookup table just have one column? (That's what your question seems to imply, but that makes no sense, since the whole point of a lookup table is to store some sort of a code in the "child" table instead of the whole text of the description.) R

Re: Lookup tables

2025-02-04 Thread Rich Shepard
On Tue, 4 Feb 2025, David G. Johnston wrote: It’s the FK side where the cost savings are experienced. David, Okay. Thanks, Rich

Re: Lookup tables

2025-02-04 Thread Rich Shepard
On Tue, 4 Feb 2025, David G. Johnston wrote: Is the use of FK here intentional or a typo? Sigh, typo. Should be PK. Rich

Re: Lookup tables [FIXED]

2025-02-04 Thread Rich Shepard
On Tue, 4 Feb 2025, Rich Shepard wrote: I'll make new tables today. That did not work as well as I expected. Instead, I added a new column (type `serial') to each of the two lookup tables. That adds a PK to each while retaining the table and column names referenced by other table

Re: Lookup tables

2025-02-04 Thread Rich Shepard
On Tue, 4 Feb 2025, Rob Sargent wrote: Unless your lookup tables are huge I would create a new table matching your current table but with an identity column and load from you original table. I created a new table: create table ind_types_lu ( ind_nbr serial primary key, ind_name varchar(32

Re: Using psql's \prompt command

2025-01-30 Thread Rich Shepard
On Thu, 30 Jan 2025, Rich Shepard wrote: Thank you. I'll look into using the \set command. My web searches find many examples of using the \set command, but none getting user input with \prompt. Please point me to a reference where I can learn how to get the user input string into the s

Re: Using psql's \prompt command

2025-01-30 Thread Rich Shepard
On Thu, 30 Jan 2025, David G. Johnston wrote: Prompt isn’t your issue. Prompt stores the value into a variable. Read how to reference variables in a psql script. David, Thank you. I'll look into using the \set command. Rich

Re: Using psql's \prompt command

2025-01-30 Thread Rich Shepard
On Thu, 30 Jan 2025, David G. Johnston wrote: That is what \prompt is for. You have the correct meta-command, you were capturing user input just fine. Read about how to use variables in queries for the part you are missing. Specifically the section of the psql docs titled: SQL Interpolation

Re: Cannot drop column

2024-12-18 Thread Rich Shepard
On Wed, 18 Dec 2024, Rich Shepard wrote: Since your column name has an Upper case character, you will have to use double quotes to drop it. Try alter table statustypes drop column "Suspect"; Thanks for the lesson. But, bustrac=# alter table statustypes drop column "S

Re: Cannot drop column

2024-12-18 Thread Rich Shepard
On Wed, 18 Dec 2024, Viral Shah wrote: Since your column name has an Upper case character, you will have to use double quotes to drop it. Try alter table statustypes drop column "Suspect"; Viral, Huh! I've not before encountered this in the 30+ years I've used postgres. Thanks for the lesson

Re: Cannot drop column

2024-12-18 Thread Rich Shepard
On Wed, 18 Dec 2024, David G. Johnston wrote: Failed to double-quote your column name. David, Thanks. That's a new one on me. Regards, Rich

Cannot drop column

2024-12-18 Thread Rich Shepard
I'm not seeing why postgres won't drop a table's column: bustrac=# select * from statustypes order by stat_name; stat_name Client Lead No further contact Opportunity Proposal submitted Prospect Qualified Referral Suspect (9 rows) bustrac=# alter table statust

Re: Restoring database from backup

2024-12-13 Thread Rich Shepard
On Fri, 13 Dec 2024, Rich Shepard wrote: #!/usr/bin/bash The line was separated. Rich

Re: Restoring database from backup

2024-12-13 Thread Rich Shepard
On Fri, 13 Dec 2024, Adrian Klaver wrote: Alright, from here: https://www.postgresql.org/docs/current/app-pgdump.html "-c --clean Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overw

Re: Restoring database from backup

2024-12-13 Thread Rich Shepard
On Fri, 13 Dec 2024, Ron Johnson wrote: It's a text file. Open it up, and see if there's a DROP DATABASE in there. Ron, No `drop database' but it drops constraints and tables. I could add a drop database to the backup script after restoring yesterday's status. Thanks, Rich

Re: Restoring database from backup

2024-12-13 Thread Rich Shepard
On Fri, 13 Dec 2024, Adrian Klaver wrote: This needs more information: 1) Have you backed up your database at the current state? Adrian, No, the current state is FUBAR'd. The cron backup script runs each night at 11:15 p.m. 2) What command did you use to create bustrac-2024-12-12.sql? !/

Restoring database from backup

2024-12-13 Thread Rich Shepard
I made a careless error this morning and want to restore the database from yesterday's backup, `bustrac-2024-12-12.sql'. If I run psql -d bustrac -f bustrac-2024-12-12.sql will this restore the database to yesterday's status without first deleting/removing the FUBAR'd one? TIA, Rich

Meaning of + symbol at end of column string

2025-01-22 Thread Rich Shepard
I use scripts to enter new rows in tables yet on rare occasions when I select all columns from a table I'll find a "+" at the end of a string value in one column. My web search finds no explanation. What does that + symbol mean in this context? TIA, Rich

Re: Meaning of + symbol at end of column string

2025-01-22 Thread Rich Shepard
On Wed, 22 Jan 2025, David G. Johnston wrote: The value has a line break break character sequence at that point (I forget if it has any awareness of CR and CRLF differences…) David, Ah! A newline (\n). Thanks very much. I fix the row with an update and now I understand that the original input

Re: psql command line editing

2025-02-12 Thread Rich Shepard
On Wed, 12 Feb 2025, Adrian Klaver wrote: The point Tom was making is that psql uses readline for it's editing positioning and that for him Emacs movement commands work in psql. Adrian, Thanks for clarifying; the emacs commands work for me, too, in psql. Regards, Rich

Re: psql command line editing

2025-02-12 Thread Rich Shepard
On Wed, 12 Feb 2025, Tom Lane wrote: On my machine, Ctrl-Left/Right don't seem to do anything, but the usual Emacs combinations Ctrl-A, Ctrl-E, Escape-B, Escape-F and so on work in psql. I don't believe I did anything special to configure that. Check your local readline documentation. Tom, I

psql command line editing

2025-02-12 Thread Rich Shepard
My web searches suggest that using the psql command line I'm limited to moving the cursor one character at a time. Is there a way to use a small editor, e.g., joe on linux, to move by words or to the begining and end of the line? TIA, Rich

<    1   2   3   4   5   6   >