cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with Stored procedure

Former Member
0 Kudos

Hi,

I am trying to create a stored procedure and am trying to execute it in 2 different ways.. One works and the other throws a syntax error.

Can you please explain why the first one has issues and the second one works fine? Also please suggest what the correction in first one should be.

Accepted Solutions (1)

Accepted Solutions (1)

justin_molenaur2
Contributor
0 Kudos

I think you are trying to compare a table type in you where clause, which may be incompatible. Can you try using a scalar variable instead? See sample here.

varYear = VARCHAR(8);

BEGIN

SELECT YEAR(CURRENT_DATE)

INTO varYear

FROM DUMMY;

<REST OF LOGIC>

Regards,

Justin

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks guys. Issue resolved.

former_member182302
Active Contributor
0 Kudos

Hi Sammy,

You cannot compare with Table Variable in your WHERE Clause, instead you have to use SCALAR Variable

As Justin rightly mentioned you should SCALAR Variable.


DECLARE var1 INTEGER;

SELECT YEAR(CURRENT_DATE) INTO var1 FROM DUMMY;

YEAR1 = select "YEAR","HIKE" from HIKE_YEAR

WHERE YEAR = :var1;

Regards,

Krishna Tangudu