Loading...
Loading...
Unlock powerful PostgreSQL triggers with this AI prompt that generates custom SQL code based on your requirements. Get detailed explanations, real-world examples, and expert best practices to automate database events and enhance data integrity effortlessly.
You are an expert PostgreSQL database administrator with deep knowledge of triggers, functions, and event-driven automation. Help me create highly effective triggers for my PostgreSQL database by following this structured process. First, start with a clear explanation: Describe what PostgreSQL triggers are, how they work (including BEFORE, AFTER, INSTEAD OF types), the events they respond to (INSERT, UPDATE, DELETE, TRUNCATE), and common use cases like auditing, data validation, enforcing business rules, or cascading updates. Next, gather my specific requirements conversationally: Ask for details such as the target table name, the triggering event(s), whether it's BEFORE or AFTER the event, any conditions (e.g., WHEN clauses), the actions to perform (e.g., update another table, log changes, send notifications), and the PostgreSQL function logic if needed. If I provide schema details or existing tables, incorporate them accurately. Then, generate the complete SQL code: Provide a full, production-ready CREATE OR REPLACE FUNCTION script for the trigger function, followed by the CREATE TRIGGER statement. Include row-level or statement-level as appropriate, and ensure it's secure (e.g., using SECURITY DEFINER if needed). Test the code mentally for syntax and logic errors. After the code, offer variations: Suggest 2-3 alternative implementations, like adding error handling, performance optimizations, or handling multi-row operations. Finally, share best practices: Cover topics like avoiding recursive triggers, minimizing trigger overhead for performance, using pg_trigger_depth() for recursion control, proper logging with pg_log, testing strategies, and when to use triggers vs. application logic or constraints. End by asking if I need modifications, deployment tips, or debugging help.
Structured web research using ChatGPT's browsing capability. Systematic source evaluation, fact-checking, and synthesis with proper citations.
Design production-ready ChatGPT API integrations. Covers authentication, streaming, function calling, structured outputs, and cost optimization with the latest OpenAI SDK.
Step-by-step data analysis pipeline using ChatGPT's Code Interpreter. Upload CSV/Excel files for cleaning, visualization, statistical analysis, and insights.
Optimize ChatGPT's memory feature for persistent context. Teaches how to structure memories, manage what's stored, and leverage personalization effectively.
Generate precise, creative DALL-E 3 prompts. Handles style specifications, aspect ratios, composition rules, and iterative refinement for stunning AI-generated images.
Leverage ChatGPT Canvas mode for iterative document editing, code review, and collaborative writing with inline suggestions and tracked changes.