-
-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create trigger Oracle Missing IN or OUT #228
Comments
I don't use Oracle and don't have access to it to test anything -- the error is coming from the underlying JDBC driver (not One thing you might try is to remove the Other than that, I have no idea (and I cannot provide support for Oracle-related issues -- you'll need to ask someone who uses Oracle, perhaps in the #sql channel on the Clojurians Slack -- you can sign up at http://clojurians.net ). |
I found the solution When using a 10g (or higher) Oracle JDBC driver, attempts to create a trigger fail when the syntax for doing so contains :OLD (or :NEW) types of references. The following exception is thrown:
CAUSEThis is expected behavior when using a PreparedStatement or a CallableStatement. Beginning in the 10g drivers, a feature was added that allows binding parameters by name. As a consequence of this, strings such as ":old" are interpreted by the JDBC driver as bind variables. Both PreparedStatement and CallableStatement check in advance that values have been provided for all bind variables. With no value provided for ":old", since it's not intended in this context to be a bind variable, the error is thrown. SolutionUse Statement rather than PreparedStatement or CallableStatement. (with-open [con (jdbc/get-connection @datasource)]
(let [stmt (prepare/statement con)]
(.executeUpdate stmt (str "CREATE OR REPLACE EDITIONABLE TRIGGER T_TEMP_TRIGGER
BEFORE INSERT ON T_TEMP
REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW
DECLARE
BEGIN
IF inserting THEN
IF :new.id IS NULL THEN
SELECT SEQ_TEMP.nextval
INTO :new.id
FROM dual;
END IF;
END IF;
END;
/"))))
=> 0 |
I'll reopen this and add a Tips & Tricks note about it. Could you confirm you can use |
Documentation updated on develop. Don't forget to call (with-open [con (jdbc/get-connection @datasource)
stmt (prepare/statement con)]
(jdbc/execute! stmt ["CREATE OR REPLACE EDITIONABLE TRIGGER ..."])) |
When I try execute a stmt Im facing SQLException Missing IN or OUT parameter at index:: 1
The text was updated successfully, but these errors were encountered: