I'm just getting my feet wet with PL/SQL in the MS SQL Server enviroment and have been strapped for figuring out why I can't get any PL/SQL scripts to run.
I have a table named Clients with numerous fields but one named clientID and in learning have generated the following PL/SQL script from a few tutorials I've flipped through.
CURSOR c1 IS
SELECT * FROM Clients;
For rec In c1 Loop
IF rec.clientID = '500' THEN
From everything I've read thus far it should work and output 500 for as many clientID's that exist with the clientID of 500....
This is the error I get.
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'CURSOR'.
Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'For'.
Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'THEN'.
I've even tried to dumb it down to:
a := '500';
SELECT * FROM Clients WHERE clientID = a;
Which still does not execute, even when defining it with VARChAR or another datatype and := '500' it throws a "VARCHAR is not a defined CURSOR" or something like that... with the a := '500' PL/SQL script I get the following:
Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near ':'.
I'm just trying to learn PL/SQL in this enviroment before I actually have to start using it @ my current job. Any help will be greatly appreciated.