Skip to content

Commit 0eaef2a

Browse files
committed
Clean Document
1 parent 114011b commit 0eaef2a

File tree

5 files changed

+84
-30
lines changed

5 files changed

+84
-30
lines changed

content/docs/guides/basics.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Basics"
3+
weight: 9
4+
draft: false
5+
---
6+
7+
**SQL Components** simplifies how your Java application interacts with relational databases by providing three core concepts:
8+
9+
1. **Manager**: Handles database connections and manages access to various database objects.
10+
2. **Model**: Represents the structure of database tables as simple Java objects (POJOs).
11+
3. **Store**: An interface that allows you to perform common database operations like **Select**, **Insert**, **Update**, and **Delete** on tables.

content/docs/guides/core-components.md

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: "Stored Procedure"
3+
weight: 11
4+
draft: false
5+
---
6+
7+
> **Stored Procedures** are a powerful feature in relational databases that allow you to encapsulate SQL logic on the database side. A stored procedure is a precompiled set of one or more SQL statements that can perform complex operations like updates, inserts, and even condition handling. By moving logic into stored procedures, you can reduce the amount of database interaction from your application code, increase performance, and improve maintainability.
8+
9+
Here’s an example of a stored procedure to transfer funds between two accounts:
10+
11+
```sql
12+
CREATE OR REPLACE PROCEDURE transfer(
13+
sender INT,
14+
receiver INT,
15+
amount DECIMAL
16+
)
17+
LANGUAGE plpgsql
18+
AS $$
19+
BEGIN
20+
-- Subtracting the amount from the sender's account
21+
UPDATE accounts
22+
SET balance = balance - amount
23+
WHERE id = sender;
24+
25+
-- Adding the amount to the receiver's account
26+
UPDATE accounts
27+
SET balance = balance + amount
28+
WHERE id = receiver;
29+
30+
COMMIT;
31+
END $$;
32+
```
33+
34+
This stored procedure transfers an amount from one account to another by updating the balances of both accounts.
35+
36+
To call this stored procedure in SQL:
37+
38+
```sql
39+
CALL transfer(1, 2, 500);
40+
```
41+
42+
### Using SQL Components to Call Stored Procedures
43+
44+
SQL Components makes it easy to call stored procedures directly from Java code without any need for complex mappings or additional libraries. Here’s how you can invoke the `transfer` stored procedure using **DatabaseManager** in SQL Components:
45+
46+
```java
47+
DatabaseManager.getManager().transfer(1, 2, 500);
48+
```

content/docs/guides/table.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: "Table"
3+
weight: 10
4+
draft: false
5+
---
6+
7+
Store will act as inteface for all the SQL operations againts tables.
8+
9+
## Insert
10+
11+
## Select
12+
13+
## Update
14+
15+
## Delete
16+
17+

hugo_stats.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"article",
66
"aside",
77
"base",
8+
"blockquote",
89
"body",
910
"button",
1011
"circle",
@@ -23,6 +24,7 @@
2324
"h5",
2425
"head",
2526
"header",
27+
"hr",
2628
"html",
2729
"img",
2830
"input",
@@ -253,7 +255,9 @@
253255
"ids": [
254256
"TableOfContents",
255257
"buttonColorMode",
258+
"delete",
256259
"doks-docs-nav",
260+
"insert",
257261
"offcanvasNavMain",
258262
"offcanvasNavSection",
259263
"offcanvasNavSectionLabel",
@@ -264,11 +268,14 @@
264268
"searchResults",
265269
"searchToggleDesktop",
266270
"searchToggleMobile",
271+
"select",
267272
"socialMenu",
268273
"sql-components-a-simpler-flexible-alternative",
269274
"sql-components-a-type-safe-alternative",
270275
"sql-components-flexibility-beyond-orm",
271-
"toc"
276+
"toc",
277+
"update",
278+
"using-sql-components-to-call-stored-procedures"
272279
]
273280
}
274281
}

0 commit comments

Comments
 (0)