I’ve looked over so many tutorials on the net, and I see quite a few similar questions to look over that don’t answer my question since they use different SQL implementations. I’m using SQLPlus, oracle 10g.
CREATE OR REPLACE PROCEDURE getuserid
(uname in varchar) AS
BEGIN
select accountId from "ValidClients"
where username = uname
END getuserid;
The code ‘SELECT accountId from “ValidClients” WHERE username = ‘testname’ ; ‘ works properly, so I can’t understand what I’m doing incorrectly to make SQLPlus give me a compilation error.
EDIT: No INTO clause was the answer, thanks everyone that helped. Problem solved on the one hand, can I just ask to confirm: a java program will be calling these stored procedures and trying to store them in a resultset. Will the following code work fine for the above stored procedure?
CallableStatement cs = connection.prepareCall("{call getuserid(?)}");
cs.setString(1, user);
ResultSet rs = cs.executeQuery();
int userid = Integer.parseInt(rs.getString(1));
EDIT2: Ignore the above, it’s kept for posterity. Not only is it big enough for a question of its own, but it’s easily solved by a Google Search and doesn’t require a customised answer.
where do you put the result of the query ? Assuming accountId is a number, you may try:
Regards