13주-14주proc.PDF

Similar documents
12주-proc.PDF

Microsoft Word - ProC3.doc

歯sql_tuning2

K&R2 Reference Manual 번역본

10.ppt

PowerPoint 프레젠테이션

歯PLSQL10.PDF

90

@OneToOne(cascade = = "addr_id") private Addr addr; public Emp(String ename, Addr addr) { this.ename = ename; this.a

I T C o t e n s P r o v i d e r h t t p : / / w w w. h a n b i t b o o k. c o. k r

03장.스택.key

목차 BUG 문법에맞지않는질의문수행시, 에러메시지에질의문의일부만보여주는문제를수정합니다... 3 BUG ROUND, TRUNC 함수에서 DATE 포맷 IW 를추가지원합니다... 5 BUG ROLLUP/CUBE 절을포함하는질의는 SUBQUE

歯9장.PDF

untitled

[ 목차 ] 5.1 데이터베이스프로그래밍개념 5.2 T-SQL T-SQL 문법 5.3 JAVA 프로그래밍 2

ESQL/C


단답형 (26 회기출문제 ) 1. 아래와같은테이블이있을때아래의 SQL 결과에대해서 Oracle, SQL Server 순서로적으시오 TAB1 COL1 CHAR(10) COL2 CHAR(10) INSERT INTO TAB1 VALUES ('1',''); INSERT INT

untitled

Microsoft Word - [Unioneinc] 특정컬럼의 통계정보 갱신_ _ldh.doc

PowerPoint 프레젠테이션

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어

SQL Tuning Business Development DB

untitled

untitled

3 S Q L A n t i p a t t e r n s Trees/intro/parent.sql CREATE TABLE Comments ( comment_id SERIAL PRIMARY KEY, parent_id BIGINT UNSIGNED, comment TEXT

Microsoft Word - SQL튜닝_실습교재_.doc

Microsoft Word - PLSQL.doc

Connection 8 22 UniSQLConnection / / 9 3 UniSQL OID SET

RDB개요.ppt

Spring Boot/JDBC JdbcTemplate/CRUD 예제

chap7.key

int main(void) int a; int b; a=3; b=a+5; printf("a : %d \n", a); printf("b : %d \n", b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf(" a : %x \

untitled

목차 BUG offline replicator 에서유효하지않은로그를읽을경우비정상종료할수있다... 3 BUG 각 partition 이서로다른 tablespace 를가지고, column type 이 CLOB 이며, 해당 table 을 truncate

Microsoft PowerPoint - PLSQL.ppt

Microsoft PowerPoint - PLSQL.ppt

ALTIBASE HDB Patch Notes

untitled

본 강의에 들어가기 전

C프로-3장c03逞풚

Jerry Held


02 C h a p t e r Java

MS-SQL SERVER 대비 기능

목차 BUG DEQUEUE 의 WAIT TIME 이 1 초미만인경우, 설정한시간만큼대기하지않는문제가있습니다... 3 BUG [qp-select-pvo] group by 표현식에있는컬럼을참조하는집합연산이존재하지않으면결괏값오류가발생할수있습니다... 4

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4

6주차.key

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

Microsoft Word - 05_SUBPROGRAM.doc

FlashBackt.ppt

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾

C 언어 프로그래밊 과제 풀이

MySQL-Ch10

sms_SQL.hwp

PowerPoint 프레젠테이션

강의10

chap8.PDF

8 장데이터베이스 8.1 기본개념 - 데이터베이스 : 데이터를조직적으로구조화한집합 (cf. 엑셀파일 ) - 테이블 : 데이터의기록형식 (cf. 엑셀시트의첫줄 ) - 필드 : 같은종류의데이터 (cf. 엑셀시트의각칸 ) - 레코드 : 데이터내용 (cf. 엑셀시트의한줄 )

(Humphery Kim) RAD Studio : h=p://tech.devgear.co.kr/ : h=p://blog.hjf.pe.kr/ Facebook : h=p://d.com/hjfactory :

제목을 입력하세요.

Microsoft Word - 03_SQL_CURSOR.doc

Microsoft Word - 04_EXCEPTION.doc

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

10.

, ( ),, ( ), 3, int kor[5]; int eng[5]; int Microsoft Windows 4 (ANSI C2 ) int kor[5] 20 # define #define SIZE 20 int a[10]; char c[10]; float

untitled

세미나(장애와복구-수강생용).ppt

5.스택(강의자료).key

ORANGE FOR ORACLE V4.0 INSTALLATION GUIDE (Online Upgrade) ORANGE CONFIGURATION ADMIN O

중간고사


C++-¿Ïº®Çؼ³10Àå

FileMaker 15 ODBC 및 JDBC 설명서


예제소스는 에서다운로드하여사용하거나툴바의 [ 새쿼리 ]( 에아래의소스를입력한다. 입력후에는앞으로실습을위해서저장해둔다. -- 실습에필요한 Madang DB 와 COMPANY DB 를모두생성한다. -- 데이터베이스생성 US

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D D382E687770>

Relational Model

chap10.PDF


Line (A) å j a k= i k #define max(a, b) (((a) >= (b))? (a) : (b)) long MaxSubseqSum0(int A[], unsigned Left, unsigned Right) { int Center, i; long Max

Microsoft PowerPoint SQL 추가 기능

: 1 int arr[9]; int n, i; printf(" : "); scanf("%d", &n); : : for(i=1; i<10; i++) arr[i-1] = n * i; for(i=0; i<9; i++) if(i%2 == 1) print

다양한 예제로 쉽게 배우는 오라클 SQL 과 PL/SQL

歯7장.PDF

Microsoft Word - 기술노트[19회] Flashback.doc

chap7.PDF

대량의 DML 작업에대한성능개선방안 엑셈컨설팅본부 /DB 컨설팅팀박준연 개요 대량의데이터를변경해야하는작업은그자체만으로도큰부담으로다가온다. 하지만변경작업자체에만국한되는것이아니라변경되기전데이터와변경이후데이터를각각저장관리해야하는메커니즘이라면성능을개선해야하는입장에서는더욱큰부담

강의 개요

ALTIBASE 사용자가이드 Templete

Microsoft PowerPoint - Chapter_09.pptx

11장 포인터

DB 성능고도화핵심원리 비투엔컨설팅 수석컨설턴트 조시형

(Microsoft PowerPoint - 5\300\345.\271\256 \303\263\270\256\(8\301\266\).ppt)

Microsoft PowerPoint - lab14.pptx

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi

NoSQL

<4D F736F F F696E74202D20C1A63132B0AD20B5BFC0FB20B8DEB8F0B8AEC7D2B4E7>

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

Microsoft PowerPoint - QVIZMVUMWURI.pptx

Transcription:

12 : Pro*C/C++ 1 2 Embeded SQL 3 PRO *C 31 C/C++ PRO *C NOT! NOT AND && AND OR OR EQUAL == = SQL,,, Embeded SQL SQL 32 Pro*C C SQL Pro*C C, C Pro*C, C C 321, C char : char[n] : n int, short, long : float : double float : VARCHAR[N] : VARCHAR C PRO*C 1

VARCAHR Pro*C char, char[n], VARCHAR[n] NUMBER NUMBER(x,x) Pro*C int, short, long, float, double PRO* C,,,, EXEC SQL BEGIN SECTION; SQL (:) testproc1pc (:) int emp_number; real emp_salary; EXEC SQL SELECT sal INTO :emp_salary FROM emp WHERE sal = :emp_salary; 322 C C, PRO*C C ALTER, CREATE, INSERT, DELETE 323 (Indicator Variable) Pro*C NULL (:) DECLARE SECTION, 2 byte testproc1pc #include<stdioh> VARCHAR user_id[20]; VARCHAR passwd[20]; int emp_no; float emp_salary; short emp_sal_indicator; /* */ 2

EXEC SQL INCLUDE SQLCA; /* */ main() { printf("\n Enter User ID :"); scanf("%s", iser_idarr); printf("\n Enter Passward :"); scanf("%s", passwdarr); user_idlen = strln(user_isarr); passwdlen = strln(passwdarr); EXEC SQL CONNECT :user_id IDENTIFIED BY :passwd; if (sqlcasqlcode < 0) { printf("\n@s", sqlcasqlerrmsqlerrmc); EXEC SQL ROLLBACK WORK RELEASE; exit(1); else { printf("\nconnected to Oracle"); EXEC SQL COMMIT WORK RELEASE; getdata(); exit(0); void getdata() { printf("\n Enter Employee Number to Query:"); scanf("%d\n", emp_number); /* : emp sal emp_sal_indicator */ EXEC SQL SELECT sal INTO :emp_salary :emp_sal_indicator FROM emp WHERE sal = :emp_number; if (emp_sal_indicator == -1_ 3

printf( Employee NO %d has the salary of $ 000\n,emp_number); else { printf("\n Emplyoee %d :", emp_number); printf("\n Salary : %f", emp_salary); SELECT emp sal Pro*C emp_salary, emp_sal_indicator, emp sal NULL, emp_sal_indicator 1, -2 (crash), -1 NULL 0 0 (crash) 1 NULL, 0-1: NULL 0 : emp sal NULL emp_sal_indicator = -1; EXEC SQL INSERT INTO emp(emp_no, sal) VALUES(:emp_number, :emp_salary :emp_sal_indicator); 324 C PRO*C C, int emp_number[10]; float emo_salary[10]; char emp_name[10][20];, SELECT 4

, /* : 2 */ float emp_salary[1][10]; (1) SQL PRO*C INSERT, UPDATE SELECT, FETCH SQL int emp_number[10]; float emo_salary[10]; /* */ EXEC SQL SELECT enpno, ename, sal INTO :emp_number, :emp_name, :emp_salary FROM emp WHERE empnp > 2000; SQL, SQL 10, 10, ORA-02112: PCC: SELECT INTRO returns too many rows (2) int emp_number[10]; float emp_salary[10]; 5

/* */ EXEC SQL INSERT INTO rmp(enpno, sal) VALUES(:emp_number, :emp_salary); 10 emp, C FOR loop 10 Pro*C FOR loop SQL, for (int I=0, I < 10; I++) { EXEC SQL INSERT INTO emp(empno, sal) VALUES (:emp_number[i], :emp_salary[i]);, SQL,, SQL (3) UPDATE, UPDATE int emp_number[10]; float emp_salary[10]; /* */ EXEC SQL UPDATE emp SET sal = :emp_salary WHERE empno = :emp_number; (4) DELETE SQL, int emo_number[10]; 6

/* */ EXEC SQL DELETE FROM emp WHERE empno = :emp_number; (5) (Indicator Variable Array),, Int emp_numnber[10]; Float emp_salary[10]; Char emp_name[10][20]; Short emp_sal_indicator[10]; /* */ EXEC SQL INSERT INTO emp(empno, ename, sal) VALUES (:emp_number, :emp_name, :emp_salary :emp_sal_indicator); 33 SQL Pro*C SQL SELECT, INSERT, DELETE, UPDATE SQL Pro*C Pro*C EXEC SQL SQL SQL, Pro*C SQL 34 PRO *C SELECT,, PRO*C 4 1 DECLARE : 2 OPEN : 3 FETCH : 4 CLOSE : 7

341, PRO *C /* */ EXEC SQL DECLARE emp_cursor CURSOR FOR SELECT empno, ename, job, sal FROM emp WHERE empno > 1000; SELECT FETCH 342 OPEN OPEN OPEN /* OPEN */ EXEC SQL OPEN emp_cursor; OPEN, OPEN OPEN 343 FETCH OPEN FETCH, FETCH SELECT FETCH /* FETCH */ EXEC SQL FETCH emp_cursor INTO :emp_number, emp_name, :emp_salary, :emp_deptno; FETCH, FETCH CLOSE OPEN, OPEN FETCH OPEN CURSOR, FETCH, CLOSE 344 CLOSE CLOSE, /* CLOSE */ 8

EXEC SQL CLOSE emp_cursor; 345 cursorpc, scott/tiger dept /* File Name : cursorpc */ Description : Connect to Oracle DB as scott/tiger, then gets the department table data, and display them #include<stdioh> VARCHAR username[20]; VARCHAR password[20]; int char char dept_no; dept_name[20]; dept_loc[20]; EXEC SQL INCLUDE SQLCA; main() { strcpy(usernamearr, "SCOTT"); strcpy(passwordarr, "TIGER"); usernamelen = strlen(usernamearr); passwordlen = strlne(passwordarr); /* : scott/tiger */ EXEC SQL CONNECT :username IDENTIFIED BY :password; /*,, */ if (sqlcasqlcode < 0) { printf("\n%s",sqlcasqlerrmsqlerrmc); EXEC SQL ROLLBACK WORK RELEASE; exit(1); 9

printf("\n Connected to Oracle "); /* */ EXEC SQL DECLARE dept_cursor CURSOR FOR SELECT deptno, dname, loc FROM dept; /* OPEN */ EXEC SQL OPEN dept_cursor; /* OPEN, break */ EXEC SQL WHENEVER NOT FOUND DO break; printf("no Name Location\n"); printf("----------- -------------------- --------------------\n"); for(;;) { /* FETCH */ EXEC SQL FETCH dept_cursor INTO :dept_no, :dept_name, :dept_loc; /* */ printf("%d, %s %s\n", dept_no, dept_name, dept_loc); /* CLOSE */ EXEC SQL CLOSE dept_cursor; /* Commit */ EXEC SQL COMMIT WORK RELEASE; exit(0); 35 Pro*C PL/SQL Pro*C PL/SQL C Pro*C SQL PL/SQL SQL C EXEC SQL, Pro*C PL/SQL EXEC SQL EXECUTE, END-EXEC, 10

int emp_number; int emp_depno; /* PL/SQL */ EXEC SQL EXECUTE BEGIN END; SELECT deptno INTO :emp_deptno FROM emp WHERE empno = :emp_number; END-EXEC; /* PL/SQL */ PL/SQL 36 sqlca SQLCA SQL, SQLCA Pro*C SQL Pro*C SQL SQLCA WHENEVER 361 SQLCA SQLCA PRO*C SQLCA sqlcah EXEC SQL INCLUDE SQLCA C #include, #include<sqlcah> EXEC SQL INCLUDE SQLCA; SQLCA SQLCA SQLCA SQLCA SQLCA, WHENEVER 362 SQLCA SQLCA struct sqlca { 11

char sqlcaid[8]; /* "SQLCA" */ long sqlabc; /* SQLCA */ long sqlcode; /* */ ; struct { unsigned short sqlerrml; /* */ char sqlerrmc[70]; /* */ sqlerrm; char sqlerrp[8]; /* */ long sqlerrd[6]; /* */ char sqlwarn[8]; /* */ char sqlext[8]; struct sqlca sqlca; SQLCA SQL C (), If (sqlcasqlcode!= 0) { printf("sql Error %s\n", sqlcasqlerrmsqlerrmc); 363 SQLCA SQLCA SQLCA (1) sqlcode sqlerrm SQLCA, sqlcode 0 : SQL > 0 : SQL < 0 : SQL,, 12

SQLCA sqlerrm sqlcode sqlerrm SQL (2) sqlerrp (3) sqlerrd 6 sqlerrd[0] : sqlerrd[1] : sqlerrd[2] : SQL SQL SQL, OPEN sqlerrd[2] 0, FETCH INSERT, SELECT, UPDATE, DELETE sqlerrd[3] : sqlerrd[4] : SQL sqlerrd[5] :, parse (4) sqlwarn 8 SQL, `W' sqlwarn[0] : sqlwarn[1] :, sqlwarn[2] : SQL AVG(), SUM() NULL sqlwarn[3] : SELECT FETCH sqlwarn[4] : UPDATE DELETE WHERE sqlwarn[5] : PL/SQL EXEC SQL CREATE PROCEDURE, EXEC SQL CREATE FUNCTION, EXEC SQL CREATE PACKAGE, EXEC SQL CREATE PACKAGE BODY sqlwarn[6] : 13

sqlwarn[7] : (5) sqlext SQLCA, (6) sqlglm() SQLCA 70, sqlglm(), SQLCA sqlerrmsqlerrmc sqlglm() void sqlglm ( char *message_buffer, size_t *buffer_size, size_t *message_length);, message_buffer : buffer_size : message_length : 364 WHENEVER SQLCA sqlglm() SQL,, SQLCA (sqlca_error) sqlglm() (sqlglm_error) /* Function sqlca_error Description : Error-Handling Routine using sqlca Return : 0 if no error, 1 error */ int sqlca_error() { /* */ if(sqlcasqlcode == 0) return 0; /*, */ printf("sql Error code %d : %s\n", sqlcasqlcode, sqlcasqlermsqlermc); return 1; /* Function sqlglm_error Desciption: Error-Handling routine using sqlglm() 14

Return: 0 if no error, 1 if error int sqlglm_error() { char error_msg[200]; size_t buf_len, msg_len; /* */ if (sqlcasqlcode == 0) return 0; /*, sqlglm() */ sqlglm(msg, &buf_len, &msg_len); printf( SQL Error: %s \n, msg); return 1; 365 WHENEVER WHENEVER Pro*C SQL Pro*C, SQL, C/C++ Pro*C SQL SQL SQL, WHENEVER, WHENEVER SQL WHENEVER,,, WHENEVER EXEC SQL WHENEVER <condition> <action> ; (1) WHENEVER (consdition) WHENEVER SQLWARNING : SQL, SQLCA sqlwarn[0], sqlcode SQL (true) SQLERROR : SQL, sqlcode 0 (true) NOT FOUND : SELECT FETCH (true) (2) WHENEVER <action> (true)dl, WHENEVER, WHENEVER CONTINUE :, 15

, WHENEVR CONTINUE DO : DO SQL GOTO lagel_name : label_name GOTO STOP : COMMIT (rollback) (3) WHENEVER WHENEVER WHENEVER, SQL WHENEVER WHENEVER WHENEVER, WHENEVER SQL WHENEVER WHENEVER /* WHENEVER */ EXEC SQL WHENEVER SQLERROR STOP; EXEC SQL CONNECT :username IDENTIFIED BY :password; /* WHENEVER */ EXEC SQL WHENEVER SQLERROR CONTINUE; EXEC SQL SELECT emp INTO : emp_name WHERE empno = :emp_number; WHENEVER, WHENEVER SQL WHENEVER, WHENEVER SQL WHENEVER 16