際際滷

際際滷Share a Scribd company logo
仂亞舒仄仄亳亠仄亶 从仍亳亠仆  ORACLE 丐亠仆仂仍仂亞亳  Pro C/C++
于舒 于亳亟舒 仗仂亞舒仄仄仆仂亞仂 亳仆亠亠亶舒 亠亟从仂仄仗亳仍仂 CALL - 亳仆亠亠亶
仂仂亳仆于舒 亳 仆亠亟仂舒从亳 仗仂亟仂亟仂于 弌丼 乘 Call  亳仆亠亠亶 亠弍亠 亟亠舒仍仆仂亞仂 亰仆舒仆亳 仗仂亠亟 亳 仆从亳亶 : 仆舒亰于舒仆亳 ; 从仂仍亳亠于仂 仗舒-仂于; 亳仗 仗舒舒仄亠仂于; 亰仆舒仆亳亠 从仂亟仂于 于仂亰于舒舒;  仂弍舒弍仂从舒 亳从仍ム亳亠仍仆 亳舒亳亶; 亳 .仗. 亠仄 亳 亟仂亰舒舒 仆舒 舒亰舒弍仂从 - 于仂亰舒舒亠 亊丐 仗仂仍亰仂于舒 仗仂亠 : 仆舒亞仍磲仆仂; 仗仂仆仆仂; 从亳仂于舒仆仆仂 亟仆舒从仂, 仄仂弍亳仍仆仂 仗仂亞舒仄仄  仄亠仆亠, 舒从 从舒从 亠弍亠 仗亠亟从仂仄仗亳仍仂  Oracle , 仗仂亰于仂仍ム亳亶 仂亳 从仂亟 亳仂亟仆仂亶 仗仂亞舒仄仄  仆舒 弌 / 弌++,  Fortran, Ada, Cobol, Pascal  亳 亟.
仂亰仄仂亢仆仂亳 仗亠亟从仂仄仗亳仍亳亳 亟亳仆 于亰仂于 从  Oracle  舒于仂仄舒亳亠从亳 仗亠仂弍舒亰亠 于 仆亠从仂仍从仂 于亰仂于仂于 仗仂亠亟(仆从亳亶). 亟仆舒 仗仂亞舒仄仄舒 仄仂亢亠 仗亳仄亠仆 亟仍 舒弍仂  舒亰仆仄亳  亠从仂仍从仂 仗仂亞舒仄仄 仄仂亞 弍 仂亟亠仍仆仂 仗亠亟从仂仄仗亳仍亳仂于舒仆 亳 仂于仄亠仆仂 于仗仂仍仆亠仆 (仂弍舒仆).
亅舒仗 舒亰舒弍仂从亳 仗亳仍仂亢亠仆亳亶 仂仍舒亟从舒
舒于亳仍舒 亳 仂亞仍舒亠仆亳 亠仆仂仍仂亞亳亳  Pro C/C++  仗仂亞舒仄仄 仆舒  Pro C/C++  仄仂亢亠 弍 于从仍ム亠仆 仍ミ頴笑 仂仗亠舒仂  SQL 亠亠亟 于亠仄亳 仂仗亠舒仂舒仄亳  SQL  舒于亳 仗亠亳从  EXEC SQL (  亟仍 仆亠从仂仂 仆亳从舒仍仆 从仂仆从亳亶  EXEC ORACLE). 仗亠舒仂  SQL  亟亠仍 仆舒  亟亠从仍舒舒亳于仆亠  亳  于仗仂仍仆磳仄亠. 仂仍亠 亳仗仂仍仆亠仆亳 于仗仂仍仆磳仄 仂仗亠舒仂仂于 从仂亟 于仂亰于舒舒 亰舒仆仂 于  SQLCA 亠从仍舒舒亳于仆亠 仂仗亠舒仂 仆亠 亳亰仄亠仆ム  SQLCA
弌从舒 仗仂亞舒仄仄 仆舒  Pro C/C++
弌亠从亳  DECLARE 亟亳仆于亠仆仆舒 仂亢亠 亳仄亠 仍仂从舒仍仆 亳仍亳 亞仍仂弍舒仍仆 于亳亟亳仄仂 EXEC SQL BEGIN DECLARE SECTION; 仗亳舒仆亳亠 仗亠亠仄亠仆仆 仂弍仄亠仆舒 亟舒仆仆仄亳 EXEC SQL END DECLARE SECTION;
亳仄亠 EXEC SQL BEGIN DECLARE SECTION; Int n,no; Char name[11]; EXEC SQL END DECLARE SECTION; Void main(){  EXEC SQL select id, fio into :n,:name from personal where num_o = :no; 仍 仂仍亳亳 仗亠亠仄亠仆仆 仂 舒亳弍仂于 于  SQL  亰舒仗仂舒 亳仗仂仍亰亠 亳仄于仂仍  : , 仗亠亠亟 亳仄亠仆亠仄 仗亠亠仄亠仆仆仂亶.
仍 仂从 仗亠亠仄亠仆仆仂亶 亟仍亳仆 于 亠从亳亳  DECLARE  亳仗仂仍亰亠 仗亠亳舒仍仆亶 亳仗  VARCHAR. 亳仄亠 VARCHAR j[40]; 于仂仄舒亳亠从亳 仗仂仂亢亟舒亠 Struct { unsigned short int len; unsigned char arr[40]; } j; 仂亢仆仂 亳仗仂仍亰仂于舒 于 仗仂亞舒仄仄亠 j.len   舒从亳亠从舒 亟仍亳仆舒 亳仆亞舒 j.arr   从舒亰舒亠仍 仆舒 仄舒亳于 仂亟亠亢亳仄仂亞仂
INCLUDE SQLCA EXEC SQL INCLUDE SQLCA; 弍仍舒  SQL 弌 A  仂亟亠亢亳 : 仍舒亞亳 仗亠亟仗亠亢亟亠仆亳亶 ; 亳仆仂仄舒亳 仂 仂弍亳; 从仂亟 仂亳弍仂从; 亠从 亟亳舒亞仆仂亳从亳 仂亳弍仂从; 亳 亟. 仍亢亠弍仆 亳仆仂仄舒亳.
亳仄亠  .. If( sqlca.sqlcode == 0 ) continue; // 仗亠仆仂亠 亰舒于亠亠仆亳亠  sql  else if( sqlca.sqlcode < 0 ) cout <<  亳弍从舒 于仗仂仍仆亠仆亳 ; else cout <<   弍舒仆舒 仗仂仍亠亟仆 仂从舒 ;
CONNECT 弌仂亠亟亳仆亠仆亳亠   ORACLE Server EXEC SQL CONNECT :oralogpass;
亳仄亠 EXEC SQL BEGIN DECLARE SECTION; Varchar oralogpass[40]; EXEC SQL END DECLARE SECTION;  Strcpy(oralogpass.arr,o01/o01@stud); oralogpass.len=strlen(oralogpass.arr); EXEC SQL CONNECT :oralogpass;  .
丐亠仍仂 仗仂亞舒仄仄 C 舒仆亟舒仆亠 仂仗亠舒仂 磶从舒  C/C++  ; 仗亠舒仂  SQL (select,delete,insert,update) ; 仂仆仂仍 舒仗亠亟亠仍亠仆仆仂亶 仂弍舒弍仂从亳 亟舒仆仆 EXEC SQL DECLARE < 亳仄 > STATEMENT; 弌于磶 亳 仗舒于仍亠仆亳亠 舒仗亠亟亠仍亠仆仆仂亶  EXEC SQL DECLARE < 亳仄 > DATABASE; 亰仄亠仆亠仆亳亠 舒仆亟舒仆 舒仆仂于仂从  EXEC ORACLE OPTION ( option= 亰仆舒亠仆亳亠  );
仆仂亢亠于亠仆仆亶 亳 亠亟亳仆亳仆亶 于弍仂  亳仗仂仍亰仂于舒仆亳亠仄 仄舒亳于仂于 仄 从舒亰舒亠仍亠亶. 仗亠舒仂  仄舒亳于(从舒亰舒亠仍)  仗仂舒 仗亠亠仄亠仆仆舒 Select  亰舒亞仂仍仂于仂从  仄仂亢仆仂  仄仂亢仆仂 Select .. Where  仆亠仍亰    仄仂亢仆仂 Insert.. Values()   仄仂亢仆仂 仄仂亢仆仂 Update .. Set.. where   仄仂亢仆仂 仂亟仆仂于. 仄仂亢仆仂 仂亟仆仂于.
亳仄亠 EXEC SQL BEGIN DECLARE SECTION; char name[100][100]; int n[100]; Float sal[100]; EXEC SQL END DECLARE SECTION;  .. EXEC SQL SELECT  fio,id into :name,:n FROM personal; // ok! EXEC SQL SELECT  fio,id into :name,:n FROM personal WHERE many = :sal; //  仆亠于亠仆亶 仂仗亠舒仂 EXEC SQL INSERT INTO personal(fio,id,many) VALUES(:name, :n, :sal); // ok! EXEC SQL UPDATE SET many = :sal WHERE id = :n; //ok! EXEC SQL UPDATE SET many = :sal WHERE id = :n[0]; // no!
仗亠舒仂  COMMIT WORK  亰舒于亠舒亠 舒仆亰舒从亳 EXEC SQL COMMIT WORK; 仗亠舒仂  COMMIT WORK RELEASE  仂亠于仍磳  DISCONNECT EXEC SQL COMMIT WORK RELEASE;
亳仄亠 仗仂亞舒仄仄, 从仂仂舒 仗仂亰于仂仍磳 亰舒亟舒 (  从仍舒于亳舒 ) 仆仂仄亠舒 仂亟仆亳从仂于 亳 亳 仂从仍舒亟, 舒 亰舒亠仄 亟仂弍舒于仍磳 亳 亟舒仆仆亠 于 舒弍仍亳 #include <stdio.h> #include <string.h> EXEC SQL BEGIN DECLARE SECTION; varchar log_pass[40]; int loop,n[100]; float many[100]; EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE   sqlca.h; main() { int i,ret; strcpy(log_pass.arr,o01/o01@stud); log_pass.len = strlen(log_pass.arr); EXEC SQL CONNECT :log_pass; for(i=0;i<100;i++) { ret=scanf(%d %f
, &n[i],&many[i]); if(ret == EOF|| ret ==0|| n[i]==0) break; } loop=i; EXEC SQL FOR :loop INSERT INTO sotrud (Tnum,okl) VALUES(:n,:many); EXEC SQL COMMIT WORK RELEASE; }

More Related Content

C++ with DB

  • 1. 仂亞舒仄仄亳亠仄亶 从仍亳亠仆 ORACLE 丐亠仆仂仍仂亞亳 Pro C/C++
  • 2. 于舒 于亳亟舒 仗仂亞舒仄仄仆仂亞仂 亳仆亠亠亶舒 亠亟从仂仄仗亳仍仂 CALL - 亳仆亠亠亶
  • 3. 仂仂亳仆于舒 亳 仆亠亟仂舒从亳 仗仂亟仂亟仂于 弌丼 乘 Call 亳仆亠亠亶 亠弍亠 亟亠舒仍仆仂亞仂 亰仆舒仆亳 仗仂亠亟 亳 仆从亳亶 : 仆舒亰于舒仆亳 ; 从仂仍亳亠于仂 仗舒-仂于; 亳仗 仗舒舒仄亠仂于; 亰仆舒仆亳亠 从仂亟仂于 于仂亰于舒舒; 仂弍舒弍仂从舒 亳从仍ム亳亠仍仆 亳舒亳亶; 亳 .仗. 亠仄 亳 亟仂亰舒舒 仆舒 舒亰舒弍仂从 - 于仂亰舒舒亠 亊丐 仗仂仍亰仂于舒 仗仂亠 : 仆舒亞仍磲仆仂; 仗仂仆仆仂; 从亳仂于舒仆仆仂 亟仆舒从仂, 仄仂弍亳仍仆仂 仗仂亞舒仄仄 仄亠仆亠, 舒从 从舒从 亠弍亠 仗亠亟从仂仄仗亳仍仂 Oracle , 仗仂亰于仂仍ム亳亶 仂亳 从仂亟 亳仂亟仆仂亶 仗仂亞舒仄仄 仆舒 弌 / 弌++, Fortran, Ada, Cobol, Pascal 亳 亟.
  • 4. 仂亰仄仂亢仆仂亳 仗亠亟从仂仄仗亳仍亳亳 亟亳仆 于亰仂于 从 Oracle 舒于仂仄舒亳亠从亳 仗亠仂弍舒亰亠 于 仆亠从仂仍从仂 于亰仂于仂于 仗仂亠亟(仆从亳亶). 亟仆舒 仗仂亞舒仄仄舒 仄仂亢亠 仗亳仄亠仆 亟仍 舒弍仂 舒亰仆仄亳 亠从仂仍从仂 仗仂亞舒仄仄 仄仂亞 弍 仂亟亠仍仆仂 仗亠亟从仂仄仗亳仍亳仂于舒仆 亳 仂于仄亠仆仂 于仗仂仍仆亠仆 (仂弍舒仆).
  • 6. 舒于亳仍舒 亳 仂亞仍舒亠仆亳 亠仆仂仍仂亞亳亳 Pro C/C++ 仗仂亞舒仄仄 仆舒 Pro C/C++ 仄仂亢亠 弍 于从仍ム亠仆 仍ミ頴笑 仂仗亠舒仂 SQL 亠亠亟 于亠仄亳 仂仗亠舒仂舒仄亳 SQL 舒于亳 仗亠亳从 EXEC SQL ( 亟仍 仆亠从仂仂 仆亳从舒仍仆 从仂仆从亳亶 EXEC ORACLE). 仗亠舒仂 SQL 亟亠仍 仆舒 亟亠从仍舒舒亳于仆亠 亳 于仗仂仍仆磳仄亠. 仂仍亠 亳仗仂仍仆亠仆亳 于仗仂仍仆磳仄 仂仗亠舒仂仂于 从仂亟 于仂亰于舒舒 亰舒仆仂 于 SQLCA 亠从仍舒舒亳于仆亠 仂仗亠舒仂 仆亠 亳亰仄亠仆ム SQLCA
  • 8. 弌亠从亳 DECLARE 亟亳仆于亠仆仆舒 仂亢亠 亳仄亠 仍仂从舒仍仆 亳仍亳 亞仍仂弍舒仍仆 于亳亟亳仄仂 EXEC SQL BEGIN DECLARE SECTION; 仗亳舒仆亳亠 仗亠亠仄亠仆仆 仂弍仄亠仆舒 亟舒仆仆仄亳 EXEC SQL END DECLARE SECTION;
  • 9. 亳仄亠 EXEC SQL BEGIN DECLARE SECTION; Int n,no; Char name[11]; EXEC SQL END DECLARE SECTION; Void main(){ EXEC SQL select id, fio into :n,:name from personal where num_o = :no; 仍 仂仍亳亳 仗亠亠仄亠仆仆 仂 舒亳弍仂于 于 SQL 亰舒仗仂舒 亳仗仂仍亰亠 亳仄于仂仍 : , 仗亠亠亟 亳仄亠仆亠仄 仗亠亠仄亠仆仆仂亶.
  • 10. 仍 仂从 仗亠亠仄亠仆仆仂亶 亟仍亳仆 于 亠从亳亳 DECLARE 亳仗仂仍亰亠 仗亠亳舒仍仆亶 亳仗 VARCHAR. 亳仄亠 VARCHAR j[40]; 于仂仄舒亳亠从亳 仗仂仂亢亟舒亠 Struct { unsigned short int len; unsigned char arr[40]; } j; 仂亢仆仂 亳仗仂仍亰仂于舒 于 仗仂亞舒仄仄亠 j.len 舒从亳亠从舒 亟仍亳仆舒 亳仆亞舒 j.arr 从舒亰舒亠仍 仆舒 仄舒亳于 仂亟亠亢亳仄仂亞仂
  • 11. INCLUDE SQLCA EXEC SQL INCLUDE SQLCA; 弍仍舒 SQL 弌 A 仂亟亠亢亳 : 仍舒亞亳 仗亠亟仗亠亢亟亠仆亳亶 ; 亳仆仂仄舒亳 仂 仂弍亳; 从仂亟 仂亳弍仂从; 亠从 亟亳舒亞仆仂亳从亳 仂亳弍仂从; 亳 亟. 仍亢亠弍仆 亳仆仂仄舒亳.
  • 12. 亳仄亠 .. If( sqlca.sqlcode == 0 ) continue; // 仗亠仆仂亠 亰舒于亠亠仆亳亠 sql else if( sqlca.sqlcode < 0 ) cout << 亳弍从舒 于仗仂仍仆亠仆亳 ; else cout << 弍舒仆舒 仗仂仍亠亟仆 仂从舒 ;
  • 13. CONNECT 弌仂亠亟亳仆亠仆亳亠 ORACLE Server EXEC SQL CONNECT :oralogpass;
  • 14. 亳仄亠 EXEC SQL BEGIN DECLARE SECTION; Varchar oralogpass[40]; EXEC SQL END DECLARE SECTION; Strcpy(oralogpass.arr,o01/o01@stud); oralogpass.len=strlen(oralogpass.arr); EXEC SQL CONNECT :oralogpass; .
  • 15. 丐亠仍仂 仗仂亞舒仄仄 C 舒仆亟舒仆亠 仂仗亠舒仂 磶从舒 C/C++ ; 仗亠舒仂 SQL (select,delete,insert,update) ; 仂仆仂仍 舒仗亠亟亠仍亠仆仆仂亶 仂弍舒弍仂从亳 亟舒仆仆 EXEC SQL DECLARE < 亳仄 > STATEMENT; 弌于磶 亳 仗舒于仍亠仆亳亠 舒仗亠亟亠仍亠仆仆仂亶 EXEC SQL DECLARE < 亳仄 > DATABASE; 亰仄亠仆亠仆亳亠 舒仆亟舒仆 舒仆仂于仂从 EXEC ORACLE OPTION ( option= 亰仆舒亠仆亳亠 );
  • 16. 仆仂亢亠于亠仆仆亶 亳 亠亟亳仆亳仆亶 于弍仂 亳仗仂仍亰仂于舒仆亳亠仄 仄舒亳于仂于 仄 从舒亰舒亠仍亠亶. 仗亠舒仂 仄舒亳于(从舒亰舒亠仍) 仗仂舒 仗亠亠仄亠仆仆舒 Select 亰舒亞仂仍仂于仂从 仄仂亢仆仂 仄仂亢仆仂 Select .. Where 仆亠仍亰 仄仂亢仆仂 Insert.. Values() 仄仂亢仆仂 仄仂亢仆仂 Update .. Set.. where 仄仂亢仆仂 仂亟仆仂于. 仄仂亢仆仂 仂亟仆仂于.
  • 17. 亳仄亠 EXEC SQL BEGIN DECLARE SECTION; char name[100][100]; int n[100]; Float sal[100]; EXEC SQL END DECLARE SECTION; .. EXEC SQL SELECT fio,id into :name,:n FROM personal; // ok! EXEC SQL SELECT fio,id into :name,:n FROM personal WHERE many = :sal; // 仆亠于亠仆亶 仂仗亠舒仂 EXEC SQL INSERT INTO personal(fio,id,many) VALUES(:name, :n, :sal); // ok! EXEC SQL UPDATE SET many = :sal WHERE id = :n; //ok! EXEC SQL UPDATE SET many = :sal WHERE id = :n[0]; // no!
  • 18. 仗亠舒仂 COMMIT WORK 亰舒于亠舒亠 舒仆亰舒从亳 EXEC SQL COMMIT WORK; 仗亠舒仂 COMMIT WORK RELEASE 仂亠于仍磳 DISCONNECT EXEC SQL COMMIT WORK RELEASE;
  • 19. 亳仄亠 仗仂亞舒仄仄, 从仂仂舒 仗仂亰于仂仍磳 亰舒亟舒 ( 从仍舒于亳舒 ) 仆仂仄亠舒 仂亟仆亳从仂于 亳 亳 仂从仍舒亟, 舒 亰舒亠仄 亟仂弍舒于仍磳 亳 亟舒仆仆亠 于 舒弍仍亳 #include <stdio.h> #include <string.h> EXEC SQL BEGIN DECLARE SECTION; varchar log_pass[40]; int loop,n[100]; float many[100]; EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE sqlca.h; main() { int i,ret; strcpy(log_pass.arr,o01/o01@stud); log_pass.len = strlen(log_pass.arr); EXEC SQL CONNECT :log_pass; for(i=0;i<100;i++) { ret=scanf(%d %f , &n[i],&many[i]); if(ret == EOF|| ret ==0|| n[i]==0) break; } loop=i; EXEC SQL FOR :loop INSERT INTO sotrud (Tnum,okl) VALUES(:n,:many); EXEC SQL COMMIT WORK RELEASE; }