Re: [GENERAL] Question about copy from with timestamp format

2015-08-05 Thread Adrian Klaver
On 08/05/2015 09:16 AM, Murali M wrote: Hi everyone, First of all, let me thank all of you for the very informative discussion. I will say my solution was to declare the field MMDDHH24 as int (can handle till Dec 31, 2147, Hr23 -- which will be 2147123123). Also this way, I can still use bet

Re: [GENERAL] Question about copy from with timestamp format

2015-08-05 Thread Murali M
Hi everyone, First of all, let me thank all of you for the very informative discussion. I will say my solution was to declare the field MMDDHH24 as int (can handle till Dec 31, 2147, Hr23 -- which will be 2147123123). Also this way, I can still use between etc to select a range of dates.. of c

Re: [GENERAL] Question about copy from with timestamp format

2015-08-04 Thread Jim Nasby
On 7/30/15 3:09 PM, Alban Hertroys wrote: COPY is a bit special, I'm afraid. For starters, although it works_like_ doing a bunch of INSERTs, it doesn't perform actual INSERTs. Apparently, that also means it won't fire an INSERT rule and thus can't be used with an updatable view. There are no

Re: [GENERAL] Question about copy from with timestamp format

2015-07-30 Thread Alban Hertroys
> On 30 Jul 2015, at 17:59, Sherrylyn Branchaw wrote: > > From here: > > http://www.postgresql.org/docs/9.4/interactive/sql-copy.html > > "COPY can only be used with plain tables, not with views. However, you can > write COPY (SELECT * FROM viewname) TO " > > Right, so you can COPY FROM

Re: [GENERAL] Question about copy from with timestamp format

2015-07-30 Thread Adrian Klaver
On 07/30/2015 08:59 AM, Sherrylyn Branchaw wrote: From here: http://www.postgresql.org/docs/9.4/interactive/sql-copy.html "COPY can only be used with plain tables, not with views. However, you can write COPY (SELECT * FROM viewname) TO " Right, so you can COPY FROM a view, but not, as far

Re: [GENERAL] Question about copy from with timestamp format

2015-07-30 Thread Adrian Klaver
On 07/30/2015 08:59 AM, Sherrylyn Branchaw wrote: From here: http://www.postgresql.org/docs/9.4/interactive/sql-copy.html "COPY can only be used with plain tables, not with views. However, you can write COPY (SELECT * FROM viewname) TO " Right, so you can COPY FROM a view, but not, as far

Re: [GENERAL] Question about copy from with timestamp format

2015-07-30 Thread Sherrylyn Branchaw
>From here: http://www.postgresql.org/docs/9.4/interactive/sql-copy.html "COPY can only be used with plain tables, not with views. However, you can write COPY (SELECT * FROM viewname) TO " Right, so you can COPY FROM a view, but not, as far as I can tell, TO a view, unless Alban found a work

Re: [GENERAL] Question about copy from with timestamp format

2015-07-30 Thread Adrian Klaver
On 07/30/2015 08:44 AM, Sherrylyn Branchaw wrote: I was thinking that perhaps an updatable view might do the trick? Interesting idea! Are you able to get it to work? I keep getting 'ERROR: cannot copy to view "view_ts_test"' even before my trigger fires. Inserting, though, works fine. From h

Re: [GENERAL] Question about copy from with timestamp format

2015-07-30 Thread Sherrylyn Branchaw
I was thinking that perhaps an updatable view might do the trick? Interesting idea! Are you able to get it to work? I keep getting 'ERROR: cannot copy to view "view_ts_test"' even before my trigger fires. Inserting, though, works fine. Still curious why the triggers I'm writing won't fire before

Re: [GENERAL] Question about copy from with timestamp format

2015-07-30 Thread Alban Hertroys
> On 30 Jul 2015, at 2:27, Sherrylyn Branchaw wrote: > > Based on your PS asking about data types and commenting that you don't want > to put hour in a separate column, it sounds like this is a brand-new table > you're creating. If so, and if this is a one-time COPY operation, you can > creat

Re: [GENERAL] Question about copy from with timestamp format

2015-07-29 Thread Sherrylyn Branchaw
Based on your PS asking about data types and commenting that you don't want to put hour in a separate column, it sounds like this is a brand-new table you're creating. If so, and if this is a one-time COPY operation, you can create a text column for the initial import. Then after you're done import

Re: [GENERAL] Question about copy from with timestamp format

2015-07-29 Thread Adrian Klaver
On 07/29/2015 03:55 PM, Murali M wrote: How do I specify that when I use copy from? this is what I am trying right now.. copy myTable (myTimeCol, col2) from myFile delimiter as '\t' I am not sure how to specify the time format.. My previous post would have been more useful if I had added that

Re: [GENERAL] Question about copy from with timestamp format

2015-07-29 Thread Adrian Klaver
On 07/29/2015 03:55 PM, Murali M wrote: How do I specify that when I use copy from? this is what I am trying right now.. copy myTable (myTimeCol, col2) from myFile delimiter as '\t' Argh, missed that. I am not sure how to specify the time format.. Yeah, the time component prevents you from

Re: [GENERAL] Question about copy from with timestamp format

2015-07-29 Thread Murali M
How do I specify that when I use copy from? this is what I am trying right now.. copy myTable (myTimeCol, col2) from myFile delimiter as '\t' I am not sure how to specify the time format.. thanks, murali. On Wed, Jul 29, 2015 at 3:49 PM, Adrian Klaver wrote: > On 07/29/2015 03:42 PM, Murali M

Re: [GENERAL] Question about copy from with timestamp format

2015-07-29 Thread Adrian Klaver
On 07/29/2015 03:42 PM, Murali M wrote: Hi, I wanted to copy a file from local file system to postgres. I have timestamp value specified as: MMDDHH24 format -- for example: 2015072913 -- is July 29, 2015 at 13:00 how do I import this data into a timestamp field? thanks, murali. PS: I beli

[GENERAL] Question about copy from with timestamp format

2015-07-29 Thread Murali M
Hi, I wanted to copy a file from local file system to postgres. I have timestamp value specified as: MMDDHH24 format -- for example: 2015072913 -- is July 29, 2015 at 13:00 how do I import this data into a timestamp field? thanks, murali. PS: I believe if I need the hour, I need to use time