2

I arrive from years with Oracle plsql. Now I'm trying vb.net

I created a function that return a char value, so written:

ALTER FUNCTION [abc].[GET_PERSON_TYPE]
( 
@person_national_id CHAR(16)
)
RETURNS CHAR(1) AS
BEGIN 

declare @person_type CHAR(1)

SET @person_national_id = (
                SELECT p_type
                FROM abc.persons
                WHERE national_id = @person_national_id
                )

RETURN @person_national_id

END

The question: I will create a function get_type(...) in vb.net that calls the tsql function written above... how can I call the tsql function [abc].[GET_PERSON_TYPE] in vb.net function get_type(...) function?

Thanks a lot.

gbn
  • 422,506
  • 82
  • 585
  • 676
Geltrude
  • 1,093
  • 3
  • 17
  • 35
  • See here for a good discussion of similar question: http://stackoverflow.com/questions/1300052/how-can-i-call-a-sqlserver-function-from-vb-netor-c-is-there-some-syntax-lik – Judah Sali Mar 23 '11 at 16:33

1 Answers1

1

I don't think you can call the function directly but you can use it in a select statement.

select [abc].[GET_PERSON_TYPE]('abcde')
Mikael Eriksson
  • 136,425
  • 22
  • 210
  • 281
  • You can `EXEC` scalar functions. – Martin Smith Mar 23 '11 at 14:52
  • @Martin - Did not know that. So basically you could call the function the same way you call a stored procedure from the client. I know nothing about vb.net but I tested in Delphi and it works fine to call the function in the same way as you would execute a stored procedure. – Mikael Eriksson Mar 23 '11 at 15:33