How to escape reserved words?

Hi,

Let’s say I have some schema and data like this:

PeopleTable : ( name:symbol$(); age:int$(); group:symbol$() ) PeopleTable ,: (A; 12; students) PeopleTable ,: (B; 18; students) PeopleTable ,: (C; 25; worker) PeopleTable ,: (D; 50; `worker)
select value:avg age by grp from PeopleTable

which causes error because ‘group’ and ‘value’ are reserved words.

It works if those columns are renamed.
PeopleTable : ( name:symbol$(); age:int$(); grp:symbol$() ) PeopleTable ,: (A; 12; students) PeopleTable ,: (B; 18; students) PeopleTable ,: (C; 25; worker) PeopleTable ,: (D; 50; `worker)
select v1:avg age by grp from PeopleTable

My question is whether there is an easy way to escape the reserved words in table creation/data insertion/aggregation or how it can be done.

Thanks

You can use functional select:

PeopleTable : flip nameagegroup!(){y$x}/:"SIS" PeopleTable ,: (A; 12; students) PeopleTable ,: (B; 18; students) PeopleTable ,: (C; 25; worker) PeopleTable ,: (D; 50; worker) ?[PeopleTable;();enlist[group] !enlist group;enlist[value]!enlist (avg;`age)]

Am 27.06.2012 04:46, schrieb Hom L:

Hi,

Let’s say I have some schema and data like this:

PeopleTable : ( name:symbol$(); age:int$(); group:symbol$() ) PeopleTable ,: (A; 12; students) PeopleTable ,: (B; 18; students) PeopleTable ,: (C; 25; worker) PeopleTable ,: (D; 50; `worker)
select value:avg age by grp from PeopleTable

which causes error because ‘group’ and ‘value’ are reserved words.

It works if those columns are renamed.
PeopleTable : ( name:symbol$(); age:int$(); grp:symbol$() ) PeopleTable ,: (A; 12; students) PeopleTable ,: (B; 18; students) PeopleTable ,: (C; 25; worker) PeopleTable ,: (D; 50; `worker)
select v1:avg age by grp from PeopleTable

My question is whether there is an easy way to escape the reserved words in table creation/data insertion/aggregation or how it can be done.

Thanks


You received this message because you are subscribed to the Google Groups “Kdb+ Personal Developers” group.
To view this discussion on the web visit https://groups.google.com/d/msg/personal-kdbplus/-/I3gDrwz47N4J.
To post to this group, send email to personal-kdbplus@googlegroups.com.
To unsubscribe from this group, send email to personal-kdbplus+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/personal-kdbplus?hl=en.

Thank you very much.