Thanks,
--
Kelly Orr
GoldTech Computer Services, Inc.
http://www.goldtechservices.com
478 Pistol Club Road
Easley, South Carolina 29640
864-294-0138 Voice
864-246-1454 Fax
--
--
Kind regards,
James Cooke
http://www.clarionfoundry.com - a concise technical reference for Clarion
Programmers
http://63.99.156.24/
=========================================
"Kelly Orr" <ke...@goldtechservices.com> wrote in message
news:3D331DAE...@goldtechservices.com...
Unfortunately, I already looked there. The solution given was to do it the
old way where you have to declare a table with the same layout as the output
from the stored procedure and do a NEXT() after you do the PROP:SQL statement
to call the stored procedure. I have no problem making that way work. In the
documenation for 5.5, it states you can use input and output parameters with
it. This was not available before 5.5. I have done it exactly as the docs
state and it never does the bind of the parameters and Sql Server says it's
invalid syntax. Here is how the docs have it:
Example:
PROGRAM
MAP
CallProc(STRING)
END
MyFile FILE,DRIVER(‘MSSQL’)
Record RECORD
c LONG
. .
Ret LONG
Out STRING(10)
CODE
BIND(‘RetCode’, Ret)
BIND(‘Out’, Out)
CallProc(‘&RetCode = CALL StoredProcTest(‘’1'’,&Out)’)
MESSAGE(Return value of StoredProcTest =’ & Ret)
MESSAGE(Output parameter of StoredProcTest =’ & Out)
CallProc PROCEDURE(Str)
CODE
MyFile{PROP:SQL} = Str
Note: The above example shows how to return an output parameter.
For a more specific example tailored to MSSQL, refer to the MSSQL
Accelerator chapter.
This is a C5.5 egg-sample I think.
--
--
Kind regards,
James Cooke
http://www.clarionfoundry.com - a concise technical reference for Clarion
Programmers
http://63.99.156.24/
=========================================
"Kelly Orr" <ke...@goldtechservices.com> wrote in message
news:3D333B45...@goldtechservices.com...
Are you trying to return data from the stored procedure like an average or
some other calculated amount or are you more interested in getting back a
return code from the SP like a success or failure indicator?
Regards
Parker
I don't know whether you're getting an error or just not getting the result,
but some things to consider which may help in getting to the answer are:
1. Whereever you need to pass strings in a sql statement, use <39> instead
of ' - I have found this very useful.
2. Try calling the procedure straight - not passing the statement to a proc:
MyFile{prop:sql} = '&RetCode = CALL StoredProcTest(<39>1<39>,&Out)'
! then check for errorcode() = 90
if errorcode() = 90 then stop('SQL error occurred: ' & fileerrorcode() & ' '
& fileerror()).
! Run a trace on the driver you're using, and see if any errors show up
there.
3. These may all be obvious, but also check that if you call the procedure
directly in the backend, that it does in fact return something - preferrably
the desired result! (Use Sql Query Analyser if you're using MSSQL!).
Just a few thoughts!
Hope it helps!
--
----------------------------
Lesley Dean
CapeSoft
Web: www.capesoft.com
"Kelly Orr" <ke...@goldtechservices.com> wrote in message
news:3D333B45...@goldtechservices.com...
I have no problems doing it the old way where you issue a next to get the result set. I have modified the proc and it now has an output variable for the results instead of issueing a select to retrieve them. The proc works if called by another one, but if I try to do it the new way using an output variable, it gives a syntax error in SQL server. This is the way I am doing it:
BIND('DOG_ID',dog:ID)
IF ERRORCODE()
IF ERRORCODE() = 90
MESSAGE(FILEERRORCODE() & ':'
& FILEERROR())
ELSE
MESSAGE(ERRORCODE() & ':' &
ERROR())
END
END
BIND('EXPENSES',loc:Expenses)
IF ERRORCODE()
IF ERRORCODE() = 90
MESSAGE(FILEERRORCODE() & ':'
& FILEERROR())
ELSE
MESSAGE(ERRORCODE() & ':' &
ERROR())
END
END
SPFile{PROP:SQL} = 'CALL USP_DOG_EXPENSES (&DOG_ID,&EXPENSES)'
When the last statement is executed, the error in the trace/log file
is
Executing Statement 13d51a8:CALL USP_DOG_EXPENSES (&DOG_ID,&EXPENSES)
Error Occurred: 37000[Microsoft][ODBC SQL Server Driver][SQL Server]Line
1: Incorrect syntax near '&'.
Time Taken:0.00 secs
SET_PROPERTY(SPFILE 2) File Error: Line 1: Incorrect syntax near
'&'. Time Taken: 0.00 secs
It does not look like the bind is working, however I get no errors on the bind. I have also tried it with the [IN] and [OUT] with the variable names and there was no difference.
I am also trying to achieve this at the moment and I am getting exactly
the same error as you are. If you or anybody else can find a solution
to this I would be very grateful.
Many thanks
Lee.
"Kelly Orr" <ke...@goldtechservices.com> wrote in message news:3D341E9D...@goldtechservices.com...
Here's the procedure. I know the proc works becuase I created another dummy procedure to call it like I want the Clarion app to call it.
CREATE PROCEDURE USP_DOG_EXPENSES
@DOG_ID INT,
@EXPENSES DECIMAL(9,2) OUTPUT
AS
SELECT @EXPENSES = SUM(CostOfVisit)
FROM VetVisits
WHERE DogID = @DOG_ID
GO
Before you say anything about using a DECIMAL variable as a return, I have also done this using a string just in case that was the problem, and there was no difference. :)
Lesley Dean wrote:
Hi Kelly, and Lee, I have to admit I have not done enough of these scenarios to call it good experience! I was hoping someone else would offer a solution! I only have one procedure returning an output variable. This procedure does not have any input variable. My thoughts at this point are that possibly the procedure itself is expecting a different parameter or syntax. What does your CREATE PROCEDURE script look like - ie, the definition of your procedure? I have not included my working procedure here, as it does in fact return an error in the trace but not in my error check, but it is returning the desired result! I think I could improve on it a bit though! The other question was, if you call it with a specific value for the input parameter, does it still return an error? ie. SPFile{PROP:SQL} = 'CALL USP_DOG_EXPENSES (1234,&EXPENSES)' HTH--
----------------------------
Lesley Dean
CapeSoft
Web: www.capesoft.com
"Kelly Orr" <ke...@goldtechservices.com> wrote in message news:3D341E9D...@goldtechservices.com...Hi Lesley,
Mix in the proper amount of single quotes and you should be in business!
SPFile{PROP:SQL} = 'CALL USP_DOG_EXPENSES ('''&DOG_ID''',&EXPENSES)'
You could also use the previously suggested <39> to make the text a little
more readable.
Regards
Parker
Kelly Orr <ke...@goldtechservices.com> wrote:
>
>--------------D5E770C6A5CF75B02F4BFF35
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
Do you have a working example you could show us? Your suggestion doesn't
seem to work in my tests. If you have a working example you could show us,
that would be greatly appretiated!
Thanks.
--
----------------------------
Lesley Dean
CapeSoft
Web: www.capesoft.com
"Parker MacDonald" <Parker_M...@uccb.ns.ca> wrote in message
news:3d39870c...@news.softvelocity.com...
First off I made a typo in the code change I suggested it should have been:
SPFile{PROP:SQL} = 'CALL USP_DOG_EXPENSES ('''&DOG_ID&''',&EXPENSES)'
Notice the & I left out after DOG_ID
Now for my "working example"
The stored proc looks like this:
CREATE proc usp_sect_enrollment
@acad_year int,
@acad_session char(2),
@course_no varchar(16),
@section_no int,
@enrollment int OUTPUT
AS
select @enrollment = count(*)
from dbo.stu_acad_detail with(index=by_cor_section)
where acad_year = @acad_year and
acad_session = @acad_session and
course_no = @course_no and
section_no = @section_no and
course_type = 'R' and
course_status = 'A'
I pass the year,session,course number and course section to the SP and get
back the number of students enrolled.
The clarion code looks like this:
BIND('OUT',LOC:ENROLLMENT)
SECTIONS{Prop:SQL}='CALL usp_Sect_Enrollment ('''&SEC:ACAD_YR&''',' |
& ''''&SEC:ACAD_SESSION&''','|
& ''''&SEC:COURSE_NO&''',' |
& ''''&SEC:SECTION_NO&''',' |
& '&OUT)'
IF ERRORCODE()
message(error() & errorfile())
END
UNBIND('OUT')
now LOC:ENROLLMENT has the value I need
All of the quotes are single quotes.
Hope this helps a little
Regards
Parker