Adding a field to an answer table

Adding a field to an answer table

Post by Wristd » Sun, 02 Apr 2000 04:00:00



I have an answer table from a query called answer.db.  I want to add a new 20
character string field called "Notes" to this table.  

Is there a simple way to add this field at the time of the QBE?  Otherwise what
is the correct OPAL code to simply add a string field to an existing table
(nothing fancy, no default, no checking)?  I've read the restructure command
(and examples) and I am still uncertain how to do this.

wristdoc

 
 
 

Adding a field to an answer table

Post by peggy bake » Sun, 02 Apr 2000 04:00:00


Query

    tblname.db    |    Field1    |    Field 2   |
Field3                                                   |
                         |    Check     |    Check     | Check calc
"                     " as "Notes"  |

EndQuery

--Peggy


> I have an answer table from a query called answer.db.  I want to add a new 20
> character string field called "Notes" to this table.

> Is there a simple way to add this field at the time of the QBE?  Otherwise what
> is the correct OPAL code to simply add a string field to an existing table
> (nothing fancy, no default, no checking)?  I've read the restructure command
> (and examples) and I am still uncertain how to do this.

> wristdoc

--
Peggy Baker
Pres., DT&S Ltd.
Software solutions for clinical data
and not-for-profit agencies
www.dtsmed-data.com

 
 
 

Adding a field to an answer table

Post by Richard Cart » Sun, 02 Apr 2000 04:00:00


: Query

:     tblname.db    |    Field1    |    Field 2   |
: Field3                                                   |
:                          |    Check     |    Check     | Check calc
: "                     " as "Notes"  |

: EndQuery

: > I have an answer table from a query called answer.db.  I want to add a new 20
: > character string field called "Notes" to this table.

Peggy's example should work.  But if you want to keep the table
around and manipulate the data, don't use the default name of
:PRIV:ANSWER.DB for the table!  That table would be overwritten
the next time you run a query.
--
Rick Carter

 
 
 

Adding a field to an answer table

Post by Steve Gree » Sun, 02 Apr 2000 04:00:00



> | Check calc "                     " as "Notes"  |

this is one of the few ways that padded blanks can become a permanent part of a
field.. it's better to

calc "xxxxxxxxxxxxxxxxxxxx" as Notes

so you can actually see the records that aren't changed later on

--
Steve Green
Corel CTech - Paradox
Diamond Software Group, Inc.
Waldorf, Maryland  USA

http://www.diamondsg.com

 
 
 

Adding a field to an answer table

Post by Wristd » Sun, 02 Apr 2000 04:00:00


I don't quite understand the syntax.  Are field1 and field2 part of the
original answer table.... and field3 is a new field?

qvar=Query
:datadir:anstbl.db  |oldfield1|oldfield2|Notes|
                           | check  |check   |check calc "            " as
notes|
endquery

 
 
 

Adding a field to an answer table

Post by Michael Juul Hanse » Sun, 02 Apr 2000 04:00:00


In the create query window you place checkmarks in oldfield1, oldfield3 and
the Notes field. In the notefield you write this

CALC "xxxxxxxxxxxxxxxxxxxx" as DesiredNameOfField

HTH


> I don't quite understand the syntax.  Are field1 and field2 part of the
> original answer table.... and field3 is a new field?

> qvar=Query
> :datadir:anstbl.db  |oldfield1|oldfield2|Notes|
>                            | check  |check   |check calc "            " as
> notes|
> endquery

--
Michael
 
 
 

Adding a field to an answer table

Post by Liz » Tue, 04 Apr 2000 04:00:00


Wristdoc,

"I don't quite understand the syntax."

This is one reason why it would have helped for you to post
your original query for us to use instead of our
imaginations....  That said, field1 or oldfield1, etc. are
our way of representing your table's fields without knowing
the actual field names in your table.

Now, for more detail on how to solve your problem:  You can
create new fields in an answer table by using...

calc <something here> as <new field name here>

...in one of the fields of the query.  

<new field name here> is simply the name you would like to
give the new field in your answer table, in your case, it
would be Notes.  

<something here> could be a variety of things.  Since you
want an A20 field, you could use 20 x's as Steve suggests,
or 20 spaces as others have suggested or any 20 alpha
characters (be sure to use letters - using numbers would
create a longint or number field).  Another option is to use
the reserved word BLANK.  This will create an empty field
with the specified name in your answer table - the key here
is that the field type and size will match exactly the field
where you put the calc statement.  So, if you happen to have
another A20 field in your table, you could put the statement

calc BLANK as Notes

in that field, and you'll end up with an empty A20 field
named Notes in your answer table.  Do some testing with
these options, and you'll get the idea pretty quick.

Hope this helps,

Liz
---
Get the lead out before you reply


> I don't quite understand the syntax.  Are field1 and field2 part of the
> original answer table.... and field3 is a new field?

> qvar=Query
> :datadir:anstbl.db  |oldfield1|oldfield2|Notes|
>                            | check  |check   |check calc "            " as
> notes|
> endquery

 
 
 

Adding a field to an answer table

Post by Wristd » Thu, 06 Apr 2000 04:00:00


Liz,
Thank you for reply using 'calc' to create a new field in a query.  It seems
unsual to create a new field this way (under an existing table field).  What if
my table which I query only has two fields and I want both included in the
answer table plus a new field.  Is there a place to tuck my calc field then?
 
 
 

Adding a field to an answer table

Post by Liz » Thu, 06 Apr 2000 04:00:00


Wristdoc,

The number of statements you can put under an existing field
in a query isn't really limited - check 'em both, calc sum
'em both, calc min and calc max 'em both, and you can still
put calc blank as Notes in one of 'em too.  (Of course, I
wouldn't want to be the one figuring out where the comma is
missing in that query... <g>)  

BTW, no, there is no other place where you can put the calc
statement to create a new field, and as I mentioned, the
field type and size is determined by the type and size of
the field you put the calc statement in.

Regards,

Liz
---
Get the lead out before you reply


> Liz,
> Thank you for reply using 'calc' to create a new field in a query.  It seems
> unsual to create a new field this way (under an existing table field).  What if
> my table which I query only has two fields and I want both included in the
> answer table plus a new field.  Is there a place to tuck my calc field then?