Skip to content

SQL Procedures

These procedures are called in Snowsight (or any SQL client) to manage the 42Forms application. All procedures are in the FORTY_TWO_FORMS_APP.CORE schema.

NOTE: Consumer admin must also run GRANT CALLER statements after install to enable per-user data access (Restricted Caller Rights). See docs/POST_INSTALL_GUIDE.md for the required SQL. External access integration for Cortex LLM (Business Critical accounts) Note: External access integrations are created at the account level by the consumer and granted to the application. The app requests this via manifest privileges. ── Emergency admin recovery ───────────────────────────────────────────────── DEPRECATED: This procedure is a no-op placeholder. Do not rely on it. For emergency admin recovery, connect to the Hybrid Tables directly and update the organizationmember table in FORTY_TWO_FORMS_DB.APP_DATA.

Signature:

CALL FORTY_TWO_FORMS_APP.CORE.RESET_ADMIN(target_email VARCHAR);

Parameters:

NameTypeDescription
target_emailVARCHAR-

Returns: VARCHAR

View procedure body
BEGIN
RETURN 'Not available in SPCS mode. Use the API container shell for admin recovery.';
END;

── License management stored procedures ────────────────────────────────────── Set license tier (creates user if not exists, switches if already has a different tier)

Signature:

CALL FORTY_TWO_FORMS_APP.CORE.SET_LICENSE(username VARCHAR, tier VARCHAR);

Parameters:

NameTypeDescription
usernameVARCHAR-
tierVARCHAR-

Returns: VARCHAR

View procedure body
BEGIN
INSERT INTO core.license_commands (username, seat_type)
VALUES (:username, :tier);
RETURN 'License command queued: ' || :username || ' → ' || :tier;
END;

Revoke paid tier (drops to view)

Signature:

CALL FORTY_TWO_FORMS_APP.CORE.REVOKE_LICENSE(username VARCHAR);

Parameters:

NameTypeDescription
usernameVARCHAR-

Returns: VARCHAR

View procedure body
BEGIN
INSERT INTO core.license_commands (username, seat_type)
VALUES (:username, 'view');
RETURN 'License revoked: ' || :username || ' → view';
END;

List all users with their tiers

Signature:

CALL FORTY_TWO_FORMS_APP.CORE.LIST_USERS();

Returns: TABLE (username VARCHAR, seat_type VARCHAR)

View procedure body
DECLARE
res RESULTSET DEFAULT (
SELECT username, seat_type
FROM core.license_commands
WHERE processed = TRUE
QUALIFY ROW_NUMBER() OVER (PARTITION BY username ORDER BY created_at DESC) = 1
);
BEGIN
RETURN TABLE(res);
END;

Convenience aliases

Signature:

CALL FORTY_TWO_FORMS_APP.CORE.ADD_ACT_LICENSE(username VARCHAR);

Parameters:

NameTypeDescription
usernameVARCHAR-

Returns: VARCHAR

View procedure body
BEGIN
CALL core.set_license(:username, 'act');
RETURN 'Act license set for: ' || :username;
END;

Signature:

CALL FORTY_TWO_FORMS_APP.CORE.ADD_BUILD_LICENSE(username VARCHAR);

Parameters:

NameTypeDescription
usernameVARCHAR-

Returns: VARCHAR

View procedure body
BEGIN
CALL core.set_license(:username, 'build');
RETURN 'Build license set for: ' || :username;
END;

Signature:

CALL FORTY_TWO_FORMS_APP.CORE.ADD_ADMIN_LICENSE(username VARCHAR);

Parameters:

NameTypeDescription
usernameVARCHAR-

Returns: VARCHAR

View procedure body
BEGIN
CALL core.set_license(:username, 'admin');
RETURN 'Admin license set for: ' || :username;
END;

── Suspend / Resume procedures ───────────────────────────────────────────── Allow the consumer to manually suspend and resume the compute pool to save credits.

Signature:

CALL FORTY_TWO_FORMS_APP.CORE.SUSPEND_APP();

Returns: VARCHAR

View procedure body
BEGIN
ALTER SERVICE core.forty_two_forms_service SUSPEND;
ALTER COMPUTE POOL forty_two_forms_pool SUSPEND;
RETURN 'Service and compute pool suspended.';
END;

Signature:

CALL FORTY_TWO_FORMS_APP.CORE.RESUME_APP();

Returns: VARCHAR

View procedure body
BEGIN
ALTER COMPUTE POOL forty_two_forms_pool RESUME;
ALTER SERVICE core.forty_two_forms_service RESUME;
RETURN 'Compute pool and service resumed.';
END;