Informix ESQL/C uses a example of cursors

Source: Internet
Author: User
Tags informix sql create database

#include <stdio.h>#include<sqlca.h>#include<sqlda.h>#include<sqltypes.h>#include<sqlstype.h>#defineSUCCESS 0Main () {EXEC SQL INCLUDE SQLCA;    EXEC SQL BEGIN DECLARE section; Char*string1; Charstr1[Ten]; Charstr2[Ten]; Charstr3[Ten];         EXEC SQL END DECLARE section;    EXEC SQL CREATE DATABASE example3;     EXEC SQL DATABASE Example3; if(SQLCODE = =SUCCESS) {EXEC SQL CREATE TABLE Student (AlarmChar(6), snameChar(Ten), SexChar(Ten)        ); } EXEC SQL INSERT into Student VALUES ("AAAA","bbbb","1"); EXEC SQL INSERT into Student VALUES ("dddd","dddd","2"); EXEC SQL INSERT into Student VALUES ("CCCC","CCCC","3");    EXEC SQL DECLARE fet_cur CURSOR for SELECT Alarm, sname,sex from Student;  EXEC SQL OPEN fet_cur; printf ("sqlcode=%d\n", SQLCODE);  for(;;) {memset (str1,0,sizeof(STR1)); memset (STR2,0,sizeof(STR2)); memset (STR3,0,sizeof(STR3));    EXEC SQL FETCH fet_cur into:str1,:str2,:str3; if(SQLCODE! =SUCCESS) {printf ("line=%d, sqlcode=%d", __line__, SQLCODE);  Break; } printf ("str1=%s, str2=%s,str2=%s\n", STR1,STR2,STR3);    } EXEC SQL CLOSE fet_cur;    EXEC SQL CLOSE DATABASE; return(0); }

Informix ESQL/C uses a example of cursors

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.