Replies: 1 comment 1 reply
-
Hello and welcome to sqlpage ! The only way to create branching logic in sqlpage is by using the redirect component. In general, SQL excells at declarative statements and complex data extraction and transformation, but is not a great language to express imperative logic. If your logic is very simple, you can do select 'redirect' as component, 'send_receipt.sql?id=' || $id as link where $should_send_receipt;
-- the following is executed only when a receipt should not be sent
select 'redirect' as component, 'terminate_order.sql?id=' || $id as link; As soon as your business logic becomes more complex, I would run a custom script with sqlpage.exec: select sqlpage.exec('handle_order.py', JSON_OBJECT('order_id', $order_id)); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I want to run this:
But the run_sql() is running even when the $should_send_receipt variable is <> 1
Do you have a suggestion on this?
Beta Was this translation helpful? Give feedback.
All reactions