mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-31 11:42:41 +08:00
support view trigger producer function
This commit is contained in:
@ -0,0 +1,7 @@
|
||||
package ai.chat2db.server.domain.core.util;
|
||||
|
||||
public class H2Functions {
|
||||
public static String keyGeneratorFunction(String tableName) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package ai.chat2db.server.domain.core.util;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.h2.api.Trigger;
|
||||
|
||||
public class H2Triggers implements Trigger {
|
||||
|
||||
@Override
|
||||
public void init(Connection conn, String schemaName, String triggerName,
|
||||
String tableName, boolean before, int type) throws SQLException {
|
||||
// Initialization logic, if needed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fire(Connection conn, Object[] oldRow, Object[] newRow)
|
||||
throws SQLException {
|
||||
// This method is called when the trigger is executed.
|
||||
// In this example, let's simply print the new values when a row is inserted.
|
||||
if (newRow != null) {
|
||||
System.out.println("New Row Inserted: " + Arrays.toString(newRow));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SQLException {
|
||||
// Cleanup logic, if needed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() throws SQLException {
|
||||
// Logic to execute when the trigger is dropped/removed.
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user