dbTalk Databases Forums  

simple del procedure

comp.databases.btrieve comp.databases.btrieve


Discuss simple del procedure in the comp.databases.btrieve forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bre-x
 
Posts: n/a

Default simple del procedure - 08-26-2004 , 10:00 AM






Hi, I am running pervasive 2000i. I have problem with this procedure

create procedure del_table (in :wtable char(10))
as begin
delete from :wtable;
end;

i get this errror:

[Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine
Interface][Data Record Manager][SPEng][Pervasive][ODBC Engine
Interface]Syntax Error: DELETE FROM << ??? >>?


Thank you all,




Reply With Quote
  #2  
Old   
ChrisM
 
Posts: n/a

Default Re: simple del procedure - 08-27-2004 , 04:20 AM







"Bre-x" <cholotron (AT) hotmail (DOT) com> wrote

Quote:
Hi, I am running pervasive 2000i. I have problem with this procedure

create procedure del_table (in :wtable char(10))
as begin
delete from :wtable;
end;

i get this errror:

[Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine
Interface][Data Record Manager][SPEng][Pervasive][ODBC Engine
Interface]Syntax Error: DELETE FROM << ??? >>?


Thank you all,



I'm no pervasive expert, but I don't think you can do that.
Procedure parameters can only be compared to fields etc. not used to
dynamically build SQL.

ie

You could say

delete from myTable where myKey = :keyValue

but not what you are trying to do.

I guess you could do somthing like:

CREATE PROCEDURE del_table (in :wtable char(10)) AS
BEGIN
if :wtable = 'Table1' then
delete from Table1;
end if

if :wtable = 'Table2' then
delete from Table2;
end if
END;

Depends on how many tables you have...


Regards,

Chris.

--
Please remove shoes to reply

But what ... is it good for?
- Engineer at the Advanced Computing Systems Division of IBM, 1968,
commenting on the microchip.




Reply With Quote
  #3  
Old   
Bre-x
 
Posts: n/a

Default Re: simple del procedure - 08-27-2004 , 08:52 AM



I want to be able to delete ALL records of a single table via procedure.

Thanks


"ChrisM" <chris_mayers_blue (AT) Suede (DOT) Yahoo.com> wrote

Quote:
"Bre-x" <cholotron (AT) hotmail (DOT) com> wrote in message
news:eWmXc.211588$M95.70625 (AT) pd7tw1no (DOT) ..
Hi, I am running pervasive 2000i. I have problem with this procedure

create procedure del_table (in :wtable char(10))
as begin
delete from :wtable;
end;

i get this errror:

[Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine
Interface][Data Record Manager][SPEng][Pervasive][ODBC Engine
Interface]Syntax Error: DELETE FROM << ??? >>?


Thank you all,




I'm no pervasive expert, but I don't think you can do that.
Procedure parameters can only be compared to fields etc. not used to
dynamically build SQL.

ie

You could say

delete from myTable where myKey = :keyValue

but not what you are trying to do.

I guess you could do somthing like:

CREATE PROCEDURE del_table (in :wtable char(10)) AS
BEGIN
if :wtable = 'Table1' then
delete from Table1;
end if

if :wtable = 'Table2' then
delete from Table2;
end if
END;

Depends on how many tables you have...


Regards,

Chris.

--
Please remove shoes to reply

But what ... is it good for?
- Engineer at the Advanced Computing Systems Division of IBM, 1968,
commenting on the microchip.





Reply With Quote
  #4  
Old   
Bre-x
 
Posts: n/a

Default Re: simple del procedure - 08-27-2004 , 10:02 AM



ChirsM

Thanks for you help. Your script/procedure works very well

CREATE PROCEDURE del_table (in :wtable char(10)) AS
BEGIN
if :wtable = 'SO_Desc' then
delete from SO_Desc;
end if

if :wtable = 'SO_Inv' then
delete from SO_Inv;
end if
END;

thnks!!


"ChrisM" <chris_mayers_blue (AT) Suede (DOT) Yahoo.com> wrote

Quote:
"Bre-x" <cholotron (AT) hotmail (DOT) com> wrote in message
news:eWmXc.211588$M95.70625 (AT) pd7tw1no (DOT) ..
Hi, I am running pervasive 2000i. I have problem with this procedure

create procedure del_table (in :wtable char(10))
as begin
delete from :wtable;
end;

i get this errror:

[Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine
Interface][Data Record Manager][SPEng][Pervasive][ODBC Engine
Interface]Syntax Error: DELETE FROM << ??? >>?


Thank you all,




I'm no pervasive expert, but I don't think you can do that.
Procedure parameters can only be compared to fields etc. not used to
dynamically build SQL.

ie

You could say

delete from myTable where myKey = :keyValue

but not what you are trying to do.

I guess you could do somthing like:

CREATE PROCEDURE del_table (in :wtable char(10)) AS
BEGIN
if :wtable = 'Table1' then
delete from Table1;
end if

if :wtable = 'Table2' then
delete from Table2;
end if
END;

Depends on how many tables you have...


Regards,

Chris.

--
Please remove shoes to reply

But what ... is it good for?
- Engineer at the Advanced Computing Systems Division of IBM, 1968,
commenting on the microchip.





Reply With Quote
  #5  
Old   
ChrisM
 
Posts: n/a

Default Re: simple del procedure - 08-27-2004 , 10:28 AM



"Bre-x" <cholotron (AT) hotmail (DOT) com> wrote

Quote:
ChirsM

Thanks for you help. Your script/procedure works very well

CREATE PROCEDURE del_table (in :wtable char(10)) AS
BEGIN
if :wtable = 'SO_Desc' then
delete from SO_Desc;
end if

if :wtable = 'SO_Inv' then
delete from SO_Inv;
end if
END;

thnks!!


Another advantage of doing it this way is you can only delete certain
pre-specified tables, so you couldn't accidentally type (say):

call del_table('ReallyImportantSalesData')

Unless that table was one of the ones you wanted to be able to delete...

--
Please remove shoes to reply

But what ... is it good for?
- Engineer at the Advanced Computing Systems Division of IBM, 1968,
commenting on the microchip.




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.