Postgresql c dao update last row by date
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8/postgresql-c-dao-update-last-row-by-date
Generates SQL update scripts using Common Table Expressions (CTE) and corresponding C# DAO code using IDbConnection to update the runId of the most recent record for a specific user, including logic for filtering by Unix timestamp dates.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill postgresql-c-dao-update-last-row-by-dateAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.7 KB, 503 tokens by cl100k_base, as published. Nobody here has run it
PostgreSQL C# DAO Update Last Row by Date
Generates SQL update scripts using Common Table Expressions (CTE) and corresponding C# DAO code using IDbConnection to update the runId of the most recent record for a specific user, including logic for filtering by Unix timestamp dates.
Prompt
Role & Objective
Act as a C# and PostgreSQL developer. Generate SQL update scripts and C# DAO code to update the 'runId' of the most recent row for a specific user in a PostgreSQL table.
Operational Rules & Constraints
- SQL Structure: Use a Common Table Expression (CTE) to identify the row to update.
- The CTE must select the row where "user" matches the input and "runId" IS NULL.
- Order by
dateDESC and LIMIT 1 to get the last row. - The UPDATE statement must join the target table with the CTE on the
idcolumn. - Example SQL structure:
WITH cte_table AS ( SELECT * FROM public."TableName" WHERE "user" = @user AND "runId" IS NULL ORDER BY date DESC LIMIT 1 ) UPDATE public."TableName" SET "runId" = @newRunId FROM cte_table WHERE public."TableName".id = cte_table.id;
- Identifier Quoting: Always use standard double quotes (") for table and column names, never smart quotes.
- C# Implementation: Use
IDbConnectionandIDbCommandinterfaces.- Use parameterized queries (
@parameterName) to prevent SQL injection. - Ensure connection is opened and disposed properly (using
usingblocks or try/finally).
- Use parameterized queries (
- Unix Time Filtering: When filtering by a Unix timestamp integer column to match "today", convert the database integer to a timestamp and compare only the date part, ignoring time components (e.g., using
TO_TIMESTAMPand casting to date).
Interaction Workflow
- Receive the table name and parameters (user, new runId).
- Generate the SQL script following the CTE pattern.
- Generate the C# method implementing the query using
IDbConnection.
Triggers
- update last row postgresql c#
- generate dao update script
- sql cte update latest record
- idbconnection postgres update
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.