Re: Knowing how many records I just inserted - Mailing list pgsql-general

From Claudio Lapidus
Subject Re: Knowing how many records I just inserted
Date
Msg-id BAY7-DAV53kzMcvsq9I00019c97@hotmail.com
Whole thread Raw
In response to Knowing how many records I just inserted  (Ron Johnson <ron.l.johnson@cox.net>)
List pgsql-general
> How can I get that back out to bash, if I'm doing psql scripting?
> An env. variable wouldn't work, since it would go away when psql
> terminates.

Capture the stdout of the psql command and pipe it through cut in order to
get only the third word of output.

your_shell_variable=`psql -c 'insert into t1 select attrs from t2' | cut -d'
' -f3`


hth,
cl.



>
> TIA
> --
> +-----------------------------------------------------------------+
> | Ron Johnson, Jr.        Home: ron.l.johnson@cox.net             |
> | Jefferson, LA  USA                                              |
> |                                                                 |
> | "I'm not a vegetarian because I love animals, I'm a vegetarian  |
> |  because I hate vegetables!"                                    |
> |    unknown                                                      |
> +-----------------------------------------------------------------+
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>

pgsql-general by date:

Previous
From: Justin Tocci
Date:
Subject: Re: INSERT RULE QUERY ORDER
Next
From: "Joshua D. Drake"
Date:
Subject: Re: migrating data from 7.3.x down to 7.2.x