1,7d0
< #ifdef RCSID
< static char *RCSid = 
<    "$Header: sample9.pc \
< 1041100.1 92/12/11 14:32:02 jboyce Generic<base> \
< $ ";
< #endif /* RCSID */
< 
11a5,14
> Modified for use as backend program fro gsql. Of note, the for loop 
> in the main function was removedm, since only process one transaction
> at a time.  Also, output is wrapped in HTML syntax, with attribute
> values that contain "gif" inlined with an anchor to the original.
>  
> MODIFIER:			DATE:
>    James Pitkow 		  Feb 13, 1994
>    Georgia Inst. of Tech.
>    pitkow@cc.gatech.edu
> 
33a37,43
> /* Set the name of your WWW server  */
> #define WWW	"lennon.cc.gatech.edu:4000/images"
> 
> /* Set the account name and password for ORACLE */
> #define ACCOUNT	"cs6450jp"
> #define PASSWD	"all4mark"
> 
61c71,73
< main()
---
> main( argc, argv)
> int	  argc;
> char	**argv;
79,85c91
<     for (;;) 
<     {
<         i = setjmp(jmp_continue);
< 
<         /* Get the statement.  Break on "exit". */
<         if (get_sql_statement() != 0)
<             break;
---
>     i = setjmp(jmp_continue);
87,88c93,94
<         /* Prepare the statement and declare a cursor. */
<         EXEC SQL WHENEVER SQLERROR DO sql_error();
---
>     /* Get the statement. */
>     strncpy( sql_statement, argv[ 1], 1024);
90,104c96,97
<         parse_flag = 1;     /* Set a flag for sql_error(). */
<         EXEC SQL PREPARE S FROM :sql_statement;
<         parse_flag = 0;     /* Unset the flag. */
< 
<         EXEC SQL DECLARE C CURSOR FOR S;
< 
<         /* Set the bind variables for any placeholders in the
<            SQL statement. */
<         set_bind_variables();
< 
<         /* Open the cursor and execute the statement.
<          * If the statement is not a query (SELECT), the
<          * statement processing is completed after the
<          * OPEN.
<          */
---
>     /* Prepare the statement and declare a cursor. */
>     EXEC SQL WHENEVER SQLERROR DO sql_error();
106c99,113
<         EXEC SQL OPEN C USING DESCRIPTOR bind_dp;
---
>     parse_flag = 1;     /* Set a flag for sql_error(). */
>     EXEC SQL PREPARE S FROM :sql_statement;
>     parse_flag = 0;     /* Unset the flag. */
> 
>     EXEC SQL DECLARE C CURSOR FOR S;
> 
>     /* Set the bind variables for any placeholders in the
>        SQL statement. */
>     set_bind_variables();
> 
>     /* Open the cursor and execute the statement.
>      * If the statement is not a query (SELECT), the
>      * statement processing is completed after the
>      * OPEN.
>      */
108,112c115
<         /* Call the function that processes the select-list.
<          * If the statement is not a query, this function
<          * just returns, doing nothing.
<          */
<         process_select_list();
---
>     EXEC SQL OPEN C USING DESCRIPTOR bind_dp;
114,124c117,121
<         /* Tell user how many rows processed. */
<         for (i = 0; i < 8; i++)
<         {
<            if (strncmp(sql_statement, dml_commands[i], 6) == 0)
<            {
<                printf("\n\n%d row%c processed.\n", sqlca.sqlerrd[2],
<                        sqlca.sqlerrd[2] == 1 ? '\0' : 's');
<                break;
<            }
<         }
<     }       /* end of for(;;) statement-processing loop */
---
>     /* Call the function that processes the select-list.
>      * If the statement is not a query, this function
>      * just returns, doing nothing.
>      */
>     process_select_list();
147d143
<     puts("\nHave a good day!\n");
161,164c157
<     printf("\nusername: ");
<     fgets((char *) username.arr, sizeof username.arr, stdin);
<     fflush(stdin);
<     username.arr[strlen((char *) username.arr)-1] = '\0';
---
>     strcpy( username.arr, ACCOUNT);
167,170c160
<     printf("password: ");
<     fgets((char *) password.arr, sizeof password.arr, stdin);
<     fflush(stdin);
<     password.arr[strlen((char *) password.arr) - 1] = '\0';
---
>     strcpy( password.arr, PASSWD);
173d162
< 
178,179d166
<     printf("\nConnected to ORACLE as user %s.\n", username.arr);
< 
183c170
<     fprintf(stderr, "Cannot connect to ORACLE as user %s\n", username.arr);
---
>     printf( "Cannot connect to ORACLE as user %s<BR>\n", username.arr);
228,229c215
<         fprintf(stderr,
<             "Cannot allocate memory for bind descriptor.");
---
>         printf( "Cannot allocate memory for bind descriptor.<BR>");
236,237c222
<         fprintf(stderr,
<             "Cannot allocate memory for select descriptor.");
---
>         printf( "Cannot allocate memory for select descriptor.<BR>");
256,308d240
< 
< get_sql_statement()
< {
<     char *cp, linebuf[256];
<     int iter;
<     int help();
< 
< 
<     for (iter = 2; ;)
<     {
<         if (iter == 2)
<         {
<             printf("\nSQL> ");
<             sql_statement[0] = '\0';
<         }
<         fgets(linebuf, sizeof linebuf, stdin);
<         fflush(stdin);
<         cp = strrchr(linebuf, '\n');
<         if (cp && cp != linebuf)
<             *cp = ' ';
<         else if (cp == linebuf)
<             continue;
<         if (strncmp(linebuf, "exit", 4) == 0 ||
<             strncmp(linebuf, "EXIT", 4) == 0)
<         {
<             return -1;
<         }
<         else if (linebuf[0] == '?' ||
<             strncmp(linebuf, "help", 4) == 0 ||
<             strncmp(linebuf, "HELP", 4) == 0)
<         {
<             help();
<             iter = 2;
<             continue;
<         }
<         strcat(sql_statement, linebuf);
< 
<         if ((cp = strrchr(sql_statement, ';')) != (char *) NULL)
<         {
<             *cp = '\0';
<             break;
<         }
<         else
<         {
<             printf("%3d  ", iter++);
<         }
<     }
<     printf( "the sql statemant is: %s\n", sql_statement);
<     return 0;
< }
< 
< 
< 
324c256
<         printf ("\nToo many bind variables (%d), maximum is %d\n.",
---
>         printf ("\nToo many bind variables (%d), maximum is %d<BR>\n.",
395,401d326
<     if ((strncmp(sql_statement, "SELECT", 6) != 0) &&
<         (strncmp(sql_statement, "select", 6) != 0))
<     {
<         select_dp->F = 0;
<         return;
<     }
< 
408c333
<     
---
>       
415c340
<         printf ("\nToo many select-list items (%d), maximum is %d\n",
---
>         printf ("\nToo many select-list items (%d), maximum is %d<BR>\n",
458,459c383,384
<     
<     printf ("\n");
---
>    
>     printf ("<HR><PRE>\n");
520c445
<     printf ("\n\n");
---
>     printf ("<HR>\n");
535c460
<             if (*select_dp->I[i] < 0)
---
>             if (*select_dp->I[i] < 0) 
537,538c462,469
<             else
<                 printf ("%-*.*s ", (int)select_dp->L[i],
---
>             else {
>    
>                 /*
>                  * See if the field contains 'gif' and wrap if does
>                  */
> 		if ( strstr( select_dp->V[i], "gif")) {
> 		   printf("<A HREF=http://%s/", WWW);
>                    printf("%-*.*s ", (int)select_dp->L[i],
539a471,479
> 		   printf("><IMG SRC=http://%s/", WWW);
>                    printf( "%-*.*s ", (int)select_dp->L[i],
>                         (int)select_dp->L[i], select_dp->V[i]);
> 		   printf( "></A>");
>                 }
>                 else
>                    printf ("%-*.*s ", (int)select_dp->L[i],
>                         (int)select_dp->L[i], select_dp->V[i]);
>             }
541c481
<         printf ("\n");
---
>         printf ("<HR>\n");
542a483
> 
551,556c492,497
<     printf("\nEnter a SQL statement at the SQL> prompt.\n");
<     printf("Use standard SQL syntax, not embedded SQL.\n");
<     printf("Statements can be continued over several lines, but \n");
<     printf("always terminate the statement with a semicolon.\n");
<     printf("Typing \"exit\" (no semicolon needed) exits the program.\n");
<     printf("You typed \"?\" or \"help\" to get this message.\n\n");
---
>     printf("\nEnter a SQL statement at the SQL> prompt.<BR>\n");
>     printf("Use standard SQL syntax, not embedded SQL.<BR>\n");
>     printf("Statements can be continued over several lines, but <BR> \n");
>     printf("always terminate the statement with a semicolon.<BR>\n");
>     printf("Typing \"exit\" (no semicolon needed) exits the program.<BR>\n");
>     printf("You typed \"?\" or \"help\" to get this message.<BR>\n\n");
572a514,517
> 
>     /* I do not like thelongjmp approach for GSQL implementation.
>        It causes ORACLE to loop indefinitely - Jim Pitkow */
> /*
573a519,520
> */
>     exit( -2);
