Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

blog/business-logic-db

A retrospective look at the "never put business logic inside the database" mantra

https://zenstack.dev/blog/business-logic-db

You must be logged in to vote

Replies: 1 comment · 1 reply

Comment options

We actually have put everything inside the database; even the UI!

-- 1. Variable declarations (ALL at start)
DECLARE @Name NVARCHAR(MAX), @NameInput NVARCHAR(MAX), @SubmitButton NVARCHAR(MAX), @message NVARCHAR(MAX);

-- 2. Display title
EXEC sp_api_modal_text @text = N'Welcome to TSQL.APP!';

-- 3. Create input field
EXEC sp_api_modal_input @name = N'@Name', @value = @Name OUT;

-- 4. Add submit button
EXEC sp_api_modal_button @name = N'@SubmitButton',  @value = N'Submit', @valueout = @SubmitButton OUT, @class = N'btn-primary';

-- 5. Wait for Submit
IF @SubmitButton IS NULL RETURN;

-- 6. Continue with @name
SET @message=concat('Hello ',@name,', welcome to https://t-sql.app, a framework built by ux1.nl')
EXEC sp_api_modal_text @text=@message, @class=N'h2'


-- 7. Add more database logic
/*
IF @SubmitButton=N'Submit'
BEGIN
    INSERT INTO (...) 
    SELECT ( .. FROM .. WHERE [Name]=@name)
END
*/
You must be logged in to vote
1 reply
@rhodelta66giscus
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.