Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Funkcja obliczająca srednią
sandra1023
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 11.06.2010

Ostrzeżenie: (0%)
-----


Mam takie tabelki :
  1. CREATE TABLE [dbo].[Student](
  2. [ID_Studenta] [int] NOT NULL,
  3. [Student_imie] [varchar](50) NOT NULL,
  4. [Student_nazwisko] [varchar](50) NOT NULL,
  5. [Student_data_ur] [datetime] NOT NULL,
  6. [ID_kierunek] [int] NOT NULL,
  7. [Nr_albumu] [int] IDENTITY(1,1) NOT NULL,
  8. [Semestr] [int] NOT NULL,
  9. [Data_rozp_studiow] [datetime] NOT NULL,
  10. [PESEL] [int] NOT NULL,
  11. [Adres] [nvarchar](max) NOT NULL,
  12. [Email] [varchar](50) NULL,
  13. [Uwagi] [nvarchar](max) NULL,
  14. CONSTRAINT [PK_Student] PRIMARY KEY CLUSTERED
  15. (

i
  1. CREATE TABLE [dbo].[Archiwum](
  2. [ID_Student] [int] NOT NULL,
  3. [Student_imie] [varchar](50) NOT NULL,
  4. [Student_nazwisko] [varchar](50) NOT NULL,
  5. [Data_rozp_studiow] [datetime] NOT NULL,
  6. [Data_ukonczenia_studiow] [datetime] NOT NULL,
  7. [Nr_albumu] [int] NOT NULL,
  8. [PESEL] [int] NOT NULL,
  9. [ID__Kierunek] [int] NOT NULL,
  10. [Uwagi] [nvarchar](max) NULL,
  11. CONSTRAINT [PK_Archiwum] PRIMARY KEY CLUSTERED


i chcę żeby po ukończeniu studiów student był przenoszony do archiwum. Kombinowałam z tym wiele ale niestety jestem poczatkujaca. Mysle że można to zrobic za pomocą trigera który dla semestru>5 przenosi studenta do archiwum ale nie wiem jak to zapisać. Bardzo proszę o pomoc.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
sandra1023
post
Post #2





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 11.06.2010

Ostrzeżenie: (0%)
-----


zrobilam to tak:


  1. ALTER TRIGGER [dbo].[archiwu]
  2. ON [dbo].[Student]
  3. after INSERT,UPDATE
  4. AS
  5. IF ((SELECT semestr FROM Student)>5)
  6. begin
  7. UPDATE dbo.Student
  8. SET archiwum=1
  9. end


tylko ze po zrobieniu
  1. UPDATE dbo.Student
  2. SET Semestr=7
  3. WHERE Student_imie ='jan'


mam taki blad
  1. Msg 512, Level 16, State 1, Procedure archiwu, Line 5
  2. Subquery returned more than 1 value. This IS NOT permitted when the subquery follows =, !=, <, <= , >, >= OR when the subquery IS used AS an expression.
  3. The statement has been terminated.



Jak to naprawic?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 8.10.2025 - 12:26