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
 General SQL Server Forums
 New to SQL Server Programming
 Problem with Stored Procedure

Author  Topic 

john20
Starting Member

30 Posts

Posted - 2008-08-18 : 06:05:57
Hi All,

I am creating SP using toad editor and it is giving me some syntex error as i am very new to toad.
Procedure syntex is:

CREATE PROCEDURE [dbo].[AdvSearch]
@UserID int,
@SearchStr nvarchar(50)
AS
BEGIN


SET NOCOUNT ON;


Select
d.*
From
User d inner join
Permission a on d.UserID = a.UserID

Where
d.Name like @SearchStr + '%'
AND
a.ID IN (Select ID From Children Where ChildID=@UserID )
AND
a.See > 0

END

can you please tell me where i need to make changes.

Thanks in advance

-john

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-18 : 06:09:38
quote:
Originally posted by john20

Hi All,

I am creating SP using toad editor and it is giving me some syntex error as i am very new to toad.
Procedure syntex is:

CREATE PROCEDURE [dbo].[AdvSearch]
@UserID int,
@SearchStr nvarchar(50)
AS
BEGIN


SET NOCOUNT ON;


Select
d.*
From
[User] d inner join
Permission a on d.UserID = a.UserID

Where
d.Name like @SearchStr + '%'
AND
a.ID IN (Select ID From Children Where ChildID=@UserID )
AND
a.See > 0

END

can you please tell me where i need to make changes.

Thanks in advance

-john


user is a keyword. so use it within []
Go to Top of Page

john20
Starting Member

30 Posts

Posted - 2008-08-18 : 06:15:31
Hi Thanks for your reply.

did the changes it is giving me error on line 1.

Below are the errors:

ERROR line 1, col 18, ending_line 1, ending_col 18, Found '[', Invalid identifier: [

ERROR line 1, col 19, ending_line 1, ending_col 21, Found 'dbo', Expecting: . -or- TIMESTAMP -or- WRAPPED -or- ( -or- AUTHID -or- AS IS

-john
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-18 : 06:21:02
quote:
Originally posted by john20

Hi Thanks for your reply.

did the changes it is giving me error on line 1.

Below are the errors:

ERROR line 1, col 18, ending_line 1, ending_col 18, Found '[', Invalid identifier: [

ERROR line 1, col 19, ending_line 1, ending_col 21, Found 'dbo', Expecting: . -or- TIMESTAMP -or- WRAPPED -or- ( -or- AUTHID -or- AS IS

-john


Not sure about Toad but above code is parsing fine for me.
Go to Top of Page

john20
Starting Member

30 Posts

Posted - 2008-08-18 : 06:29:53
Hi thanks for replying.

I have changed the code now it is giving below error:

PLS-00201: identifier 'NVARCHAR' must be declared

how to declare that?

below is the code:

CREATE OR REPLACE PROCEDURE UserPerm (UserID NUMBER,Searchstr nvarchar)

IS

BEGIN

Select
d.*
From
Tree d inner join
TreeACL a on d.DataID = a.DataID
Where
d.Name like SearchStr + '%'
AND
a.RightID IN (Select ID From Children Where ChildID=UserID )
AND
a.See > 0;


END UserPerm;

/

-john
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-18 : 06:39:08
Are you using SQL Server?
If you use ORACLE, post your questions at www.orafaq.com

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-18 : 06:40:50
quote:
Originally posted by john20

Hi thanks for replying.

I have changed the code now it is giving below error:

PLS-00201: identifier 'NVARCHAR' must be declared

how to declare that?

below is the code:

CREATE OR REPLACE PROCEDURE UserPerm (UserID NUMBER,Searchstr nvarchar)

IS

BEGIN

Select
d.*
From
Tree d inner join
TreeACL a on d.DataID = a.DataID
Where
d.Name like SearchStr + '%'
AND
a.RightID IN (Select ID From Children Where ChildID=UserID )
AND
a.See > 0;


END UserPerm;

/

-john



1.use int or float/real instead of number
2.specify a length for nvarchar
Go to Top of Page
   

- Advertisement -