Created
June 10, 2012 14:03
-
-
Save cx20/2905779 to your computer and use it in GitHub Desktop.
Hello, ESQL/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> | |
int main( int argc, char* argv[] ) | |
{ | |
EXEC SQL BEGIN DECLARE SECTION; | |
char szServerDatabase[] = "(local).pubs"; | |
char szLoginPassword[] = "sa.P@ssW0rd"; | |
char szCommand[] = "SELECT 'Hello, ESQL/C World!' AS Message"; | |
char message[32] = { 0 }; | |
EXEC SQL END DECLARE SECTION; | |
EXEC SQL CONNECT TO :szServerDatabase USER :szLoginPassword; | |
EXEC SQL DECLARE C1 CURSOR FOR stmt; | |
EXEC SQL PREPARE stmt FROM :szCommand; | |
EXEC SQL OPEN C1; | |
while ( SQLCODE == 0 ) | |
{ | |
EXEC SQL FETCH C1 INTO :message; | |
if ( SQLCODE == 0 ) | |
{ | |
printf( "Message\n" ); | |
printf( "--------------------\n" ); | |
printf( "%s\n", message ); | |
} | |
} | |
EXEC SQL CLOSE C1; | |
EXEC SQL DISCONNECT ALL; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment