
Stored Procedures
This one covers the fundamentals of writing stored procedures, functions, and triggers across PostgreSQL and MySQL. You get examples for scalar functions, multi-step procedures with error handling, and trigger implementations for audit trails and data validation. The quick start shows a straightforward calculation function, and the reference guides walk through progressively complex scenarios. It's practical if you're moving business logic into the database layer or need reusable routines that multiple applications can call. The coverage is solid on the basics, though you'll want to supplement with database-specific docs for advanced features like cursor handling or dynamic SQL.
- skills.sh installs
- 457
- GitHub stars
- 379
- last updated
- Aug 21, 2026
Install
$ npx -y skills add aj-geddes/useful-ai-prompts --skill stored-procedures --agent claude-codeInstalls into .claude/skills of the current project.
Files
Stored Procedures & Functions
Table of Contents
Overview
Implement stored procedures, functions, and triggers for business logic, data validation, and performance optimization. Covers procedure design, error handling, and performance considerations.
When to Use
- Business logic encapsulation
- Complex multi-step operations
- Data validation and constraints
- Audit trail maintenance
- Performance optimization
- Code reusability across applications
- Trigger-based automation
Quick Start
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;
Sponsors
Details
- Repository
- github.com/aj-geddes/useful-ai-prompts
- Categories
- Backend & APIs, AI & Agent Building, Databases
- First seen
- Jun 3, 2026
More from aj-geddes/useful-ai-prompts
All 258- Autoscaling Configuration456
- Profiling Optimization456
- Cpu Profiling455
- Security Documentation455
- Frontend Routing454
- Load Balancer Setup454
- Property Based Testing454
- Aws Rds Database453
- Log Aggregation453
- Documentation Site Setup452
- Monorepo Management451
- Retrospective Facilitation451
- Api Filtering Sorting450
- Cloud Migration Planning450
- Design Handoff450
- Git Hooks Setup450
- Cloud Storage Optimization449
- Performance Regression Debugging449
- Secrets Management449
- Configuration Management448
- Alert Management447
- Cloud Cost Management447
- Troubleshooting Guide447
- Vue Application Structure447