Hi,

I create a CURSOR with different fields. How can I delete a field in
that CURSOR if all the records of that field are blank?

Thanks

Regards,
Derek

Re: Deleting field in CURSOR by Hutch

Hutch
Sat Dec 04 01:25:44 CST 2004

Derek,

check out the ALTER command with drop column in the help file.
the following is an extract:
ALTER TABLE TableName1 [DROP [COLUMN] FieldName3]
[SET CHECK lExpression3 [ERRORcMessageText3]] [DROP CHECK]
[ADD PRIMARY KEY eExpression3 [FOR lExpression4] TAG TagName2
[COLLATE cCollateSequence]] [DROP PRIMARY KEY]
[ADD UNIQUE eExpression4 [[FOR lExpression5] TAG TagName3
[COLLATE cCollateSequence]]] [DROP UNIQUE TAG TagName4]
[ADD FOREIGN KEY [eExpression5] [FOR lExpression6] TAG TagName4
[COLLATE cCollateSequence] REFERENCES TableName2 [TAG TagName5]]
[DROP FOREIGN KEY TAG TagName6 [SAVE]] [RENAME COLUMN FieldName4 TO
FieldName5] [NOVALIDATE]
DROP [COLUMN] FieldName3
Specifies a field to remove from the table. Removing a field from the table
also removes the field's default value setting and field validation rule.
If index key or trigger expressions reference the field, the expressions
become invalid when the field is removed. In this case, an error is not
generated when the field is removed, but the invalid index key or trigger
expressions generate errors at run time.


--


---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"

Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com


"July Derek" <julyderek@hotmail.com> wrote in message
news:9680a0b6.0412032320.2395dc75@posting.google.com...
> Hi,
>
> I create a CURSOR with different fields. How can I delete a field in
> that CURSOR if all the records of that field are blank?
>
> Thanks
>
> Regards,
> Derek



Re: Deleting field in CURSOR by David

David
Sat Dec 04 10:21:06 CST 2004

Derek,

You can use the ALTER TABLE command Hutch recommends on a cursor, it is sort
of odd sytnax but it does work:

create cursor x1 ( i1 i, c1 c(10) )
insert into x1 values ( 1, 'test' )
alter table x1 drop column c1
browse

--
df - Microsoft MVP FoxPro http://www.geocities.com/df_foxpro

"July Derek" <julyderek@hotmail.com> wrote in message
news:9680a0b6.0412032320.2395dc75@posting.google.com...
> Hi,
>
> I create a CURSOR with different fields. How can I delete a field in
> that CURSOR if all the records of that field are blank?



Re: Deleting field in CURSOR by julyderek

julyderek
Mon Jan 17 01:53:03 CST 2005

Hi Guys,

When I use:

ALTER TABLE temp DROP COLUMN &field.....it gives me a SYNTAX error!!
Please help.


Re: Deleting field in CURSOR by borisb

borisb
Mon Jan 17 03:49:28 CST 2005

julyderek@hotmail.com wrote:
> Hi Guys,
>
> When I use:
>
> ALTER TABLE temp DROP COLUMN &field.....it gives me a SYNTAX error!!
> Please help.
>

Why You should do that?
If You create cursor via SQL Select, Just not select that field in SQL.
If You use CREATE CURSOR - create the CURSOR w/o field.

Re: Deleting field in CURSOR by David

David
Mon Jan 17 08:25:23 CST 2005

July,

What version of VFP? What is the value of field at the time? (It's not
particularly good to use a reserved word as a memvar name field() is a
function in VFP). What is the structure of temp at the time?

--
df - Microsoft MVP FoxPro http://www.geocities.com/df_foxpro

"julyderek@hotmail.com" <burzinb@gmail.com> wrote in message
news:1105948383.383040.323420@c13g2000cwb.googlegroups.com...
> Hi Guys,
>
> When I use:
>
> ALTER TABLE temp DROP COLUMN &field.....it gives me a SYNTAX error!!
> Please help.
>



Re: Deleting field in CURSOR by Anders

Anders
Mon Jan 17 06:29:39 CST 2005

I tried to replicate that error:

USE H:\VFP9TESTING\customers.dbf
BROWSE LAST NOWAIT
cfield='ccustname'
ALTER table customers DROP COLUMN &cfield

No problem

-Anders



"borisb" <borisb@mail.bg> wrote in message
news:OBBIVnH$EHA.1392@tk2msftngp13.phx.gbl...
> julyderek@hotmail.com wrote:
> > Hi Guys,
> >
> > When I use:
> >
> > ALTER TABLE temp DROP COLUMN &field.....it gives me a SYNTAX error!!
> > Please help.
> >
>
> Why You should do that?
> If You create cursor via SQL Select, Just not select that field in SQL.
> If You use CREATE CURSOR - create the CURSOR w/o field.


Re: Deleting field in CURSOR by julyderek

julyderek
Sun Jan 23 07:13:27 CST 2005

Thanks guys. but is was my mistake. the variable "field" I was using
(didnt use the reserve word but just as an example) had a wrong syntax
when I used it in as &field

Regards,
Derek