-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Elin Angelow
committed
Dec 18, 2023
1 parent
8b522df
commit 20db663
Showing
3 changed files
with
22 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,21 @@ | ||
CREATE TYPE LessonType AS TABLE (LessonId INT, LessonName VARCHAR(100)) | ||
|
||
CREATE TABLE Lesson ( | ||
Id INT PRIMARY KEY, | ||
LName VARCHAR(50) | ||
) | ||
------------------------- | ||
CREATE PROCEDURE Usp_InsertLesson | ||
@ParLessonType LessonType READONLY, | ||
@ParLessonType2 LessonType READONLY | ||
CREATE TABLE "some-test-example"."exsschema"."tx" ( | ||
tag serial PRIMARY KEY, | ||
device VARCHAR (100) NOT NULL, | ||
created BIGINT DEFAULT extract(epoch from now()) | ||
); | ||
--------------------------------------------------------------- | ||
CREATE FUNCTION "some-test-example"."exsschema"."fnLastTx"(pDevice VARCHAR (100)) | ||
RETURNS table (tag integer, created BIGINT) | ||
AS | ||
INSERT INTO Lesson | ||
SELECT * FROM @ParLessonType; | ||
|
||
CREATE PROCEDURE Usp_InsertLesson2 | ||
@ParLessonType LessonType READONLY, | ||
@ParLessonType2 LessonType READONLY | ||
$$ | ||
SELECT tag, created FROM "some-test-example"."exsschema"."tx" WHERE tag = (SELECT MAX(tag) AS tag FROM "some-test-example"."exsschema"."tx" WHERE device = pDevice); | ||
$$ | ||
LANGUAGE sql; | ||
--------------------------------------------------------------- | ||
CREATE FUNCTION "some-test-example"."exsschema"."fnNewTx"(pDevice VARCHAR (100), pCreated BIGINT) | ||
RETURNS table (tag integer, created BIGINT) | ||
AS | ||
INSERT INTO Lesson | ||
SELECT * FROM @ParLessonType | ||
------------------------- | ||
DECLARE @VarLessonType AS LessonType | ||
|
||
INSERT INTO @VarLessonType VALUES ( 1, 'Math') | ||
INSERT INTO @VarLessonType VALUES ( 2, 'Science') | ||
INSERT INTO @VarLessonType VALUES ( 3, 'Geometry') | ||
|
||
|
||
EXECUTE Usp_InsertLesson @VarLessonType | ||
------------------------- | ||
------------------------- | ||
------------------------- | ||
$$ | ||
INSERT INTO "some-test-example"."exsschema"."tx" (device, created) VALUES (pDevice, pCreated) RETURNING tag, created; | ||
$$ | ||
LANGUAGE sql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters