Prompt to Pipeline
When an assistant is connected through the OcaltQL MCP server, a request in plain English becomes a short script that runs on your account. Each example below shows the request, the script an assistant can write for it, and the output the script returned when it was run against the live API. Your numbers will differ wherever the data is live.
Each script follows the two rules that matter most. Every statement after the first in a chain starts with AFTER, AND or OR. And OcaltQL is nestable everywhere; only operations are not nestable within each other.
1. A morning brief
The request: “Give me the weather in Durban and the dollar rate in one line, and tell me what R2,500 is in dollars.”
The weather and the rate do not depend on each other, so the script fetches them at the same time with AND. The conversion waits for both with AFTER.
WEATHER "Durban" SET ?w
AND CURRENCY RATE FROM "USD" TO "ZAR" SET ?rate
AFTER CURRENCY CONVERT 2500 FROM "ZAR" TO "USD" SET ?usd
AFTER CALCULATE ROUND(?usd) SET ?usd
AFTER EMIT "Durban: " & ?w("temp_c") & " C, " & ?w("description") & ". USD/ZAR " & ?rate & ", so R2500 is about $" & ?usd & "."
The result: Durban: 22 C, Light drizzle. USD/ZAR 16.7669, so R2500 is about $149.
2. Watch a page for changes
The request: “Check whether this page has changed since the last time I asked.”
The script keeps a fingerprint of the page with GENERATE HASH and stores it with REMEMBER, which lasts between runs. On the next run it compares the new fingerprint with the stored one. The three outcomes are an IF followed by OR IF and OR, because OcaltQL has no ELSE.
FETCH "https://www.iana.org/help/example-domains" SET ?page
AFTER GENERATE HASH FOR ?page AS sha256 SET ?now
AFTER RECALL "watch:iana" SET ?before
AFTER IF ?before IS NULL OPEN
EMIT "First check. Saved the page fingerprint."
CLOSE
OR IF ?before IS EQUAL TO ?now OPEN
EMIT "No change since the last check."
CLOSE
OR OPEN
EMIT "The page changed."
CLOSE
AFTER REMEMBER "watch:iana" AS ?now
The result: the first run returned First check. Saved the page fingerprint. and the second run returned No change since the last check. To check every hour without asking, the same script can run on a schedule; see Schedule & Cron.
3. A signup list with a summary
The request: “Keep a list of signups with their plan, add two people, and tell me how many joined, how many are on Pro, and who joined last.”
The script creates a database and a table, inserts two rows, and then asks three questions of the table. COUNT ROWS answers the first two and SELECT ROWS with ORDER BY and LIMIT answers the third.
NEW DB "signups"
AFTER NEW TABLE "people" IN DB "signups" COLUMNS
ADD "id" TYPE NUMBER AUTOINCREMENT PRIMARY
AND ADD "email" LENGTH 255 TYPE STRING UNIQUE REQUIRED
AND ADD "plan" LENGTH 20 TYPE STRING DEFAULT "free"
AFTER INSERT INTO DB "signups" TABLE "people" ROW "email" AS "lerato@example.com" AND "plan" AS "pro"
AFTER INSERT INTO DB "signups" TABLE "people" ROW "email" AS "musa@example.com"
AFTER COUNT ROWS FROM DB "signups" TABLE "people" SET ?total
AFTER COUNT ROWS FROM DB "signups" TABLE "people" WHERE "plan" IS EQUAL TO "pro" SET ?pro
AFTER SELECT ROWS FROM DB "signups" TABLE "people" ORDER BY "id" DESCENDING LIMIT 1 SET ?last
AFTER EMIT ?total & " signups, " & ?pro & " on Pro. Newest: " & ?last(0)("email")
The result: 2 signups, 1 on Pro. Newest: musa@example.com
NEW DB reports that signups already exists. Remove it with DROP DB "signups" when you are done.Getting good scripts from an assistant
- Ask it to read ql.ocalt.com/llms.txt or the
ocaltql://guideresource before it writes anything. - Describe the result you want to see, not the steps. The assistant chooses the verbs.
- When a script fails, the error names the line. Let the assistant read the error and correct the script itself.
- Read any script that changes or deletes data before you approve it.