Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

specifying expression field length

Status
Not open for further replies.

tsh73

Programmer
Apr 27, 2002
304
RU
Folks, please enlight me.
Then I create a table I would say N(10,2) to get a field with preset width / decimals.
Is there kind of same thing for SELECT statement?
I could use
sele 000000.00+round(oldVal,2) as newVal
but this looks kind of clumzy (and I'm not sure it works as intended... It seems not).

So, what is the right way of ensuring proper width / decimals in evaluated field in SELECT statement?
 
If you are using VFP9:
Code:
SELECT CAST(round(oldVal,2) as N(10,2)) as newVal
If you are using smaller versions you are stuck with old code :)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Hey ts73

What do you want to do with this table ?
Is it a table you use in other forms or program's
If is isn't i would create a cursor for example in the load of the form

create cursor test;
zonea n(12,2),;
zoneb c(10))
index on str(zonea,12,2) tag key1

wfg,

FILIP MERLIER

 
Borislav, unfortunately I'm well below VFP9.
Mike, I am pretty content with "the usual way of doing it". I just want to make sure I am not re-inventing the bycicle ;)

Guys, thanks for prompt responce.
 
You may also define a cursor with the field types you want and include the fields of that cursor in your selects, without including the alias in the FROM list.

create cursor curTemp (nField N(10,2))
append blank

select curTemp.nField+oldval from table

This way you also can determine fields to be of type memo.

Still CAST() is a very nice VFP9 feature to get rid of such clumsy code, right.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top