I have a stored procured in SQL and I need to re-write it for ORACLE 8.
I am new in Oracle and still learning.
Please Help. Thanks a lot.
CREATE PROCEDURE SearchProductCategory
@Product as varchar(50),
@SearchTypeProd as int,
@Category as varchar(50),
@SearchTypeCat as int
AS
declare @SQL as varchar(8000)
begin
set @SQL='SELECT Name, Category
FROM Product
WHERE Deleted =0 '
if @Product<>''
begin
if @SearchTypeProd=1 -- starts with
begin
set @SQL= @SQL + ' and Name like ''' + @Product + '%'''
end
if @SearchTypeProd=2 -- ends with
begin
set @SQL= @SQL + ' and Name like ''%' + @Product + ''''
end
if @SearchTypeProd=3 -- contain
begin
set @SQL= @SQL + ' and Name like ''%' + @Product + '%'''
end
if @SearchTypeProd=4 -- Equal
begin
set @SQL= @SQL + ' and Name = ''' + @Product + ''''
end
end
if @Category<>''
begin
if @SearchTypeCat=1 -- starts with
begin
set @SQL= @SQL + ' and Category like ''' + @Category + '%'''
end
if @SearchTypeCat=2 -- ends with
begin
set @SQL= @SQL + ' and Category like ''%' + @Category + ''''
end
if @SearchTypeCat=3 -- contain
begin
set @SQL= @SQL + ' and Category like ''%' + @Category + '%'''
end
if @SearchTypeCat=4 -- Equal
begin
set @SQL= @SQL + ' and Category = ''' + @Category + ''''
end
end
--print(@SQL)
exec(@SQL)
end
Thanks again.
I am new in Oracle and still learning.
Please Help. Thanks a lot.
CREATE PROCEDURE SearchProductCategory
@Product as varchar(50),
@SearchTypeProd as int,
@Category as varchar(50),
@SearchTypeCat as int
AS
declare @SQL as varchar(8000)
begin
set @SQL='SELECT Name, Category
FROM Product
WHERE Deleted =0 '
if @Product<>''
begin
if @SearchTypeProd=1 -- starts with
begin
set @SQL= @SQL + ' and Name like ''' + @Product + '%'''
end
if @SearchTypeProd=2 -- ends with
begin
set @SQL= @SQL + ' and Name like ''%' + @Product + ''''
end
if @SearchTypeProd=3 -- contain
begin
set @SQL= @SQL + ' and Name like ''%' + @Product + '%'''
end
if @SearchTypeProd=4 -- Equal
begin
set @SQL= @SQL + ' and Name = ''' + @Product + ''''
end
end
if @Category<>''
begin
if @SearchTypeCat=1 -- starts with
begin
set @SQL= @SQL + ' and Category like ''' + @Category + '%'''
end
if @SearchTypeCat=2 -- ends with
begin
set @SQL= @SQL + ' and Category like ''%' + @Category + ''''
end
if @SearchTypeCat=3 -- contain
begin
set @SQL= @SQL + ' and Category like ''%' + @Category + '%'''
end
if @SearchTypeCat=4 -- Equal
begin
set @SQL= @SQL + ' and Category = ''' + @Category + ''''
end
end
--print(@SQL)
exec(@SQL)
end
Thanks again.