Created
June 10, 2012 14:26
-
-
Save cx20/2905907 to your computer and use it in GitHub Desktop.
Hello, Pro*C/C++ World!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
EXEC SQL INCLUDE SQLCA; | |
int main( int argc, char* argv[] ) | |
{ | |
EXEC SQL BEGIN DECLARE SECTION; | |
char username[] = "scott"; | |
char password[] = "tiger"; | |
char message[32]; | |
EXEC SQL END DECLARE SECTION; | |
EXEC SQL CONNECT :username IDENTIFIED BY :password; | |
EXEC SQL DECLARE C1 CURSOR FOR | |
SELECT 'Hello, Pro*C/C++ World!' AS Message FROM DUAL; | |
EXEC SQL OPEN C1; | |
EXEC SQL WHENEVER NOT FOUND DO BREAK; | |
for (;;) | |
{ | |
EXEC SQL FETCH C1 INTO :message; | |
printf("Message\n"); | |
printf("-----------------------\n"); | |
printf("%s\n", message); | |
} | |
EXEC SQL CLOSE C1; | |
EXEC SQL COMMIT RELEASE; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment