返回首页

gbase数据、南大通用产品文档:GBase8aformat

更新日期:2024年09月11日

功能
该参数控制导出数据文件的数据格式。
说明
当设置为3 时,导出数据为无转义的文本格式。
示例
示例1
--format='3'
示例2
-m'3'
参数说明
表4- 119 参数说明

GBase 8a MPP Cluster 产品手册
4 管理员指南
文档版本953(2022-04-10)
南大通用数据技术股份有限公司
562
参数全称
参数简称
取值范围
默认值
format
m
3
3

ifx_int8cvdec() 函数将 decimal 类型值转换为 int8 类型值。
语法
mint ifx_int8cvdec(dec_val, int8_val)

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 728 -
dec_t *dec_val;
ifx_int8_t *int8_val;
dec_val
指向 ifx_int8cvdec() 转换为 int8 类型值的 decimal 结构的指针。
int8_val
指向 ifx_int8cvdec() 放置转换的结果处的 int8 结构的指针。

返回代码
0
转换成功。
<0
转换失败。

示例
demo 目录中的文件 int8cdec.ec 包含下列样例程序。
/*
* ifx_int8cvdec.ec *

The following program converts two INT8s types to DECIMALS and displays the results.
*/

#include

EXEC SQL include decimal;
EXEC SQL include "int8.h";

char string1[] = "2949.3829398204382";
char string2[] = "3238299493";
char result[41];

main()
{

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 729 -
mint x;
ifx_int8_t n;
dec_t num;

printf("IFX_INT8CVDEC Sample ESQL Program running.\n\n");

if (x = deccvasc(string1, strlen(string1), #))
{
printf("Error %d in converting string1 to DECIMAL\n", x);
exit(1);
}
if (x = ifx_int8cvdec(#, &n))
{
printf("Error %d in converting DECIMAL1 to INT8\n", x);
exit(1);
}

/* Convert the INT8 to ascii and display it. Note that the digits to the right of the decimal
are truncated in the conversion.
*/

if (x = ifx_int8soasc(&n, result, sizeof(result)))
{
printf("Error %d in converting INT8 to string\n", x);
exit(1);
}
result[40] = '\0';
printf("String 1 Value = %s\n", string1);
printf(" INT8 type value = %s\n", result);
if (x = deccvasc(string2, strlen(string2), #))
{
printf("Error %d in converting string2 to DECIMAL\n", x);
exit(1);

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 730 -
}
if (x = ifx_int8cvdec(#, &n))
{
printf("Error %d in converting DECIMAL2 to INT8\n", x);
exit(1);
}
printf("String 2 = %s\n", string2);

/* Convert the INT8 to ascii to display value. */

if (x = ifx_int8soasc(&n, result, sizeof(result)))
{
printf("Error %d in converting INT8 to string\n", x);
exit(1);
}
result[40] = '\0';
printf(" INT8 type value = %s\n", result);

printf("\nIFX_INT8CVDEC Sample Program over.\n\n");
exit(0);
}
输出
IFX_INT8CVDEC Sample ESQL Program running.

String 1 Value = 2949.3829398204382
INT8 type value = 2949
String 2 = 3238299493
INT8 type value = 3238299493
IFX_INT8CVDEC Sample Program over.

编写如下servlet,然后把项目部署到GlassFish 上。
package com.gbase.glassfish;


GBase UP 产品手册 6 应用开发指南
文档版本04(2021-04-21) 南大通用数据技术股份有限公司 1065
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;

public class TestServlet extends HttpServlet {

/**
*
*/
private static final long serialVersionUID = 1L;

/**
* The doGet method of the servlet.

*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {

Connection conn = null;
ResultSet rs = null;
Statement st = null;
try {
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("gbase2");
conn = ds.getConnection();
st = conn.createStatement();
rs = st.executeQuery("select id,name,age,department from emp");
while(rs.next()){

GBase UP 产品手册 6 应用开发指南
文档版本04(2021-04-21) 南大通用数据技术股份有限公司 1066
System.out.println("员工id:"+rs.getInt(1)+" 员工姓名:"+rs.getString(2)+"
员工年龄:"+rs.getInt(3)+" 员工部门:"+rs.getString(4));
}
} catch (Exception e) {
e.printStackTrace();
}finally{
if(rs != null){
try {
rs.close();
rs = null;
} catch (SQLException e) {
e.printStackTrace();
}
if(st != null){
try {
st.close();
st = null;
} catch (SQLException e) {
e.printStackTrace();
}
if(conn != null){
try {







conn.close();







conn = null;
} catch (SQLException e) {







e.printStackTrace();
}
}
}
}
}
}

/**
* The doPost method of the servlet.

*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client

GBase UP 产品手册 6 应用开发指南
文档版本04(2021-04-21) 南大通用数据技术股份有限公司 1067
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)


throws ServletException, IOException {

this.doGet(request, response);
}
}
web.xml 文件如下:


xmlns="http://java.sun.com/xml/ns/javaee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

This is the description of my J2EE component
This is the display name of my J2EE component
TestServlet
com.gbase.glassfish.TestServlet



TestServlet
/TestServlet


index.jsp


部署成功后,启动glassfish 服务器,访问如下url:
http://localhost:8088/TestGBase/TestServlet
该测试用例会打印出数据库为test 表为emp 中的内容。

GBase UP 产品手册 6 应用开发指南
文档版本04(2021-04-21) 南大通用数据技术股份有限公司 1068