Can't "EXTRACT" from a field?

Can't "EXTRACT" from a field?

Post by Marc G. Fournie » Sat, 24 Nov 2001 00:26:47



Simple, really ... using v7.2b3 that hasn't been released yet ...

traf_stats=# select EXTRACT(WEEK FROM TIMESTAMP runtime) from hourly_stats;
ERROR:  parser: parse error at or near "runtime"
traf_stats=# \d hourly_stats
                 Table "hourly_stats"
   Column   |            Type             | Modifiers
------------+-----------------------------+-----------
 from_ip    | inet                        |
 to_ip      | inet                        |
 port       | integer                     |
 bytes      | bigint                      |
 runtime    | timestamp(6) with time zone |
 no_records | integer                     |
Indexes: hourly_from_ip,
         hourly_to_ip

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate

message can get through to the mailing list cleanly

 
 
 

Can't "EXTRACT" from a field?

Post by Brent Vern » Sat, 24 Nov 2001 01:17:00



|
| Simple, really ... using v7.2b3 that hasn't been released yet ...
|
| traf_stats=# select EXTRACT(WEEK FROM TIMESTAMP runtime) from hourly_stats;
| ERROR:  parser: parse error at or near "runtime"

The following works for me (on 7.2b3).

  create table test( id serial, tid timestamp default now() );
  select extract(week from tid) from test;

gram.y has
  extract_list:  extract_arg FROM a_expr

which appears to be in keeping with the sql99 def.
  part2-         <extract expression> ::=
  part2:              EXTRACT <left paren> <extract field>
  part2-                  FROM <extract source> <right paren>

I don't know if there was ever any other format for extract(), but
things look normal from here.

btw Marc, can you help me in getting archives of the various lists?

cheers.
  brent

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing."  -- Duane Allman

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

 
 
 

Can't "EXTRACT" from a field?

Post by Marc G. Fournie » Sat, 24 Nov 2001 01:31:59




> |
> | Simple, really ... using v7.2b3 that hasn't been released yet ...
> |
> | traf_stats=# select EXTRACT(WEEK FROM TIMESTAMP runtime) from hourly_stats;
> | ERROR:  parser: parse error at or near "runtime"

> The following works for me (on 7.2b3).

>   create table test( id serial, tid timestamp default now() );
>   select extract(week from tid) from test;

> gram.y has
>   extract_list:  extract_arg FROM a_expr

> which appears to be in keeping with the sql99 def.
>   part2-         <extract expression> ::=
>   part2:              EXTRACT <left paren> <extract field>
>   part2-                  FROM <extract source> <right paren>

> I don't know if there was ever any other format for extract(), but
> things look normal from here.

ya, I hadn't clued in until fighting with it some more that if the fieldis
already a timestamp, yyou don't have to put it in as 'EXTRACT(WEEK FROM
TIMESTAMP tid) :(

Quote:> btw Marc, can you help me in getting archives of the various lists?

they are all at archives.postgresql.org ... no?

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate

message can get through to the mailing list cleanly

 
 
 

Can't "EXTRACT" from a field?

Post by Brent Vern » Sat, 24 Nov 2001 02:12:50




|

| > |
| > | Simple, really ... using v7.2b3 that hasn't been released yet ...
| > |
| > | traf_stats=# select EXTRACT(WEEK FROM TIMESTAMP runtime) from hourly_stats;
| > | ERROR:  parser: parse error at or near "runtime"
| >
| > The following works for me (on 7.2b3).
| >
| >   create table test( id serial, tid timestamp default now() );
| >   select extract(week from tid) from test;
| >
| >
| > gram.y has
| >   extract_list:  extract_arg FROM a_expr
| >
| > which appears to be in keeping with the sql99 def.
| >   part2-         <extract expression> ::=
| >   part2:              EXTRACT <left paren> <extract field>
| >   part2-                  FROM <extract source> <right paren>
| >
| >
| > I don't know if there was ever any other format for extract(), but
| > things look normal from here.
|
| ya, I hadn't clued in until fighting with it some more that if the fieldis
| already a timestamp, yyou don't have to put it in as 'EXTRACT(WEEK FROM
| TIMESTAMP tid) :(

I didn't even know what the args to extract were, which is how I ended
up in gram.y...

note: extract() is correctly not listed as a function, but it doesn't
      have any '\h' help available.  Is this a TODO kind-of-thing?  If
      it is I can try to add it sometime later today.  There is not
note2: This documentation is incorrect as of last night's cvs.
      an example given in the docs is.
        SELECT EXTRACT(CENTURY FROM TIMESTAMP '2001-02-16 20:38:40');
      I can go ahead and update func.sgml if noone else is already
      getting it.

| > btw Marc, can you help me in getting archives of the various lists?
|
| they are all at archives.postgresql.org ... no?

Not that I see.  archives. points at www2.us.

I ftp'd around every postgresql.org (and hub.org) anonftp server
I could find, and sent an 'index' command to majordomo, and it has
/some/ files listed, but I could not ever retreive those files...

I'm really looking forward to having locally (mutt!!) searchable
docs...

Did you ever get the documentation issue worked out?  Is there anything
I can do to help with that?  I did get man.tar and postgres.tar built
from cvs on my debian box.

Thanks,
  Brent

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing."  -- Duane Allman

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command

 
 
 

Can't "EXTRACT" from a field?

Post by Brent Vern » Sat, 24 Nov 2001 02:42:16



|
| ya, I hadn't clued in until fighting with it some more that if the fieldis
| already a timestamp, yyou don't have to put it in as 'EXTRACT(WEEK FROM
| TIMESTAMP tid) :(

Ok, scratch my previous email WRT the sgml docs being wrong...

Something is strange, tho.

brent=# select extract( week from timestamp ('2001-02-06 20:38:40'::timestamp)>
ERROR:  parser: parse error at or near "'"
brent=# select extract( week from "timestamp" ('2001-02-06 20:38:40'::timestam>
 date_part
-----------
         6
(1 row)

brent=# select extract( week from timestamp ('2001-02-06 20:38:40') );
ERROR:  parser: parse error at or near "'"
brent=# select extract( week from timestamp '2001-02-06 20:38:40'::timestamp );
 date_part
-----------
         6
(1 row)

brent=# select extract( week from timestamp '2001-02-06 20:38:40' );
 date_part
-----------
         6
(1 row)

Notice:
  timestamp( type )         => fail
  "timestamp"( type )       => OK
  timestamp type            => OK
  timestamp column_of_type  => fail     [1] Marc's original observation.

can't help any more...
  brent

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing."  -- Duane Allman

---------------------------(end of broadcast)---------------------------

 
 
 

Can't "EXTRACT" from a field?

Post by Tom La » Sat, 24 Nov 2001 03:13:22



> note: extract() is correctly not listed as a function, but it doesn't
>       have any '\h' help available.  Is this a TODO kind-of-thing?  If
>       it is I can try to add it sometime later today.

There is no mechanism for keeping track of help entries for functions,
only statements.

Quote:> note2: This documentation is incorrect as of last night's cvs.
>       an example given in the docs is.
>         SELECT EXTRACT(CENTURY FROM TIMESTAMP '2001-02-16 20:38:40');

This example is fine.  Try it.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

 
 
 

Can't "EXTRACT" from a field?

Post by Tom La » Sat, 24 Nov 2001 10:52:01



> Something is strange, tho.

The construct you're poking around the edges of here is

                type-name  literal-string

which is an SQLish typed constant.  (Or more accurately, it's Thomas'
generalization of some type-specific constant syntaxes that appear in
SQL92.  AFAIK the spec itself doesn't claim this is a type-universal
construction.)

Casting something other than a string literal requires different, more
explicit syntax; eg, CAST(foo AS type), foo::type, or if the type name
is allowable as a function name type(foo) will work.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command

 
 
 

1. How to make a "decimal"-field to an "integer"-field

Hello
It is probably very easy, but I can't figure it out:
A field in a table on my MSSQL-server is at decimal-field, but in a view I
would like to use the field as an integer-field. I have tryed the SQL-code:

SELECT Int([Tabel1]![Felt2]) AS Udtryk1
FROM Tabel1;

but it dosn't work ! How do I do that ?

Thanks, Mads.

2. CREATE FUNCTIONS

3. aReport."Field".SetFilter("this")?

4. How to connect Oracle from VB using Net8

5. max of ("...","...","..")

6. Error -20

7. Field's "OrdinalPosition"

8. Ingres Access from Forest & Trees

9. Extracting LastName from "Title FirstName LastName"

10. Extracting "Column Description" from schema

11. ODBC, Serial Fields (aka "Counter Fields"), and Insert

12. dr("field").toString returns "400.0000" instead of "400"

13. application error 'at "0x001ec000"'