Skip to content

Instantly share code, notes, and snippets.

@cx20
Created June 10, 2012 14:26
Show Gist options
  • Save cx20/2905907 to your computer and use it in GitHub Desktop.
Save cx20/2905907 to your computer and use it in GitHub Desktop.
Hello, Pro*C/C++ World!
#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