From aj-geddes-useful-ai-prompts-4
Implement stored procedures, functions, and triggers for encapsulating business logic, data validation, and performance optimization. Covers design, error handling, and best practices.
How this skill is triggered — by the user, by Claude, or both
Slash command
/aj-geddes-useful-ai-prompts-4:stored-proceduresThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Overview](#overview)
Implement stored procedures, functions, and triggers for business logic, data validation, and performance optimization. Covers procedure design, error handling, and performance considerations.
PostgreSQL - Scalar Function:
-- Create function returning single value
CREATE OR REPLACE FUNCTION calculate_order_total(
p_subtotal DECIMAL,
p_tax_rate DECIMAL,
p_shipping DECIMAL
)
RETURNS DECIMAL AS $$
BEGIN
RETURN ROUND((p_subtotal * (1 + p_tax_rate) + p_shipping)::NUMERIC, 2);
END;
$$ LANGUAGE plpgsql IMMUTABLE;
-- Use in queries
SELECT id, subtotal, calculate_order_total(subtotal, 0.08, 10) as total
FROM orders;
-- Or in application code
SELECT * FROM orders
WHERE calculate_order_total(subtotal, 0.08, 10) > 100;
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Simple Functions | Simple Functions |
| Stored Procedures | Stored Procedures |
| Simple Procedures | Simple Procedures |
| Complex Procedures with Error Handling | Complex Procedures with Error Handling |
| PostgreSQL Triggers | PostgreSQL Triggers |
| MySQL Triggers | MySQL Triggers |
npx claudepluginhub joshuarweaver/cascade-code-languages-misc-1 --plugin aj-geddes-useful-ai-prompts-4Generates, validates, and deploys stored procedures, functions, and triggers for PostgreSQL, MySQL, SQL Server with error handling and transactions. Trigger on 'generate stored procedure' or similar.
Guides SAP HANA SQLScript development for procedures, table functions, exception handling, cursors, performance optimization, and AMDP integration.
Optimizes SQL queries, designs schemas, and troubleshoots performance issues using window functions, CTEs, indexing, and EXPLAIN plan analysis. Supports PostgreSQL, MySQL, SQL Server, and Oracle.