Development summary of ESQL

Source: Internet
Author: User


1 defining or declaring methods
int method (char *arg1,char* arg2 ...);
Implementation method
int method (char *arg1,char* arg2 ...)
EXEC SQL BEGIN DECLARE section;
Char *arg1;
char* arg2;
EXEC SQL END DECLARE section;
{
EXEC SQL BEGIN DECLARE section;
Define your own variables, only the local variables defined here can be used directly in SQL.
EXEC SQL END DECLARE section;
Initialize variables
memset (sqlbuf,0x00,sizeof (SQLBUF));
strncpy (from,to);
DECCVDBL (0,&decimal type variable);
return 0;
}
2 defining structs in. h
As the header file Test.h content is as follows:
...
EXEC SQL BEGIN DECLARE section;
typedef struct lyname{
Decimal x;
Char y[1+1];
Char z[1+1];
int u;
}x;
EXEC SQL END DECLARE section;
...
Proper referencing of struct lyname is required using the below introduction method
EXEC SQL include relative path/test.h;
Instead of
#include <test.h>

3 common print-log methods
printf ("[%s][%d] Gettaxdata start\n", __file__, __line__);
Txlog (Log_info, "current ywrq[%s] =%s\n", __file__, __line__,x,y);
#define Etxlog (Loglevel,format,args ...) txlog (loglevel,format,__file__,__line__,# #args); Txlogflush ()
#define EETXLOG (Loglevel,format) Txlog (loglevel,format,__file__,__line__); Txlogflush ()
Eetxlog (Log_info, "Info:ssnjbbzlzczrdz end. FAILED ");
sprintf (Poutbuf, "Failed:select njgrjh.jhbh[%s]qybh[%s]grbh[%s]sqlcode[%d]"
, Tb_njdl.jhbh,tb_njdl.qybh,val[0],sqlca.sqlcode);
Etxlog (Log_error, "%s", poutbuf);
fprintf (Fplog, "%s|%d|%d|%s|%d|%s\n", strserial,tb_njdl.clcs,nerrnum++, "Database Error", NLINECNT, "Database error");

4 Printing the Decimal public method
void Printdecimaltostring (PTR_VAL,DESC)
EXEC SQL BEGIN DECLARE section;
Decimal *ptr_val;
Char *desc;
EXEC SQL END DECLARE section;
{
Char decimalresult[30];
memset (decimalresult,0x00,sizeof (Decimalresult));
DECTOASC (ptr_val,decimalresult,29,8);//change decmail value to ASC code
Txlog (Log_info, "%s = [%s]\n", __file__, __line__,desc,decimalresult);
printf ("[%s][%d]%s=[%s] \ n", __file__, __line__,desc,decimalresult);
}

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.