diff --git a/db/4_sem/tag_1/TSQL-Einführung/Einführung-01.sql b/db/4_sem/tag_1/TSQL-Einführung/Einführung-01.sql new file mode 100644 index 0000000..ad87939 --- /dev/null +++ b/db/4_sem/tag_1/TSQL-Einführung/Einführung-01.sql @@ -0,0 +1,92 @@ +-- Beispiel 1 + +-- Variablen Deklaration +declare @Z1 int, @Firstname varchar(50); + +-- Set +set @Z1 = 100; + +-- Print +print 'Zahl Z1 = ' + cast(@Z1 as varchar) + + +-- Beispiel 2 +declare @Z1 int; + +set @Z1 = 1000; +if @Z1 > 100 +begin + print 'Z1 ist eine grosse Zahl'; +end +else +begin + print 'Z2 ist eine kleine Zahl'; +end + + +-- Beispiel 3 +declare @num int +set @num =(SELECT COUNT(*) FROM PA_MITARBEITER); +if @num > 0 + print 'Total Abteilungen = ' + convert(varchar, @num); +else + print 'keine Abteilungen vorhanden'; + + +-- Beispiel 4 +declare @Nr varchar(20), @bez varchar(40); +select @Nr=ABT_ABTNR, @bez = ABT_BEZ + from PA_ABTEILUNG + where ABT_ABTNR = 'DV1'; + +print 'Nr = ' + @Nr + ', Bezeichnung = ' + @bez; + + +-- Beispiel 5 +go +create procedure CalcSumProc (@Z1 int, @Z2 int, @Result int output) +as +set @Result = @Z1 + @Z2; +go + +declare @Sum int, @RetCode int; +set @Sum = 0; +exec CalcSumProc 1, 2, @Sum output; +print 'Sum = ' + cast(@Sum as varchar); + + +-- Beispiel 6 +go +create function CalcSumFunc (@Z1 int, @Z2 int) +returns int +as +begin +declare @result int; + +set @result = @Z1 + @Z2; +return @Result +end +go + + + +-- Beispiel 7 +declare @abtnr varchar(20), @abtbez varchar(50); + +DECLARE Abteilung_Cursor CURSOR FOR + SELECT ABT_ABTNR, ABT_BEZ + FROM PA_ABTEILUNG + ORDER BY ABT_BEZ; + +OPEN Abteilung_Cursor; +FETCH NEXT FROM Abteilung_Cursor + into @abtnr, @abtbez; + +WHILE @@FETCH_STATUS = 0 +BEGIN + print 'Nr = ' + @abtnr + ', Name = ' + @abtbez + FETCH NEXT FROM Abteilung_Cursor + into @abtnr, @abtbez; +END; +CLOSE Abteilung_Cursor; +DEALLOCATE Abteilung_Cursor; diff --git a/db/4_sem/tag_1/TSQL-Einführung/Einführung-02.sql b/db/4_sem/tag_1/TSQL-Einführung/Einführung-02.sql new file mode 100644 index 0000000..d181f14 --- /dev/null +++ b/db/4_sem/tag_1/TSQL-Einführung/Einführung-02.sql @@ -0,0 +1,931 @@ +/* +******************************************************************************* +* * +* SQL Server 2008 / 2008 R2 - Der schnelle Einstieg * +* * +* Kapitel 5 - Transact-SQL - Die Sprache zur Serverprogrammierung * +* * +* © 2009/2010, Klemens Konopasek * +******************************************************************************* +*/ + + +-- Variablen und Datentypen +-- 5.1.1 + + +DECLARE @nachname varchar(50), @vorname varchar(50) +DECLARE @gebdatum date + +SET @nachname = (SELECT PersNachname + FROM tblPersonal + WHERE PersNr = 452) +SET @vorname = (SELECT PersVorname + FROM tblPersonal + WHERE PersNr = 452) +SET @gebdatum = (SELECT PersGebDatum + FROM tblPersonal + WHERE PersNr = 452) +SELECT @nachname NN, @vorname VN, @gebdatum Geburtsdatum + + + +GO +-- ************************************************************************* + + +DECLARE @nachname varchar(50), @vorname varchar(50) +DECLARE @gebdatum date + +SELECT @nachname = PersNachname, + @vorname = PersVorname, + @gebdatum = PersGebDatum +FROM tblPersonal +WHERE PersNr = 452 + +SELECT @nachname NN, @vorname VN, @gebdatum Geburtsdatum + + + + +-- ************************************************************************* + + + +DECLARE @ust tinyint +DECLARE @netto smallmoney, @brutto smallmoney + +SET @ust = 19 +SET @netto = 450 +SET @brutto = @netto * (@ust + 100) / 100 + +SELECT @netto Netto, @brutto Brutto + + + + +-- ************************************************************************* + + +DECLARE @nr int + +SET @nr = @nr + 3 +SET @nr = @nr * 5 + +SELECT @nr Nr + + +GO +-- ************************************************************************* + + + +DECLARE @plz varchar(5) + +SET @plz = '8010' + +SELECT PersNachname, PersVorname +FROM tblPersonal +WHERE PersPlz = @plz + + +GO +-- ************************************************************************* + + +DECLARE @nr int = 3 +SET @nr = @nr + 3 +SET @nr = @nr * 5 +SELECT @nr Nr + + +GO +-- ************************************************************************* + + + + + + + + +-- Benutzerdefinierte Tabellentypen +-- 5.1.2 + +CREATE TYPE KundenTab AS TABLE +( kdnr int PRIMARY KEY, + nachname varchar(50), + vorname varchar(50) +) + +GO +-- ************************************************************************* + + +DECLARE @kunden KundenTab + +INSERT INTO @kunden (kdnr, nachname, vorname) +SELECT KdNr, KdNachname, KdVorname +FROM dbo.tblKunden +WHERE KdLand = 'D' + + +GO +-- ************************************************************************* + + + +CREATE PROCEDURE dbo.spTabellenTest + + @kdnamen KundenTab READONLY + +AS +BEGIN + + SELECT UPPER(nachname) + ' ' + vorname AS Kunde + FROM @kdnamen + ORDER BY 1 + +END + + +GO + + +DECLARE @kunden KundenTab + +INSERT INTO @kunden (kdnr, nachname, vorname) +SELECT KdNr, KdNachname, KdVorname +FROM dbo.tblKunden +WHERE KdLand = 'D' + +EXEC dbo.spTabellenTest @kunden + + +GO +-- ************************************************************************* + + + + + + + + +-- Funktionen + +-- 5.1.3 + + +SELECT @@language + +SELECT @@servername + +SELECT @@VERSION + +SELECT SERVERPROPERTY('ProductVersion') + +-- Datumsfunktionen + +SELECT DATEADD(week, 3, '01.01.2010') + +SELECT DATEDIFF(month, '08.01.2010', '15.11.2010') + +SET LANGUAGE german +SELECT DATENAME(weekday, '23.05.2010') +SELECT DATEPART(weekday, '23.05.2010') + +SET LANGUAGE english +SELECT DATENAME(weekday, '05.23.2010') +SELECT DATEPART(weekday, '05.23.2010') + +SET LANGUAGE german +SELECT DAY('20.04.2009') Tag, MONTH('20.04.2009') Monat, YEAR('20.04.2009') Jahr + +SELECT GETDATE() + + +SELECT ISDATE('24.12.2008'), ISDATE('240.12.2008') + +SELECT CURRENT_TIMESTAMP +SELECT Sysdatetime(), GETDATE() +SELECT Sysutcdatetime() +SELECT Sysdatetimeoffset() + +SELECT Sysdatetimeoffset() AS Graz, + Switchoffset(Sysdatetimeoffset(), '-08:00') AS Vancouver + +SELECT Todatetimeoffset(Sysdatetime(), '-08:00') + + +-- Mathematische Funktionen + +SELECT ROUND(5.129, 2), ROUND(18452, -2), ROUND(1.99,1,1) + +SELECT CEILING(5.129) + + +-- Metadatenfunktionen + +SELECT DB_NAME(), DB_NAME(1), DB_ID(), DB_ID('master') + +SELECT COL_LENGTH('tblArtikel','Artbezeichnung') -- nur innerhalb der DB möglich! + +SELECT COL_LENGTH('wawi.dbo.tblArtikel','Artbezeichnung') -- von jeder DB aus möglich! + +SELECT OBJECT_ID('tblArtikel') + +SELECT OBJECT_NAME('1511676433') + +SELECT COL_NAME(OBJECT_ID('tblArtikel'), 2) + + +-- Sicherheitsfunktionen + +SELECT IS_MEMBER('db_owner') + + +-- Zeichenfolgefunktionen + +SELECT ASCII('m'), CHAR(109) + +SELECT CHARINDEX(' ','SQL Server') + + +DECLARE @name varchar(30), @vorname varchar(15) +DECLARE @position int + SET @name = 'Petra Konopasek' + SET @position = CHARINDEX(' ', @name) + SET @vorname = LEFT(@name, @position - 1) + SELECT @vorname Vorname + + +SELECT MAX(LEN(PersNachname)) [Längster Name] +FROM tblPersonal; + +SELECT PersVorname + ' ' + UPPER(PersNachname) Name +FROM tblPersonal +ORDER BY PersNachname; + +SELECT REPLICATE('.', 15 - LEN(PersNachname)) + PersNachname Name +FROM tblPersonal; + +SELECT SOUNDEX('Maier') Maier, + SOUNDEX('Meyer') Meyer, + SOUNDEX('Mayer') Mayer, + SOUNDEX('Peyer') Peyer, + SOUNDEX('Ober') Ober, + SOUNDEX('Obermann') Obermann, + SOUNDEX('Hausmahn') Hausmahn + + +SELECT ArtBezeichnung + ' kostet € ' + + ArtVKPreis AS Preise +FROM tblArtikel; + + +SELECT ArtBezeichnung + ' kostet € ' + + STR(ArtVKPreis, 5, 2) AS Preise +FROM tblArtikel; + + + +DECLARE @name varchar(30) +DECLARE @nachname varchar(15) +DECLARE @position int + SET @name = 'Alina Konopasek' + SET @position = CHARINDEX(' ', @name) + SET @nachname = SUBSTRING(@name, @position + 1, 15) + SELECT @nachname Nachname + + + +SELECT SUBSTRING(@@VERSION, 35, 4) AS Version + + +-- Systemfunktionen + +SELECT SYSDATETIME() As Datum, + CONVERT(varchar,SYSDATETIME(), 4) As [Jahr 2-stellig], + CONVERT(varchar,SYSDATETIME(), 104) As [Jahr 4-stellig] + + + +SELECT PersNachname FROM tblPersonal +WHERE PersEintritt = '01.04.2001'; + +SELECT PersNachname FROM tblPersonal +WHERE PersEintritt = '01.04.2001 8:00'; + + +SELECT GETDATE() As Datum, + CONVERT(datetime,CONVERT(varchar,GETDATE(),4),4) + As NurDatum + + + +SELECT PersNachname FROM tblPersonal +WHERE CAST(PersEintritt AS DATE)= '01.04.2001'; + + + +SELECT HOST_NAME() As Arbeitsplatz, HOST_ID() As ID + + + +INSERT INTO tblArtikel (ArtBezeichnung, ArtGruppe, + ArtVKpreis, ArtEKPreis, ArtLief) +VALUES('Wassereimer 15L', 'GA', 3.99, 2.12, 1003); +SELECT @@IDENTITY "Neue Artikelnunmmer" + + + +SELECT KdTitel + ' ' + KdAkadGrad + ' ' + + KdNachname + ' ' + KdVorname As Kunden +FROM tblKunden +ORDER BY KdNachname; + + + +SELECT ISNULL(KdTitel + ' ','') + + ISNULL(KdAkadGrad + ' ', '') + + KdNachname + ' ' + KdVorname AS Kunden +FROM tblKunden +ORDER BY KdNachname; + + + +BEGIN TRAN + +UPDATE tblArtikel +SET ArtVKPreis = ArtVKPreis * 0.95 +WHERE ArtVKPreis > 200; + +SELECT @@ROWCOUNT "Anzahl um 5% verbilligt" + +ROLLBACK TRAN + + +-- Rangfolgefunktionen + + +SELECT Artbezeichnung AS Bezeichnung, + ArtVKPreis AS Preis, + RANK() OVER( ORDER BY ArtVKPreis DESC) AS Rang +FROM tblArtikel; + + +SELECT Artbezeichnung Bezeichnung, + ArtVKPreis Preis, + ArtGruppe Gruppe, + RANK() OVER( PARTITION BY ArtGruppe + ORDER BY ArtVKPreis DESC) AS Rang +FROM dbo.tblArtikel; + + + + +SELECT Artbezeichnung Bezeichnung, + ArtVKPreis Preis, + DENSE_RANK() OVER(ORDER BY ArtVKPreis DESC) AS Rang +FROM dbo.tblArtikel; + + + +SELECT PersNachname AS Nachname, + PersVorname As Vorname, + NTILE(5) OVER( ORDER BY PersGebDatum) AS Gruppe +FROM tblPersonal; + + +SELECT Artbezeichnung AS Bezeichnung, + ArtVKPreis AS Preis, + ROW_NUMBER() OVER( ORDER BY ArtVKPreis DESC) AS "lfd. Nr." +FROM tblArtikel; + + + + +-- Hierarchie-ID-Funktionen + +DECLARE @root hierarchyid +SET @root = hierarchyid::GetRoot() +SELECT @root.ToString() AS Wurzeleintrag, @root AS WurzelID + + +DECLARE @nachfolger hierarchyid +SET @nachfolger = @root.GetDescendant(NULL, NULL) +SELECT @nachfolger.ToString() AS Nachfolger + +SELECT @nachfolger.IsDescendantOf(@root) AS IstNachfolger1, +@root.IsDescendantOf(@nachfolger) AS IstNachfolger2 + +SELECT @root.GetLevel() AS LevelRoot, +@nachfolger.GetLevel() AS LevelNachfolger + +DECLARE @vorgaenger hierarchyid +SET @vorgaenger = @nachfolger.GetAncestor(1) +SELECT @vorgaenger.ToString() As Vorgänger + + + +-- ************************************************************************* +-- Kontrollstrukturen + + +-- 5.1.4 +GO + + +DECLARE @monat tinyint + SET @monat = MONTH(GETDATE()) + IF @monat <= 6 + PRINT 'Wir sind in der ersten Jahreshälfte.' + ELSE + PRINT 'Wir befinden uns im zweiten Halbjahr.' + + +-- ************************************************************************* +GO + +DECLARE @kunde int +DECLARE @interesse char(3) + + SET @kunde = 136 + SET @interesse = 'HUG' + + INSERT INTO tblKundeninteressen + VALUES (@kunde, @interesse) + + +SELECT * FROM tblKunden; +SELECT * FROM tblKundenInteressen; + + +GO +-- ************************************************************************* + +DECLARE @kunde int +DECLARE @interesse char(3) + + SET @kunde = 136 + SET @interesse = 'HUG' + + IF (SELECT COUNT(*) FROM tblKundenInteressen + WHERE KdNr = @kunde AND IntCode = @interesse) = 1 + PRINT 'Zuordnung bereits vorhanden.' + ELSE + INSERT INTO tblKundenInteressen + VALUES (@kunde, @interesse); + + +GO +-- ************************************************************************* + + +BEGIN TRAN + +DECLARE @kunde int +DECLARE @interesse char(3) + + SET @kunde = 136 + SET @interesse = 'SPO' + + IF (SELECT COUNT(*) FROM tblKundenInteressen + WHERE KdNr = @kunde AND IntCode = @interesse) = 1 + PRINT 'Zuordnung bereits vorhanden.' + ELSE + BEGIN + INSERT INTO tblKundenInteressen + VALUES (@kunde, @interesse); + PRINT 'Interesse wurde zugewiesen.' + END + + +--ROLLBACK TRAN +GO +-- ************************************************************************* + + + +IF MONTH(SYSDATETIME()) IN(1,2,3,4,5) + PRINT 'Vorsaison' +ELSE + IF MONTH(SYSDATETIME()) IN(6,7,8,9) + PRINT 'Hauptsaison' + ELSE + PRINT 'Nachsaison' + + + + +-- ************************************************************************* + + +IF MONTH(SYSDATETIME()) IN(1,2,3,4,5) + PRINT 'Vorsaison' +ELSE + IF MONTH(SYSDATETIME()) IN(6,7,8,9) + BEGIN + PRINT 'Hauptsaison' + PRINT 'Hier ist alles sehr teuer.' + END + ELSE + PRINT 'Nachsaison' + + + +-- ************************************************************************* + + +DECLARE @kunde int +DECLARE @interesse char(3) + + SET @kunde = 132 + SET @interesse = 'SPO' + + IF (SELECT COUNT(*) FROM tblKundenInteressen + WHERE KdNr = @kunde AND IntCode = @interesse) = 1 + OR (SELECT KdAktiv FROM tblKunden + WHERE KdNr = @kunde) = 0 + PRINT 'Zuordnung bereits vorhanden oder Kunde nicht mehr aktiv.' + ELSE + BEGIN + INSERT INTO tblKundenInteressen + VALUES (@kunde, @interesse); + PRINT 'Interesse wurde zugewiesen.' + END + + + +-- ************************************************************************* + + + +DECLARE @wotag varchar(10) +SET @wotag = CASE DATEPART(weekday, SYSDATETIME()) + WHEN 1 THEN 'Montag' + WHEN 2 THEN 'Dienstag' + WHEN 3 THEN 'Mittwoch' + WHEN 4 THEN 'Donnerstag' + WHEN 5 THEN 'Freistag' + WHEN 6 THEN 'Samstag' + ELSE 'Sonntag' + END +SELECT @wotag [Heute ist] + + + +-- ************************************************************************* + + +DECLARE @typ varchar(10) +SET @typ = CASE WHEN DATEPART(weekday, GETDATE()) < 6 + THEN 'Arbeitstag' + ELSE 'Wochenende' END +SELECT @typ "Heute ist" + + + + +-- ************************************************************************* + + +SELECT CASE PersGeschlecht WHEN 1 THEN 'Frau' ELSE 'Herr' END Anrede, + PersVorname Vorname, + PersNachname Nachname +FROM tblPersonal + + + +-- ************************************************************************* + +-- Cursor für Datenzugriffe einsetzen + + +-- 5.1.5 + + +DECLARE @kdnr int +DECLARE @nachname varchar(50) + + +DECLARE kunden_cursor CURSOR LOCAL STATIC +FOR + SELECT KdNr, KdNachname + FROM tblKunden + WHERE KdAktiv = 1 + +OPEN kunden_cursor +FETCH NEXT FROM kunden_cursor INTO @kdnr, @nachname + + +WHILE @@fetch_status = 0 +BEGIN + --... + FETCH NEXT FROM kunden_cursor INTO @kdnr, @nachname +END + + +CLOSE kunden_cursor +DEALLOCATE kunden_cursor + + + +-- ************************************************************************* + +-- Transaktionssteuerung + + +-- 5.2.1 + +DELETE FROM tblKunden WHERE KdAktiv = 0; + + + +-- 5.2.2 + +SELECT * FROM tblTestpersonal; + + +UPDATE tblTestpersonal +SET Nachname = 'Untermann' +WHERE Nr = 101; + + +SELECT * +FROM tblTestpersonal +WHERE Nr = 101; + + +ROLLBACK TRAN + + +BEGIN TRANSACTION + + +DELETE FROM tblTestpersonal +WHERE Abtlg IN('MA', 'EK'); + + +INSERT INTO tblTestpersonal +VALUES(700, 'Deutschmann', 'MA', SYSDATETIME()); + + +SELECT * FROM tblTestpersonal ORDER BY Nr; + + +ROLLBACK TRANSACTION + + +SELECT * FROM tblTestpersonal ORDER BY Nr; + + +BEGIN TRANSACTION + + +DELETE FROM tblTestpersonal +WHERE Abtlg = 'GL'; + + +INSERT INTO tblTestpersonal +VALUES(700, 'Deutschmann', 'MA', SYSDATETIME()); + + +COMMIT TRANSACTION + + + +-- ************************************************************************* + +-- SET-Optionen verwenden + +-- 5.3 + + +SET ANSI_NULLS ON +DECLARE @agrad varchar(10) +SET @agrad = Null + +SELECT PersNachname, PersAkadGrad +FROM tblPersonal +WHERE PersAkadGRad = @agrad; + + + +GO + + +SET ANSI_NULLS OFF +DECLARE @agrad varchar(10) +SET @agrad = Null + +SELECT PersNachname, PersAkadGrad +FROM tblPersonal +WHERE PersAkadGRad != @agrad; + + +GO +-- ************************************************************************* + +SELECT PersAkadGrad + ' ' + PersNachname AS Mitarbeiter +FROM tblPersonal; + + +SET CONCAT_NULL_YIELDS_NULL OFF + +SELECT LTRIM(PersAkadGrad + ' ' + PersNachname) AS Mitarbeiter +FROM tblPersonal; + +SET CONCAT_NULL_YIELDS_NULL ON + +SELECT ISNULL(PersAkadGrad + ' ', '') + PersNachname AS Mitarbeiter +FROM tblPersonal; + + +GO +-- ************************************************************************* + +SET DATEFIRST 1 +SELECT DATEPART(weekday, '01.01.2010') As Tag + +SET DATEFIRST 7 +SELECT DATEPART(weekday, '01.01.2010') As Tag + +-- ************************************************************************* + +SET DATEFORMAT dmy +DECLARE @datum datetime +SET @datum = '15.08.2010' + +-- ************************************************************************* + +SET IDENTITY_INSERT tblArtikel ON + +INSERT INTO tblArtikel (ArtNr, ArtBezeichnung, ArtGruppe, + ArtVKpreis, ArtEKPreis, ArtLief) +VALUES (2222, 'Gartenschlauch 15m', 'GA', 23.99, + 17.11, 1003); + + + +-- ************************************************************************* + +SELECT langid, name, alias, dateformat, datefirst +FROM master.sys.syslanguages; + +SET LANGUAGE english +SET LANGUAGE français +SET LANGUAGE german +SET LANGUAGE latviešu + + +-- ************************************************************************* + +SET QUOTED_IDENTIFIER OFF +CREATE TABLE quot_id_test +( ID int, + "Kunden Name" varchar(60) ); + + +-- ************************************************************************* + +SET ROWCOUNT 5 + +SELECT PersNr, PersNachname, Persvorname +FROM tblPersonal +ORDER BY 1; + +SET ROWCOUNT 0 + + + + +-- ************************************************************************* + +-- Fehlerbehandlung + +-- 5.4 + + +SET NOCOUNT ON + +DECLARE @gruppe char(2), @name varchar(30) + +SET @gruppe = 'GE' +SET @name = 'Geschirr' + +INSERT INTO dbo.tblArtikelGruppen (ArtGr, ArtGrText) +VALUES (@gruppe, @name); + +IF @@ROWCOUNT = 0 + SELECT 'Fehler!' As Ergebnis +ELSE + SELECT 'Erledigt ;-)' As Ergebnis + + +GO + +-- Fehler "vermeiden" + +SET NOCOUNT ON + +DECLARE @gruppe char(2), @name varchar(30) + +SET @gruppe = 'GE' +SET @name = 'Geschirr' + +IF exists ( SELECT * + FROM dbo.tblArtikelGruppen + WHERE ArtGr = @gruppe) + SELECT 'Fehler!' As Ergebnis +ELSE +BEGIN + INSERT INTO dbo.tblArtikelGruppen + VALUES (@gruppe, @name); + SELECT 'Erledigt ;-)' As Ergebnis +END + + +GO + +-- Fehler "behandeln" + + +SET NOCOUNT ON + +DECLARE @gruppe char(2), @name varchar(30) + +SET @gruppe = 'GE' +SET @name = 'Geschirr' + +BEGIN TRY + INSERT INTO dbo.tblArtikelGruppen + VALUES (@gruppe, @name); + SELECT 'Erledigt ;-)' As Ergebnis +END TRY +BEGIN CATCH + SELECT 'Fehler!' As Ergebnis +END CATCH + + + +GO + +-- inkl. Transaktion + + +SET NOCOUNT ON + +DECLARE @gruppe char(2), @name varchar(30) + +SET @gruppe = 'GE' +SET @name = 'Geschirr' + +BEGIN TRY + BEGIN TRANSACTION + + INSERT INTO dbo.tblArtikelGruppen + VALUES (@gruppe, @name); + + COMMIT TRANSACTION + + SELECT 'Erledigt ;-)' As Ergebnis +END TRY +BEGIN CATCH + ROLLBACK TRANSACTION + SELECT 'Fehler!' As Ergebnis +END CATCH + + +GO + + + +-- Ausgabe Fehlermeldung + +SET NOCOUNT ON + +DECLARE @gruppe char(2), @name varchar(30) + +SET @gruppe = 'GE' +SET @name = 'Geschirr' + +BEGIN TRY + + BEGIN TRANSACTION + + INSERT INTO dbo.tblArtikelGruppen + VALUES (@gruppe, @name); + + COMMIT TRANSACTION + + SELECT 'Erledigt ;-)' As Ergebnis +END TRY +BEGIN CATCH + ROLLBACK + SELECT ERROR_MESSAGE() As Ergebnis +END CATCH + + +GO diff --git a/db/4_sem/tag_1/procedures.sql b/db/4_sem/tag_1/procedures.sql new file mode 100644 index 0000000..499c1fb --- /dev/null +++ b/db/4_sem/tag_1/procedures.sql @@ -0,0 +1,27 @@ +use Berater; +go + +create FUNCTION fBestverdiener() +RETURNS varchar(100) + +AS BEGIN +DECLARE @nr int, + @nachname varchar(50), + @vorname varchar(50), + @aufgabe varchar(30) +--set nocount on + +SELECT @nr = b.BERATERID, + @nachname = b.BERATERNAME, + @aufgabe = a.AUFGABE +FROM BERATER b INNER JOIN AUFGABE a +ON b.AUFGABEID = a.AUFGABEID +WHERE b.STUNDENLOHN = (SELECT MAX(STUNDENLOHN) +FROM BERATER) + +Return convert(varchar,@nr) + ',' + @nachname + ',' + @aufgabe +END +go + + +select dbo.fBestverdiener(), BERATERNAME FROM BERATER; diff --git a/vagrant/webtech/.vagrant/machines/default/virtualbox/action_set_name b/vagrant/webtech/.vagrant/machines/default/virtualbox/action_set_name deleted file mode 100644 index 33d4062..0000000 --- a/vagrant/webtech/.vagrant/machines/default/virtualbox/action_set_name +++ /dev/null @@ -1 +0,0 @@ -1503757949 \ No newline at end of file diff --git a/vagrant/webtech/.vagrant/machines/default/virtualbox/creator_uid b/vagrant/webtech/.vagrant/machines/default/virtualbox/creator_uid deleted file mode 100644 index e37d32a..0000000 --- a/vagrant/webtech/.vagrant/machines/default/virtualbox/creator_uid +++ /dev/null @@ -1 +0,0 @@ -1000 \ No newline at end of file diff --git a/vagrant/webtech/.vagrant/machines/default/virtualbox/id b/vagrant/webtech/.vagrant/machines/default/virtualbox/id deleted file mode 100644 index 574be8c..0000000 --- a/vagrant/webtech/.vagrant/machines/default/virtualbox/id +++ /dev/null @@ -1 +0,0 @@ -59196ade-8d6d-414e-9803-84ceeb7bffe8 \ No newline at end of file diff --git a/vagrant/webtech/.vagrant/machines/default/virtualbox/index_uuid b/vagrant/webtech/.vagrant/machines/default/virtualbox/index_uuid deleted file mode 100644 index 81a05f3..0000000 --- a/vagrant/webtech/.vagrant/machines/default/virtualbox/index_uuid +++ /dev/null @@ -1 +0,0 @@ -84a7ea016bff42d6a81f0e24e28c5803 \ No newline at end of file diff --git a/vagrant/webtech/.vagrant/machines/default/virtualbox/private_key b/vagrant/webtech/.vagrant/machines/default/virtualbox/private_key deleted file mode 100644 index 99fa1c8..0000000 --- a/vagrant/webtech/.vagrant/machines/default/virtualbox/private_key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAmaCHhayjEjIDSfuFK/YVpOcFdbGKdCaQAUS8EQcfbT7o4Ns6 -Yq3dYitvqeC73Hda1neGEIa6EjRAUXeL4b0RAw2R0wSexwmM4levWa6A3/4LtD1i -jxVyDgI834Ime2TEk7pHf3s0v5fThB1/eS5qGeCqC3nNfZxpXKLeAl+oCUesGMgd -lr5hZ/Dr78hFKKeOKCXtgp+NIxokRgWgicrnwTlaSRuWVf8zSZo6h6hG4bqMAOjR -6/duTLe2YusAvWedPJyJ7dQIge9gO9a1skhfVlk8p0Mnt0qeK2zNHKk4M8dNTUVG -dAVpPaTU2oSGkKjJkf1MbUm4ArKgRAboA8K+FQIDAQABAoIBAEU/c/cQU00vWAYw -Jt4jBayYKgDcL2GdxEmeFvvB7yuKMOSyTQYQAvtuQt4bG/MLpdmIdNjcMeFkxh0y -us3dMF7k7fdlXMCxEF0yUyskmpjc5Z+wD84ZR5kC7zd8biYuzOEeFX5kJem64S/r -L/uKrW7OszeLBtJ4/5EvJM2DGrZbcml7P4WAWli+aVFU2fCheRR5JbntdmlKVfZw -uFzsbggOiSkXOiBi7bM/aapS6RsMWO4cNjPeu6YDzxiH7Xybfx66BxLmH2bkQTD8 -TWiCpO+1iX9GLeT1jln37VBsnkpIbFj0ngsau3Da+Z8TXoENI2Y1W76FyFf0Rkip -ClzKkZ0CgYEAyiNz6OWUnE44dvTIM90Vive+ZYId37ABEmdnuyo2uS/FaPwfrAEz -DgAgF3IVJj3XoQtPmPgxQcsJqv1siURObEx5/sj3zvalhsUVjZ//ROyQdtYrbAnt -AsRWpuWuao0Jc54ag5Du5r9+iM/7s8zfmRMnvZ6aS+Ye3ArBLFcURFsCgYEAwo/z -AkIwPqOh0i9HwiUoz4gwMF8cXH6kpBU9p2pEBcPJz7KQCAqXNqSxkKZZ7b7ePz+z -GKCtWaQP8UZAzvoVBnSrlpD5fuOAeo1458Nj+yKFMa7h6FlNY/HlFJOaBlg7F+tr -5yx22BS71QFvccfjUmtmDcgPVoBILiXZaKx90k8CgYAvuu1cuhE8U1AL7sLzVCoJ -FXTU3UOWlSW7pcUdsdsYIUqY/qev4tyeWrM5Ngv+aq3m7hfOhBSFd58BzDN7ujBW -bDyGSAgTy7PMPe9X8MbDDKUUGoBIU5OuipP3dtaXfFQWA+g41tlCjUcgoRPLIf5O -U/KXWMMQVvdEeBmjEbDMbwKBgQCdsYqm4/qyanH4J7Yjl3aybpGQQyZ7mXHcRBMK -pEip23ywyOuQePUCpw38TbhJyA/ed8SzS1f1ddIuHmDc4Tk1WE7S5IIz5DT4H75F -KsrYe6w1DqevaOIfBapEuTV3uv96baexYQqaLIPpKxamw/ptjPrUZLh5xdO7A5Zp -DpWUZQKBgQCRlx5nZFhzw+N4e2CpyhZO/7n/FYP68uDnIap8sLtaUhFQsnO9zVVR -27P3obOh1LLuzeS6Uy5CjE2lP/S7ESZjXxnH1o7ng1VI40Rj6c8nVG7EFoPg9UIy -y/nJebdpad9gjAwJn4P9fx+vf1rvj9Q0iH0VKELGCNBqMVGB8liHEg== ------END RSA PRIVATE KEY----- diff --git a/vagrant/webtech/.vagrant/machines/default/virtualbox/synced_folders b/vagrant/webtech/.vagrant/machines/default/virtualbox/synced_folders deleted file mode 100644 index 249ce58..0000000 --- a/vagrant/webtech/.vagrant/machines/default/virtualbox/synced_folders +++ /dev/null @@ -1 +0,0 @@ -{"rsync":{"/vagrant":{"type":"rsync","guestpath":"/vagrant","hostpath":"/home/andreas/git_repos/ibz_repos/ibz/vagrant/webtech","disabled":false,"__vagrantfile":true,"owner":"vagrant","group":"vagrant"}},"virtualbox":{"/var/www/html":{"guestpath":"/var/www/html","hostpath":"/home/andreas/git_repos/ibz_repos/ibz/web/1_sem","disabled":false,"__vagrantfile":true}}} \ No newline at end of file diff --git a/vagrant/webtech/Vagrantfile b/vagrant/webtech/Vagrantfile index 73401a7..da4989e 100644 --- a/vagrant/webtech/Vagrantfile +++ b/vagrant/webtech/Vagrantfile @@ -12,7 +12,7 @@ Vagrant.configure("2") do |config| # Every Vagrant development environment requires a box. You can search for # boxes at https://atlas.hashicorp.com/search. - config.vm.box = "debian-VAGRANTSLASH-stretch64" + config.vm.box = "debian/stretch64" # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs @@ -66,7 +66,7 @@ Vagrant.configure("2") do |config| # documentation for more information about their specific syntax and use. config.vm.provision "shell", inline: <<-SHELL apt-get update - apt-get install -y apache2 + apt-get install -y apache2 php7.0 SHELL end diff --git a/web/1_sem/index.html b/web/1_sem/index.html new file mode 100644 index 0000000..766401d --- /dev/null +++ b/web/1_sem/index.html @@ -0,0 +1,368 @@ + + + + + + Apache2 Debian Default Page: It works + + + +
+ + +
+ + +
+
+ It works! +
+
+

+ This is the default welcome page used to test the correct + operation of the Apache2 server after installation on Debian systems. + If you can read this page, it means that the Apache HTTP server installed at + this site is working properly. You should replace this file (located at + /var/www/html/index.html) before continuing to operate your HTTP server. +

+ + +

+ If you are a normal user of this web site and don't know what this page is + about, this probably means that the site is currently unavailable due to + maintenance. + If the problem persists, please contact the site's administrator. +

+ +
+
+
+ Configuration Overview +
+
+

+ Debian's Apache2 default configuration is different from the + upstream default configuration, and split into several files optimized for + interaction with Debian tools. The configuration system is + fully documented in + /usr/share/doc/apache2/README.Debian.gz. Refer to this for the full + documentation. Documentation for the web server itself can be + found by accessing the manual if the apache2-doc + package was installed on this server. + +

+

+ The configuration layout for an Apache2 web server installation on Debian systems is as follows: +

+
+/etc/apache2/
+|-- apache2.conf
+|       `--  ports.conf
+|-- mods-enabled
+|       |-- *.load
+|       `-- *.conf
+|-- conf-enabled
+|       `-- *.conf
+|-- sites-enabled
+|       `-- *.conf
+          
+
    +
  • + apache2.conf is the main configuration + file. It puts the pieces together by including all remaining configuration + files when starting up the web server. +
  • + +
  • + ports.conf is always included from the + main configuration file. It is used to determine the listening ports for + incoming connections, and this file can be customized anytime. +
  • + +
  • + Configuration files in the mods-enabled/, + conf-enabled/ and sites-enabled/ directories contain + particular configuration snippets which manage modules, global configuration + fragments, or virtual host configurations, respectively. +
  • + +
  • + They are activated by symlinking available + configuration files from their respective + *-available/ counterparts. These should be managed + by using our helpers + + a2enmod, + a2dismod, + + + a2ensite, + a2dissite, + + and + + a2enconf, + a2disconf + . See their respective man pages for detailed information. +
  • + +
  • + The binary is called apache2. Due to the use of + environment variables, in the default configuration, apache2 needs to be + started/stopped with /etc/init.d/apache2 or apache2ctl. + Calling /usr/bin/apache2 directly will not work with the + default configuration. +
  • +
+
+ +
+
+ Document Roots +
+ +
+

+ By default, Debian does not allow access through the web browser to + any file apart of those located in /var/www, + public_html + directories (when enabled) and /usr/share (for web + applications). If your site is using a web document root + located elsewhere (such as in /srv) you may need to whitelist your + document root directory in /etc/apache2/apache2.conf. +

+

+ The default Debian document root is /var/www/html. You + can make your own virtual hosts under /var/www. This is different + to previous releases which provides better security out of the box. +

+
+ +
+
+ Reporting Problems +
+
+

+ Please use the reportbug tool to report bugs in the + Apache2 package with Debian. However, check existing bug reports before reporting a new bug. +

+

+ Please report bugs specific to modules (such as PHP and others) + to respective packages, not to the web server itself. +

+
+ + + + +
+
+
+
+ + + diff --git a/web/3_sem/tomcat/ROOT/META-INF/context.xml b/web/3_sem/tomcat/ROOT/META-INF/context.xml new file mode 100644 index 0000000..00e2ff6 --- /dev/null +++ b/web/3_sem/tomcat/ROOT/META-INF/context.xml @@ -0,0 +1,2 @@ + diff --git a/web/3_sem/tomcat/ROOT/index.html b/web/3_sem/tomcat/ROOT/index.html new file mode 100644 index 0000000..5f50007 --- /dev/null +++ b/web/3_sem/tomcat/ROOT/index.html @@ -0,0 +1,29 @@ + + + + + Apache Tomcat + + + +

It works !

+ +

If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!

+ +

This is the default Tomcat home page. It can be found on the local filesystem at: /var/lib/tomcat8/webapps/ROOT/index.html

+ +

Tomcat8 veterans might be pleased to learn that this system instance of Tomcat is installed with CATALINA_HOME in /usr/share/tomcat8 and CATALINA_BASE in /var/lib/tomcat8, following the rules from /usr/share/doc/tomcat8-common/RUNNING.txt.gz.

+ +

You might consider installing the following packages, if you haven't already done so:

+ +

tomcat8-docs: This package installs a web application that allows to browse the Tomcat 8 documentation locally. Once installed, you can access it by clicking here.

+ +

tomcat8-examples: This package installs a web application that allows to access the Tomcat 8 Servlet and JSP examples. Once installed, you can access it by clicking here.

+ +

tomcat8-admin: This package installs two web applications that can help managing this Tomcat instance. Once installed, you can access the manager webapp and the host-manager webapp.

+ +

NOTE: For security reasons, using the manager webapp is restricted to users with role "manager-gui". The host-manager webapp is restricted to users with role "admin-gui". Users are defined in /etc/tomcat8/tomcat-users.xml.

+ + +