stored-procedures by aj-geddes/useful-ai-prompts
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill stored-procedures实现存储过程、函数和触发器,用于业务逻辑、数据验证和性能优化。涵盖过程设计、错误处理和性能考量。
PostgreSQL - 标量函数:
-- 创建返回单个值的函数
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;
-- 在查询中使用
SELECT id, subtotal, calculate_order_total(subtotal, 0.08, 10) as total
FROM orders;
-- 或在应用程序代码中使用
SELECT * FROM orders
WHERE calculate_order_total(subtotal, 0.08, 10) > 100;
references/ 目录下的详细实现:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 指南 | 内容 |
|---|---|
| 简单函数 | 简单函数 |
| 存储过程 | 存储过程 |
| 简单过程 | 简单过程 |
| 带错误处理的复杂过程 | 带错误处理的复杂过程 |
| PostgreSQL 触发器 | PostgreSQL 触发器 |
| MySQL 触发器 | MySQL 触发器 |
每周安装数
103
仓库
GitHub 星标数
116
首次出现
Jan 21, 2026
安全审计
安装于
opencode85
gemini-cli83
codex82
claude-code81
cursor78
github-copilot70
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 |
Weekly Installs
103
Repository
GitHub Stars
116
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode85
gemini-cli83
codex82
claude-code81
cursor78
github-copilot70
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
36,300 周安装