SQL Syntax Error Exception: ORA-00928: SELECT keyword not found

Asked

Viewed 1,138 times

2

I have this message while trying to execute a Stored Procedure created on the Oracle:

java.sql.Sqlsyntaxerrorexception: ORA-00928: SELECT keyword not found

at oracle.jdbc.driver.T4cttioer.processError(T4cttioer.java:447) at oracle.jdbc.driver.T4cttioer.processError(T4cttioer.java:396) at oracle.jdbc.driver.T4c8oall.processError(T4c8oall.java:951) at oracle.jdbc.driver.T4cttifun.receive(T4cttifun.java:513) at oracle.jdbc.driver.T4cttifun.doRPC(T4cttifun.java:227) at oracle.jdbc.driver.T4c8oall.doOLL(T4c8oall.java:531) at oracle.jdbc.driver.T4ccallablestatement.doOall8(T4ccallablestatement.java:205) at oracle.jdbc.driver.T4ccallablestatement.executeForRows(T4ccallablestatement.java:1043) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(Oraclestatement.java:1336) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(Oraclepreparedstatement.java:3613) at oracle.jdbc.driver.OraclePreparedStatement.execute(Oraclepreparedstatement.java:3714) at oracle.jdbc.driver.OracleCallableStatement.execute(Oraclecallablestatement.java:4755) at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(Oraclepreparedstatementwrapper.java:1378) at unidade3.ClienteApp.inserirSP(Customersapp.java:71) at 3.ClienteApp.main(Clienteapp.java:192)


create or replace PROCEDURE SP_INSERIRCLIENTE 
(
  CPF IN INTEGER 
, NOME IN VARCHAR2 
, EMAIL IN VARCHAR2 
) AS 
BEGIN
  INSERT INTO CLIENTE VALUES(CPF, NOME, EMAIL);
END SP_INSERIRCLIENTE;

2 answers

0

I believe your problem lies in the creation syntax of Procedure. Take a look at that link talking about different ways to use a proc and tries to create like this:

create procedure SP_INSERIRCLIENTE 
@CPF integer,
@NOME varchar(255),
EMAIL varchar(255)
begin
   INSERT INTO CLIENTE (CPF, NOME, EMAIL)
   VALUES(@CPF, @NOME, @EMAIL);
end;

Analyzing the answer better I realized that it is a Procedure in oracle, so I researched the structure suggested in devmedia and rode as follows:

create or replace procedure SP_INSERIRCLIENTE 
(CPF_PARAM IN INTEGER, NOME_PARAM IN VARCHAR2, EMAIL_PARAM IN VARCHAR2)
begin
   INSERT INTO CLIENTE (CPF, NOME, EMAIL)
   VALUES(CPF_PARAM, NOME_PARAM, EMAIL_PARAM);
end

I basically removed the as which existed in the declaration of proc original and named the table fields cliente in the Insert


NOTE: always try to add as much useful information as possible to the question (of course, without letting the question turn into a book =p) and add the tags concerning the question.

  • I made the change, but when I withdraw the "as" compile error occurs.

0

I think in your case the solution is simple:

CREATE OR REPLACE PROCEDURE SP_INSERIRCLIENTE 
(
        CPF     IN INTEGER
    ,   NOME    IN VARCHAR2
    ,   EMAIL   IN VARCHAR2 
) IS 
BEGIN
    INSERT INTO CLIENTE VALUES(CPF, NOME, EMAIL);
END;
/
  • Good morning guys! Still the same mistake.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.