| From: | "Claudio Lapidus" <clapidus(at)hotmail(dot)com> | 
|---|---|
| To: | "Ron Johnson" <ron(dot)l(dot)johnson(at)cox(dot)net>, "PgSQL General ML" <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Re: Knowing how many records I just inserted | 
| Date: | 2003-08-05 22:03:25 | 
| Message-ID: | BAY7-DAV53kzMcvsq9I00019c97@hotmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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(dot)l(dot)johnson(at)cox(dot)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(at)postgresql(dot)org)
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joshua D. Drake | 2003-08-05 22:10:59 | Re: migrating data from 7.3.x down to 7.2.x | 
| Previous Message | Justin Tocci | 2003-08-05 21:36:39 | Re: INSERT RULE QUERY ORDER |