dbTalk Databases Forums  

Syntax for Stored Procedure Pervasive 8x

comp.databases.btrieve comp.databases.btrieve


Discuss Syntax for Stored Procedure Pervasive 8x in the comp.databases.btrieve forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
BangSQL
 
Posts: n/a

Default Syntax for Stored Procedure Pervasive 8x - 11-14-2005 , 05:31 AM






Pervasive 8, WinXP client

Hi folks, I've just started working with Pervavsive and am simply
trying to create an Update Stored Procedure.


CREATE PROCEDURE spTestUpdate()
AS
BEGIN
SELECT TOP 1000 "Part Master".PMDES1_01, "Part Master"."UDFKEY_01",
LENGTH("Part Master".PMDES1_01)
FROM "Part Master"
where "Part Master"."UDFKEY_01" ='R' OR "Part Master"."UDFKEY_01" ='RS'
END

I'm gettign syntax errors.
Looking online I have seen some samples using an ";" for end of
statement marker, others that do not use it.

Questions:
1. What is the proper syntax for the stored procedure?

2. Where is a good online resource that shows Examples of using
Pervasive SQL?

Thanks in Advance!
-andy


Reply With Quote
  #2  
Old   
Bill Bach
 
Posts: n/a

Default Re: Syntax for Stored Procedure Pervasive 8x - 11-14-2005 , 09:52 AM






BangSQL wrote:

Quote:
Pervasive 8, WinXP client

Hi folks, I've just started working with Pervavsive and am simply
trying to create an Update Stored Procedure.


CREATE PROCEDURE spTestUpdate()
AS
BEGIN
SELECT TOP 1000 "Part Master".PMDES1_01, "Part Master"."UDFKEY_01",
LENGTH("Part Master".PMDES1_01)
FROM "Part Master"
where "Part Master"."UDFKEY_01" ='R' OR "Part Master"."UDFKEY_01"
='RS' END

I'm gettign syntax errors.
Looking online I have seen some samples using an ";" for end of
statement marker, others that do not use it.

Questions:
1. What is the proper syntax for the stored procedure?
You should use the semicolon as a statement separator, which should go
right before the "END" line, in this example.


Quote:
2. Where is a good online resource that shows Examples of using
Pervasive SQL?
The online manuals are OK for examples, but your best source is the
syntax diagrams included in the SQL Engine Reference section of the
manual.
Goldstar Software Inc.
Building on Btrieve(R) for the Future(SM)
Bill Bach
BillBach (AT) goldstarsoftware (DOT) com
http://www.goldstarsoftware.com
*** Chicago: Pervasive.SQL Service & Support - March, 2006 ***
*** Chicago: Pervasive DataExchange Class - March, 2006 ***


Reply With Quote
  #3  
Old   
Fardreamer
 
Posts: n/a

Default Re: Syntax for Stored Procedure Pervasive 8x - 11-14-2005 , 01:01 PM



You need a RETURNS clause that lists the field names/types the SP
returns, as so:

CREATE PROCEDURE spTestUpdate() RETURNS (FirstField UINT, SecondField
CHAR(255), [etc.])
AS ...


Reply With Quote
  #4  
Old   
BangSQL
 
Posts: n/a

Default Re: Syntax for Stored Procedure Pervasive 8x - 11-14-2005 , 08:12 PM



Thanks Bill unfortunetly I'm not quite there

CREATE PROCEDURE spTest1()
AS
BEGIN
update "Part Master"
set "Part Master".PMDES1_01 = RTRIM("Part Master".PMDES1_01) +
REPLICATE (' ', 24 - (length(RTRIM("Part Master".PMDES1_01)))) + '~'
where "Part Master"."UDFKEY_01" ='R' OR "Part Master"."UDFKEY_01"
='RS'
AND POSITION('~', "Part Master".PMDES1_01) = 0;
END


Getting an error:
[Pervasive][ODBC Client Interface][LNA][Pervasive][ODBC Engine
Interface][Data Record Manager]General error.

Any other thoughts?


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

Default Re: Syntax for Stored Procedure Pervasive 8x - 11-19-2005 , 07:47 PM



Well it is now working, not sure what the problem was.
Here is the working code for the Update Stored procedure:

-- ajb 11/19/2006
-- Update TheDescription
CREATE PROCEDURE spUpdateTest();
BEGIN
update "Part Master" set "Part Master".PMDES1_01 = '1'
where "Part Master"."UDFKEY_01" ='R' OR "Part Master"."UDFKEY_01" ='RS'

AND POSITION('~', "Part Master".PMDES1_01) = 0;

END;



-andy


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.