问题
I have a procedure to insert values into one table and update rows of another table. The procedure compiled without any errors. If I manually call it within PL/SQL codes, the tables are updated.
CREATE OR REPLACE PROCEDURE payment_update
(bId IN number, pType IN varchar2, pAmt IN number )
AS
BEGIN
INSERT INTO payment
VALUES (PID_SEQ.NEXTVAL,
bId,
pType,
(SELECT CURRENT_DATE FROM DUAL),
pAmt);
UPDATE booking
SET payment_status = 'FP',
paid = pAmt
WHERE booking_id = bId;
END;
/
I am trying to call this stored procedure in a Java class, through the click of a button. The user enters values into a text field of the GUI frame, those values need to be sent to the stored procedure.
This is my Java code -
private void payButtonActionPerformed(java.awt.event.ActionEvent evt) {
int i = unpaidJTable.getSelectedRow();
int bookingId =Integer.parseInt(bIdText.getText());
String pType = pTypeText.getText();
double pAmt = Double.parseDouble(pAmtText.getText());
CallableStatement callableStatement = null;
String paymentUpdateRecord = "{call payment_update(?, ?, ?)}";
try{
callableStatement = conn.prepareCall(paymentUpdateRecord);
callableStatement.setInt(1, bookingId);
callableStatement.setString(2, pType);
callableStatement.setDouble(3, pAmt);
callableStatement.executeUpdate();
conn.commit();
System.out.println("Successfully updated!");
}
catch(SQLException e){
System.out.println(e.getMessage());
}
On clicking this button, I get an error pasted above as the question. Can someone please help me out? I can't figure out what I need to declare.
回答1:
I faced same problem and figured out the solution. Actually, When I searched for answer, other post mentioned that 'there could be permission issue'. Which is quit the case here. As a workaround or solution need to do following: -Drop you SP. -Recreate SP with Parameter (i.e. your final SP)
You might have created SP first and later did some changes in Parameter section. See if this helps. However, it did in my case.
回答2:
PLS-00201: identifier 'PROC_NAME' must be declared ORA-06550: line 1, column 7:
I was able to resolve the issue by creating synonym for the procedure.
来源:https://stackoverflow.com/questions/43199043/ora-06550-line-1-column-7-pls-00201-identifier-payment-update-must-be-decl