Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 User defined function inside SELECT statement

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-06-03 : 08:23:28
Bhaggs writes "Hi,
I have been doing pl-sql programming using oracle for last 3 years and have recently started working on Transact SQL programming.

I want to replicate following scenario as seen in oracle.

Usign Oracle(This is a simple example):

Select
Emp.Emp_Code,Emp.sal,
Oracle_Function('Emp_Personal','Status_Desc',Emp.status) "Status"
from Emp

Note: Emp_Personal is my another table having 'Salary' field.This can vary.

"Oracle_Function" is my Generic user defined function which returns a VARCHAR Output based on Dynamic SQL generated.

Eg: Select Status_Desc from Emp_Personal Where Status = @Parameter

My output is as under:

Emp_Code Sal Status
100 1200 Is not Valid
200 2100 Is Valid
300 2300 Is Valid
400 800 Is not Valid


Now, I want to do the same thing in sql server.I tried using dynamic sql in functions but somehow I can simulate above scenario.

Need help uergently.

Regards,
BSM"

mtomeo
Starting Member

30 Posts

Posted - 2003-06-03 : 11:01:03
Look up "User Defined Functions" in BOL. SQL Server supports UDF's also. Just as in Oracle, once you create the UDF, you can use it the same way...the same way you would use any System Defined Function. Basically, assuming you've created the UDF correctly, your syntax is the same as Oracle when you need to reference it.

It sounds like you need help replicating your Oracle UDF in SQL Server. Post your Oracle function if you need help re-writing that in Transact-SQL.



Go to Top of Page
   

- Advertisement -