-
Notifications
You must be signed in to change notification settings - Fork 189
Feature/better examples #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ede9fa1
Added award_bonus example (based on https://docs.oracle.com/database/…
jgebal f6b4e96
Added betwnstr example
jgebal 3a19187
Added remove rooms example
jgebal 91fd638
Fixed examples and added examples to main examples run.
jgebal 776cc32
Fixed examples execution and improved performance and visibility for …
jgebal 66b9b08
Merge branch 'version3' into feature/better_examples
jgebal 72471a6
Merge branch 'version3' into feature/better_examples
jgebal 9502f16
Adressed code review comments.
jgebal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added remove rooms example
- Loading branch information
commit 3a19187880cd96d6100ab243575ad656a59197e0
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| create or replace procedure remove_rooms_by_name( l_name rooms.name%type ) is | ||
| begin | ||
| if l_name is null then | ||
| raise program_error; | ||
| end if; | ||
| delete from rooms where name like l_name; | ||
| end; | ||
| / |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| create table rooms ( | ||
| room_key number primary key, | ||
| name varchar2(100) | ||
| ); | ||
|
|
||
| create table room_contents ( | ||
| contents_key number primary key, | ||
| room_key number, | ||
| name varchar2(100) | ||
| ); | ||
|
|
||
| alter table room_contents add constraint fk_rooms foreign key (room_key) references rooms (room_key); | ||
13 changes: 13 additions & 0 deletions
13
examples/remove_rooms_by_name/run_remove_rooms_by_name_test.sql
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| @@rooms.sql | ||
| @@remove_rooms_by_name.sql | ||
| @@test_remove_rooms_by_name.pkg | ||
|
|
||
| set serveroutput on size unlimited format truncated | ||
|
|
||
| exec ut.run(user||'.test_betwnstr',ut_documentation_reporter()); | ||
|
|
||
| drop package test_remove_rooms_by_name; | ||
| drop procedure remove_rooms_by_name; | ||
| drop table room_contents; | ||
| drop table rooms; | ||
|
|
96 changes: 96 additions & 0 deletions
96
examples/remove_rooms_by_name/test_remove_rooms_by_name.pkg
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| create or replace package test_remove_rooms_by_name as | ||
|
|
||
| -- %suite(Remove rooms by name) | ||
|
|
||
| -- %suitesetup | ||
| procedure setup_rooms; | ||
|
|
||
| -- %test(Removes a room without content in it) | ||
| procedure remove_empty_room; | ||
|
|
||
| -- %test(Does not remove room when it has content) | ||
| procedure room_with_content; | ||
|
|
||
| -- %test(Raises exception when null room name given) | ||
| procedure null_room_name; | ||
|
|
||
| end; | ||
| / | ||
|
|
||
| create or replace package body test_remove_rooms_by_name as | ||
|
|
||
| procedure setup_rooms is | ||
| begin | ||
| insert all | ||
| into rooms values(1, 'Dining Room') | ||
| into rooms values(2, 'Living Room') | ||
| into rooms values(3, 'Office') | ||
| into rooms values(4, 'Bathroom') | ||
| into rooms values(5, 'Bedroom') | ||
| select 1 from dual; | ||
|
|
||
| insert all | ||
| into room_contents values(1, 1, 'Table') | ||
| into room_contents values(2, 1, 'Hutch') | ||
| into room_contents values(3, 1, 'Chair') | ||
| into room_contents values(4, 2, 'Sofa') | ||
| into room_contents values(5, 2, 'Lamp') | ||
| into room_contents values(6, 3, 'Desk') | ||
| into room_contents values(7, 3, 'Chair') | ||
| into room_contents values(8, 3, 'Computer') | ||
| into room_contents values(9, 3, 'Whiteboard') | ||
| select 1 from dual; | ||
| end; | ||
|
|
||
| procedure remove_empty_room is | ||
| l_rooms_not_named_b sys_refcursor; | ||
| l_remaining_rooms sys_refcursor; | ||
| begin | ||
| open l_rooms_not_named_b for select * from rooms where name not like 'B%'; | ||
|
|
||
| remove_rooms_by_name('B%'); | ||
|
|
||
| open l_remaining_rooms for select * from rooms; | ||
| ut.expect( l_remaining_rooms ).to_(equal(l_rooms_not_named_b)); | ||
| end; | ||
|
|
||
| procedure room_with_content is | ||
| l_rooms sys_refcursor; | ||
| l_remaining_rooms sys_refcursor; | ||
| begin | ||
| open l_rooms for select * from rooms; | ||
|
|
||
| begin | ||
| remove_rooms_by_name('Living Room'); | ||
| ut.expect( sqlcode ).to_( equal(-2292) ); | ||
| exception | ||
| when others then | ||
| ut.expect( sqlcode ).to_( equal(-2292) ); | ||
| end; | ||
|
|
||
| open l_remaining_rooms for select * from rooms; | ||
|
|
||
| ut.expect( l_remaining_rooms ).to_( equal( l_rooms ) ); | ||
| end; | ||
|
|
||
| procedure null_room_name is | ||
| l_rooms sys_refcursor; | ||
| l_remaining_rooms sys_refcursor; | ||
| begin | ||
| open l_rooms for select * from rooms; | ||
|
|
||
| begin | ||
| remove_rooms_by_name(NULL); | ||
| ut.expect( sqlcode ).to_( equal(-6501) ); | ||
| exception | ||
| when others then | ||
| ut.expect( sqlcode ).to_( equal(-6501) ); | ||
| end; | ||
|
|
||
| open l_remaining_rooms for select * from rooms; | ||
|
|
||
| ut.expect( l_remaining_rooms ).to_( equal( l_rooms ) ); | ||
| end; | ||
|
|
||
| end; | ||
| / |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit simpler: