File install/INSTALL.md changed (mode: 100644) (index 18ea7f0..c2dbc3c) |
... |
... |
To compile [those notes](../README.html), you need |
21 |
21 |
- librsvg2-bin, |
- librsvg2-bin, |
22 |
22 |
- font-linuxlibertine |
- font-linuxlibertine |
23 |
23 |
|
|
|
24 |
|
**Warning: as of now (Nov. 2020), you actually need [pandoc 2.9.2.1](https://github.com/jgm/pandoc/releases/tag/2.9.2.1), |
|
25 |
|
|
24 |
26 |
Then, clone the repository at <https://rocketgit.com/user/caubert/CSCI_3410>, and refer to [the example file](../notes/example.html) for a gentle test and guide on the syntax and tool of this document. |
Then, clone the repository at <https://rocketgit.com/user/caubert/CSCI_3410>, and refer to [the example file](../notes/example.html) for a gentle test and guide on the syntax and tool of this document. |
25 |
27 |
Change the current folder to `notes`, and execute `make example`. |
Change the current folder to `notes`, and execute `make example`. |
26 |
28 |
You can have a look at `notes/Makefile` to understand what is happening in the `example` rule. |
You can have a look at `notes/Makefile` to understand what is happening in the `example` rule. |
File notes/Makefile changed (mode: 100644) (index ffc3395..3b72f7d) |
... |
... |
MAKEFLAGS:= -j |
15 |
15 |
# Maximize parallel execution whenever possible |
# Maximize parallel execution whenever possible |
16 |
16 |
OPTIONSPANDOC:= --toc --filter pandoc-numbering --citeproc --filter pandoc-include-code --top-level-division=chapter -M date="$$(LANG=en_us_88591 date '+%B %e, %Y (%r)')" --lua-filter filters/default-code-class.lua -M default-code-class=sqlmysql |
OPTIONSPANDOC:= --toc --filter pandoc-numbering --citeproc --filter pandoc-include-code --top-level-division=chapter -M date="$$(LANG=en_us_88591 date '+%B %e, %Y (%r)')" --lua-filter filters/default-code-class.lua -M default-code-class=sqlmysql |
17 |
17 |
# Options common to all invokations of pandoc. Cf https://pandoc.org/MANUAL.html to understand them. |
# Options common to all invokations of pandoc. Cf https://pandoc.org/MANUAL.html to understand them. |
|
18 |
|
# -citeproc used to be --filter pandoc-citeproc |
18 |
19 |
OPTIONSPANDOCODT:= $(OPTIONSPANDOC) --default-image-extension=svg |
OPTIONSPANDOCODT:= $(OPTIONSPANDOC) --default-image-extension=svg |
19 |
20 |
OPTIONSPANDOCHTML:= $(OPTIONSPANDOC) --css=style/style.css -B style/foldable_toc.html -B style/anchors_header.html -A style/anchors_footer.html --section-divs --toc-depth=2 --self-contained --default-image-extension=svg |
OPTIONSPANDOCHTML:= $(OPTIONSPANDOC) --css=style/style.css -B style/foldable_toc.html -B style/anchors_header.html -A style/anchors_footer.html --section-divs --toc-depth=2 --self-contained --default-image-extension=svg |
20 |
21 |
OPTIONSPANDOCPDF:= $(OPTIONSPANDOC) --pdf-engine=xelatex --pdf-engine-opt=-shell-escape -V links-as-notes --default-image-extension=pdf |
OPTIONSPANDOCPDF:= $(OPTIONSPANDOC) --pdf-engine=xelatex --pdf-engine-opt=-shell-escape -V links-as-notes --default-image-extension=pdf |
File notes/code/java/CallProcedure.java changed (mode: 100644) (index 9526ec0..5dcc678) |
... |
... |
public class CallProcedure { |
18 |
18 |
+ "CREATE SCHEMA HW_CALL_TEST;" |
+ "CREATE SCHEMA HW_CALL_TEST;" |
19 |
19 |
+ "USE HW_CALL_TEST;"); |
+ "USE HW_CALL_TEST;"); |
20 |
20 |
|
|
21 |
|
stmt.execute("CREATE TABLE Test1 (" + "A INT PRIMARY KEY);"); |
|
|
21 |
|
stmt.execute("CREATE TABLE Test1 (A INT PRIMARY KEY);"); |
22 |
22 |
|
|
23 |
23 |
stmt.execute("INSERT INTO Test1 VALUES (1), (2), (3);"); |
stmt.execute("INSERT INTO Test1 VALUES (1), (2), (3);"); |
24 |
24 |
// To create a procedure, we don't need to change the delimiter! |
// To create a procedure, we don't need to change the delimiter! |
25 |
25 |
// Cf. https://stackoverflow.com/a/5314879/ for instance. |
// Cf. https://stackoverflow.com/a/5314879/ for instance. |
26 |
26 |
stmt.execute( |
stmt.execute( |
27 |
|
" CREATE PROCEDURE List () " + " BEGIN " + " SELECT * " + " FROM Test1; " + " END; "); |
|
|
27 |
|
" CREATE PROCEDURE List () BEGIN SELECT * FROM Test1; END; "); |
28 |
28 |
// We create a CallabaleStatement object |
// We create a CallabaleStatement object |
29 |
29 |
// https://docs.oracle.com/javase/7/docs/api/java/sql/CallableStatement.html |
// https://docs.oracle.com/javase/7/docs/api/java/sql/CallableStatement.html |
30 |
30 |
// that extends PreparedStatements and allow to call procedures. |
// that extends PreparedStatements and allow to call procedures. |
File notes/lectures_notes.md changed (mode: 100644) (index 0087285..219e9c2) |
... |
... |
You can find below a simple example of "scrollable" `ResultSet`: |
8434 |
8434 |
|
|
8435 |
8435 |
You can also have a look at the end of `code/java/AdvancedProg.java`, which creates a second `Statement` object is created and used. |
You can also have a look at the end of `code/java/AdvancedProg.java`, which creates a second `Statement` object is created and used. |
8436 |
8436 |
|
|
|
8437 |
|
## A Delicate Balance |
|
8438 |
|
|
|
8439 |
|
Forgetting about the technical difficulties for a minute, there is always the issue of finding the right balance between what the application, and what the database, should do. |
|
8440 |
|
Any control structure should be dealt with by the application, and queries (such as select project joins) should be done by the DBMS, but the line may be a bit blurry at times. |
|
8441 |
|
For instance, should the schema being created from the application? Probably yes if this is an operation that needs to be performed repeatedly (to "reboot" your schema), or if you want your application to be as portable as possible. |
|
8442 |
|
Otherwise, it may make little sense. |
|
8443 |
|
|
|
8444 |
|
Another question is: if a task need to be performed repeatedly, should you create a method in the application, or a procedure in the DBMS? |
|
8445 |
|
Once again, it will depend: if you need to read information from the user or if using control flow is crucial to your task, then a method seems more adequate. |
|
8446 |
|
But if the task is essentially a series of queries, then creating a procedure may have benefits: |
|
8447 |
|
|
|
8448 |
|
- A procedure will be accessible from any application, and from the command-line as well, |
|
8449 |
|
- A procedure will be pre-parsed and optimized on the database side, |
|
8450 |
|
- A procedure can serve as a "bridge" between a schema that may evolve and an application that requires resilience from the DBMS. Typically, if two attributes are swapped in the schema, it may not impact the order in which the arguments are passed to the procedure, which ultimately save from having to edit the application. |
|
8451 |
|
|
|
8452 |
|
As an example of how to technically declare and use a procedure from an application, refer to the following code: |
|
8453 |
|
|
|
8454 |
|
```{.java .numberLines include=code/java/CallProcedure.java} |
|
8455 |
|
``` |
|
8456 |
|
|
|
8457 |
|
|
8437 |
8458 |
## Exercises {-} |
## Exercises {-} |
8438 |
8459 |
|
|
8439 |
8460 |
Exercise +.# |
Exercise +.# |