Re: Help!
Posted in 1995
CREATE VIEW can be compiled -- see the code below (using a stores database).
If you can't get this to work, then let me know. If you get this to work,
you need to discover what is wrong with your code. I got the list of names
shown below when I did 'SELECT * FROM JollyGood' on a standard version 6.00
stores database (freshly created just for the purposes of this exercise).
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
>Date: Wed, 20 Dec 1995 17:26:40 -0300 (EST)
>From: Flavio Leal Pimentel <flp@di.ufpe.br>
>X-Informix-List-Id: <list.8279>
>
> Hi Everybody,
> I am using esql/c to build programs. I would like
>to know how could i use the "create view" statement into programs. I
>know that neither "prepare" or "$create view" can be compiled. The manuals i
>have does not explain nothing about it.
> Could somebody out there help me?
> Yours sincerely,
> Flavio.
101 Pauli Ludwig
104 Higgins Anthony
106 Watson George
110 Jaeger Roy
111 Keyes Frances
112 Lawson Margaret
116 Parmelee Jean
117 Sipes Arnold
119 Shorter Bob
120 Jewell Fred
121 Wallack Jason
122 O'Brian Cathy
123 Hanlon Marvin
124 Putnum Chris
126 Neelie Eileen
127 Satifer Kim
#include <stdio.h>
#include <stdlib.h>
static void sqlerror()
{
fprintf(stderr, "SQL = %ld\\n", sqlca.sqlcode);
if (sqlca.sqlerrd[1] != 0)
fprintf(stderr, ", ISAM = %ld\\n", (long)sqlca.sqlerrd[1]);
putc('\\n', stderr);
exit(EXIT_FAILURE);
}
int main()
{
EXEC SQL WHENEVER ERROR CALL sqlerror;
EXEC SQL DATABASE Stores;
/* Drop view JollyGood, just in case this program is rerun */
EXEC SQL WHENEVER ERROR CONTINUE;
EXEC SQL DROP VIEW JollyGood;
EXEC SQL WHENEVER ERROR CALL sqlerror;
/* Create view JollyGood */
EXEC SQL CREATE VIEW JollyGood (Customer_Num, Lname, Fname) AS
SELECT C.Customer_Num, C.Lname, C.Fname
FROM Customer C
WHERE 100 < (SELECT SUM(I.Total_Price)
FROM Orders O, Items I
WHERE O.Customer_Num = C.Customer_Num
AND O.Order_Num = I.Order_Num);
EXEC SQL CLOSE DATABASE;
return(EXIT_SUCCESS);
}