Professional Documents
Culture Documents
SQL2
SQL2
Dis#onne#tion
DISCONNECT 1-%%$1+*-%)%&4$!
Chapter 9-2&
Copyright 2004 Rame E!masri and "ham#ant $a%athe
Elmasri!a"athe, #undamentals o$ %ata&ase S'stems, #ourth Edition
Embedded SQL in C
Programming E9am,les
,--. = 6!
@2*,$ (,--.) A
.0-4.+ (BE%+$0 SSNC B, ;;%)!
EXEC S(L
;$,$1+ FNAME, LNAME, ADDRESS, SALARY
*%+- C9%&4$, C,%&4$, C&330$;;, C;&,&0D
90-4 EMPLOYEE @2$0$ SSN == C;;%!
*9 (S(LCODE == <) .0*%+9(9%&4$, :)!
$,;$ .0*%+9(BSSN 3-$; %-+ $E*;+C B, ;;%)!
.0-4.+(BM-0$ SSNF (6=D$;, <=%-)C B, ,--.)!
END)EXEC
G
Chapter 9-2'
Copyright 2004 Rame E!masri and "ham#ant $a%athe
Elmasri!a"athe, #undamentals o$ %ata&ase S'stems, #ourth Edition
Embedded SQL in C
Programming E9am,les
Ad/antages6
8
i0 t+e ,ro#ed"re is needed b* man* a,,li#ations$ it
#an be in/o<ed b* an* o0 t+em 1t+"s red"#e
d",li#ations2
8
e9e#"tion b* t+e ser/er red"#es #omm"ni#ation
#osts
8
en+an#e t+e modeling ,ower o0 /iews
Chapter 9-4*
Copyright 2004 Rame E!masri and "ham#ant $a%athe
Elmasri!a"athe, #undamentals o$ %ata&ase S'stems, #ourth Edition
Stored Pro#ed"re Constr"#ts
A stored ,ro#ed"re
CREATE PROCEDURE .0-1$3>0$)%&4$ (.&0&4;)
,-1&,)3$1,&0&+*-%;
.0-1$3>0$)=-3D!
A stored 0"n#tion
CREATE FUNCTION 9>%)%&4$ (.&0&4;) RETRUNS 0$+>0%)+D.$
,-1&,)3$1,&0&+*-%;
9>%1+*-%)=-3D!