Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create an Integer field on the fly
Message
From
20/06/2000 14:54:12
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00382290
Message ID:
00382323
Views:
14
>>>Hi everyone,
>>>
>>>I'd like to create an Integer field in a select statement. AFAIK, by default it creates Numeric field. How can I do this?
>>>E.g.
>>> Select space(1) as moditype, ctot('') as PostTime, ? as Error (should be Integer field), .f. as Posted, etc.
>>>
>>>Thanks in advance.
>>
>>sele 000 as intfield && creates three digit integer field
>
>It creates Numeric field, not Integer!!!!!!

I know that numeric works in your current context, but in case you ever want to create an integer constant on the fly the following works:

Than do an inner join on a expression that will always evaluate to .t. (for example 1=1). Voila -- you can now put the constant of the right type and value into every row in your result example:


CREATE TABLE henig (f1 c(10))
APPEND BLANK
REPL f1 WITH "x"
APPEND BLANK
REPL f1 WITH "y"
APPEND BLANK
REPL f1 WITH "z"


CREATE CURSOR henig2 (f2 i)
APPEND BLANK
REPL f2 WITH 22


SELECT henig.f1,henig2.f2 FROM henig inner JOIN henig2 ON 1=1



Do a display stru on Query, and you will see that f2 not only has a value of 22 but is an integer type. This also works to let you create null constants of any data type you want. If you work with large files, this is a lot faster than adding an "append from" to your code.
Thanks

Gar W. Lipow
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform