Fork me on GitHub
#sql
<
2019-04-17
>
Drew Verlee02:04:57

What is a good use case for a database trigger?

seancorfield02:04:45

@drewverlee Some context for your question?

seancorfield02:04:42

I haven't used triggers for a very, very long time. I'm not sure I even remember what I used them for, way back when...

Drew Verlee03:04:21

@seancorfield the context is that we some functionality of our system has a dependency on the database having certain relationships and in an effort to do some performance testing we would like to clone those database relationships. I'm able to build something that can insert data into our database to mimic those relationships, but i can't think of a way to even capture what effect the current triggers will have. e.g if i insert a parent bc all children has a fk dep on parent then a trigger might give that child a parent as well.

seancorfield03:04:49

@drewverlee So, it's the triggers in the current system that are already causing you pain?

usasigain15:04:51

Hi! Starting to work with a Sql Server data base. We are able to query selects but don’t know how to call to a stored procedure, we have been trying with clojure.java.jdbc/db-do-commands and clojure.java.jdbc/db-do-prepared but we haven’t been able to get anything. Could someone help us? Thank you!

seancorfield16:04:39

@usasigain You should be able to use jdbc/query for that, with EXEC schema.dbo.procname arg1 arg2 as the SQL string I think.

seancorfield16:04:36

clojure.java.jdbc simply passes the SQL string to the JDBC driver, after creating a PreparedStatement and setting any parameters.

seancorfield16:04:31

Is the problem that Microsoft's JDBC driver doesn't support EXEC in a PreparedStatement? Are you getting an error?

usasigain16:04:08

@seancorfield ou! it works, I think we tried this at the beginning but maybe with the wrong string… And then we were over thinking it. Calling a simple Stored Procedure with no parameters this way works for us: (jdbc/query spec ["EXEC schema.dbo.procname"]) Thank you for your quick response!

✔️ 12