RE: Returned row count doesn't match lines in output file

From: "Tchouante, Merlin" <mtchouan(at)umaryland(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: RE: Returned row count doesn't match lines in output file
Date: 2019-11-07 18:29:17
Message-ID: BL0PR12MB256204F37C42B64623227B07D2780@BL0PR12MB2562.namprd12.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thank you so much for responding.

Yes, one of the selected columns is null; when I only select one column that I know can't be a null, it returns all of them. I changed it to the below and it worked just fine, thank you so much.

select u.user_id||'|'||coalesce(u.firstname,'')||'|'||coalesce(u.lastname,'')||'|'||coalesce(u.email,'')||'|'||coalesce(u.student_id,'')

Thanks,
  -- Merlin
 
 
Merlin D. Tchouante, Sr. IT Enterprise Application Developer
Center for Information Technology Services (CITS)
601 West Lombard Street
Baltimore, Maryland 21201-1512
mtchouan(at)umaryland(dot)edu 
410-706-4489 * 410-706-1500 fax

Please send Blackboard questions to the CITS support email address:  DL-CITSBbSupport(at)umaryland(dot)edu
Please send Mediasite questions to the CITS support email address:  DL-CITSMediasiteSupport(at)umaryland(dot)edu

-----Original Message-----
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Sent: Thursday, November 7, 2019 1:07 PM
To: Tchouante, Merlin <mtchouan(at)umaryland(dot)edu>
Cc: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Re: Returned row count doesn't match lines in output file

"Tchouante, Merlin" <mtchouan(at)umaryland(dot)edu> writes:
> I'm executing an .sql file which looks like this:

> \o /home/bbuser/banner/gradeload/sodorgusers.txt
> \t on
> select
> u.user_id||'|'||u.firstname||'|'||u.lastname||'|'||u.email||'|'||u.stu
> dent_id from users u, course_main cm, course_users cu where
> cu.crsmain_pk1 = cm.pk1 and cu.users_pk1 = u.pk1 and cm.course_id =
> 'Org.dent.Training'
> order by u.lastname, u.firstname;
> \t off
> \o

> When I look at the output file, it has a bunch of blank lines in between the records but displays a line count of 4916. What is causing the blank lines?

Null values in one or more of the columns you're concatenating, perhaps?
Concatenating a null with something else yields null. (See
coalesce() for one ad-hoc way to fix that.)

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tchouante, Merlin 2019-11-08 16:55:33 Help with outer joins
Previous Message Steve Midgley 2019-11-07 18:06:38 Re: Returned row count doesn't match lines in output file