http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/client_install/src/resources/source/basicsql.cpp ---------------------------------------------------------------------- diff --git a/docs/client_install/src/resources/source/basicsql.cpp b/docs/client_install/src/resources/source/basicsql.cpp index 9215a5d..aa4f2d8 100644 --- a/docs/client_install/src/resources/source/basicsql.cpp +++ b/docs/client_install/src/resources/source/basicsql.cpp @@ -1,394 +1,456 @@ -// @@@ START COPYRIGHT @@@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// -// @@@ END COPYRIGHT @@@ - -#ifdef __linux - #include <unistd.h> -#else - #include <windows.h> - #include <tchar.h> -#endif - -//#include <stdarg.h> - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <assert.h> - -#include <sql.h> -#include <sqlext.h> - -SQLHENV henv; -SQLHDBC hdbc; -SQLHSTMT hstmt; -SQLHWND hWnd; - -#define MAX_SQLSTRING_LEN 1000 -#define STATE_SIZE 6 -#define MAX_CONNECT_STRING 256 -#define TRUE 1 -#define FALSE 0 -#define ARGS "d:u:p:" - -const char *SqlRetText(int rc) -{ - static char buffer[80]; - switch (rc) - { - case SQL_SUCCESS: - return("SQL_SUCCESS"); - case SQL_SUCCESS_WITH_INFO: - return("SQL_SUCCESS_WITH_INFO"); - case SQL_NO_DATA: - return("SQL_NO_DATA"); - case SQL_ERROR: - return("SQL_ERROR"); - case SQL_INVALID_HANDLE: - return("SQL_INVALID_HANDLE"); - case SQL_STILL_EXECUTING: - return("SQL_STILL_EXECUTING"); - case SQL_NEED_DATA: - return("SQL_NEED_DATA"); - } - sprintf(buffer,"SQL Error %d",rc); - return(buffer); -} - -void CleanUp() -{ - printf("\nConnect Test FAILED!!!\n"); - if(hstmt != SQL_NULL_HANDLE) - SQLFreeHandle(SQL_HANDLE_STMT,hstmt); - if(hdbc != SQL_NULL_HANDLE) - { - SQLDisconnect(hdbc); - SQLFreeHandle(SQL_HANDLE_DBC,hdbc); - } - if(henv != SQL_NULL_HANDLE) - SQLFreeHandle(SQL_HANDLE_ENV,henv); - exit(EXIT_FAILURE); -} - -void LogDiagnostics(const char *sqlFunction, SQLRETURN rc, bool exitOnError=true) -{ - SQLRETURN diagRC = SQL_SUCCESS; - SQLSMALLINT recordNumber; - SQLINTEGER nativeError; - SQLCHAR messageText[SQL_MAX_MESSAGE_LENGTH]; - SQLCHAR sqlState[6]; - int diagsPrinted = 0; - bool printedErrorLogHeader = false; - - printf("Function %s returned %s\n", sqlFunction, SqlRetText(rc)); - - /* Log any henv Diagnostics */ - recordNumber = 1; - do - { - diagRC = SQLGetDiagRec( SQL_HANDLE_ENV - , henv - , recordNumber - , sqlState - , &nativeError - , messageText - , sizeof(messageText) - , NULL - ); - if(diagRC==SQL_SUCCESS) - { - if(!printedErrorLogHeader) - { - printf("Diagnostics associated with environment handle:\n"); - printedErrorLogHeader = true; - } - printf("\n\tSQL Diag %d\n\tNative Error: %ld\n\tSQL State: %s\n\tMessage: %s\n", - recordNumber,nativeError,sqlState,messageText); - } - recordNumber++; - } while (diagRC==SQL_SUCCESS); - - /* Log any hdbc Diagnostics */ - recordNumber = 1; - printedErrorLogHeader = false; - do - { - diagRC = SQLGetDiagRec( SQL_HANDLE_DBC - , hdbc - , recordNumber - , sqlState - , &nativeError - , messageText - , sizeof(messageText) - , NULL - ); - if(diagRC==SQL_SUCCESS) - { - if(!printedErrorLogHeader) - { - printf("Diagnostics associated with connection handle:\n"); - printedErrorLogHeader = true; - } - printf("\n\tSQL Diag %d\n\tNative Error: %ld\n\tSQL State: %s\n\tMessage: %s\n", - recordNumber,nativeError,sqlState,messageText); - } - recordNumber++; - } while (diagRC==SQL_SUCCESS); - - /* Log any hstmt Diagnostics */ - recordNumber = 1; - printedErrorLogHeader = false; - do - { - diagRC = SQLGetDiagRec( SQL_HANDLE_STMT - , hstmt - , recordNumber - , sqlState - , &nativeError - , messageText - , sizeof(messageText) - , NULL - ); - if(diagRC==SQL_SUCCESS) - { - if(!printedErrorLogHeader) - { - printf("Diagnostics associated with statmement handle:\n"); - printedErrorLogHeader = true; - } - printf("\n\tSQL Diag %d\n\tNative Error: %ld\n\tSQL State: %s\n\tMessage: %s\n", - recordNumber,nativeError,sqlState,messageText); - } - recordNumber++; - } while (diagRC==SQL_SUCCESS); - - if(exitOnError && rc!=SQL_SUCCESS_WITH_INFO) - CleanUp(); -} - -// Main Program -int main (int argc, char *argv[]) -{ - unsigned char dsnName[20]; - unsigned char user[20]; - unsigned char password[20]; - SQLRETURN returnCode; - bool testPassed = true; - SQLCHAR InConnStr[MAX_CONNECT_STRING]; - SQLCHAR OutConnStr[MAX_CONNECT_STRING]; - SQLSMALLINT ConnStrLength; - int errflag = 0; - - //optarg = NULL; - if (argc != 4) - errflag++; - - if (!errflag ) - { - strcpy ((char *)dsnName, argv[1]); - strcpy ((char *)dsnName, argv[1]); - strcpy ((char *)user, argv[2]); - strcpy ((char *)password, argv[3]); - } - - if (errflag) - { - printf("Command line error.\n"); - printf("Usage: %s <datasource> <userid> <password>\n", argv[0] ); - return FALSE; - } - - // Initialize handles to NULL - henv = SQL_NULL_HANDLE; - hstmt = SQL_NULL_HANDLE; - hdbc = SQL_NULL_HANDLE; - - // Allocate Environment Handle - returnCode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv)",returnCode); - - // Set ODBC version to 3.0 - returnCode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics( "SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0)" - , returnCode - , false - ); - - // Allocate Connection handle - returnCode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc)", returnCode); - - //Connect to the database - sprintf((char*)InConnStr,"DSN=%s;UID=%s;PWD=%s;%c",(char*)dsnName, (char*)user, (char*)password,'\0'); - printf("Using Connect String: %s\n", InConnStr); - returnCode = SQLDriverConnect( hdbc - , hWnd - , InConnStr - , SQL_NTS - , OutConnStr - , sizeof(OutConnStr) - , &ConnStrLength - , SQL_DRIVER_NOPROMPT - ); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLDriverConnect",returnCode); - printf("Successfully connected using SQLDriverConnect.\n"); - - //Allocate Statement handle - returnCode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt)", returnCode); - - printf("Drop sample table if it exists...\n"); - //Drop the test table if it exists - //DROP IF EXISTS TASKS; - returnCode = SQLExecDirect(hstmt, (SQLCHAR*)"DROP TABLE IF EXISTS TASKS", SQL_NTS); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLExecDirect of DROP", returnCode); - - printf("Creating sample table TASKS...\n"); - //Create a test table in default schema - //CREATE TABLE TASKS (ID INT NOT NULL, TASK VARCHAR(10), LAST_UPDATE TIMESTAMP, PRIMARY KEY (C1)); - returnCode = - SQLExecDirect - ( hstmt - , (SQLCHAR*)"CREATE TABLE TASKS (ID INT NOT NULL, TASK CHAR(20), COMPLETED DATE, PRIMARY KEY (ID))" - , SQL_NTS - ); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLExecDirect of CREATE", returnCode); - printf("Table TASKS created using SQLExecDirect.\n"); - - printf("Inserting data using SQLBindParameter, SQLPrepare, SQLExecute\n"); - //Insert few rows into test table using bound parameters - //INSERT INTO TASKS VALUES (?, ?, ?); - SQLINTEGER intID; - SQLLEN cbID = 0, cbTask = SQL_NTS, cbCompleted = 0; - SQLCHAR strTask[200]; - SQL_DATE_STRUCT dsCompleted; - - returnCode = SQLBindParameter( hstmt - , 1 - , SQL_PARAM_INPUT - , SQL_C_SHORT - , SQL_INTEGER - , 0 - , 0 - , &intID - , 0 - , &cbID - ); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLBindParameter 1", returnCode); - - returnCode = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0, &strTask, 0, &cbTask); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLBindParameter 2", returnCode); - - returnCode = SQLBindParameter( hstmt - , 3 - , SQL_PARAM_INPUT - , SQL_C_TYPE_DATE - , SQL_DATE - , sizeof(dsCompleted) - , 0 - , &dsCompleted - , 0 - , &cbCompleted - ); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLBindParameter 3", returnCode); - - returnCode = SQLPrepare(hstmt, (SQLCHAR*)"INSERT INTO TASKS VALUES (?, ?, ?)", SQL_NTS); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLPrepare of INSERT", returnCode); - - intID = 1000; - strcpy ((char*)strTask, "CREATE REPORTS"); - dsCompleted.year = 2014; - dsCompleted.month = 3; - dsCompleted.day = 22; - - returnCode = SQLExecute(hstmt); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLExecute", returnCode); - printf("Data inserted.\n"); - - //Select rows from test table and fetch the data - //SELECT * from TASKS WHERE TASK LIKE '%REPORT%' - printf("Fetching data using SQLExecDirect, SQLFetch, SQLGetData\n"); - returnCode = SQLExecDirect(hstmt, (SQLCHAR*)"SELECT ID, TASK, COMPLETED FROM TASKS", SQL_NTS); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLExecDirect of SELECT", returnCode); - - //loop thru resultset - while (TRUE) - { - returnCode = SQLFetch(hstmt); - if (returnCode == SQL_ERROR || returnCode == SQL_SUCCESS_WITH_INFO) - { - LogDiagnostics("SQLFetch", returnCode); - } - if (returnCode == SQL_SUCCESS || returnCode == SQL_SUCCESS_WITH_INFO) - { - SQLGetData(hstmt, 1, SQL_C_SHORT, &intID, 0, &cbID); - SQLGetData(hstmt, 2, SQL_C_CHAR, strTask, 20, &cbTask); - SQLGetData(hstmt, 3, SQL_C_TYPE_DATE, &dsCompleted, sizeof(dsCompleted), &cbCompleted); - printf( "Data selected: %d %s %d-%d-%d\n" - , intID - , strTask - , dsCompleted.year - , dsCompleted.month - , dsCompleted.day - ); - } - else - break; - } - - //Free Statement handle - returnCode = SQLFreeHandle(SQL_HANDLE_STMT, hstmt); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLFreeHandle(SQL_HANDLE_STMT, hstmt)", returnCode); - hstmt = SQL_NULL_HANDLE; - - //Disconnect - returnCode = SQLDisconnect(hdbc); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLDisconnect(hdbc)", returnCode); - - //Free Connection handle - returnCode = SQLFreeHandle(SQL_HANDLE_DBC, hdbc); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLFreeHandle(SQL_HANDLE_DBC, hdbc)", returnCode); - hdbc = SQL_NULL_HANDLE; - - //Free Environment handle - returnCode = SQLFreeHandle(SQL_HANDLE_ENV, henv); - if (!SQL_SUCCEEDED(returnCode)) - LogDiagnostics("SQLFreeHandle(SQL_HANDLE_ENV, henv)", returnCode); - henv = SQL_NULL_HANDLE; - - printf("Basic SQL ODBC Test Passed!\n"); - exit(EXIT_SUCCESS); -} +// @@@ START COPYRIGHT @@@ +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// +// @@@ END COPYRIGHT @@@ + +#ifdef __linux + #include <unistd.h> +#else + #include <windows.h> + #include <tchar.h> +#endif + +//#include <stdarg.h> + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <assert.h> + +#include <sql.h> +#include <sqlext.h> + +SQLHENV henv ; +SQLHDBC hdbc ; +SQLHSTMT hstmt ; +SQLHWND hWnd ; + +#define MAX_SQLSTRING_LEN 1000 +#define STATE_SIZE 6 +#define MAX_CONNECT_STRING 256 +#define TRUE 1 +#define FALSE 0 +#define ARGS "d:u:p:" + +const char *SqlRetText( int rc ) +{ + static char buffer[80] ; + switch ( rc ) + { + case SQL_SUCCESS: return( "SQL_SUCCESS" ) ; + case SQL_SUCCESS_WITH_INFO: return( "SQL_SUCCESS_WITH_INFO" ) ; + case SQL_NO_DATA: return( "SQL_NO_DATA" ) ; + case SQL_ERROR: return( "SQL_ERROR" ) ; + case SQL_INVALID_HANDLE: return( "SQL_INVALID_HANDLE" ) ; + case SQL_STILL_EXECUTING: return( "SQL_STILL_EXECUTING" ) ; + case SQL_NEED_DATA: return( "SQL_NEED_DATA" ) ; + } + + sprintf( buffer, "SQL Error %d", rc ) ; + return( buffer ) ; +} + +void CleanUp() +{ + printf( "\nConnect Test FAILED!!!\n" ) ; + + if ( hstmt != SQL_NULL_HANDLE ) + SQLFreeHandle( SQL_HANDLE_STMT,hstmt ) ; + + if( hdbc != SQL_NULL_HANDLE ) + { + SQLDisconnect( hdbc ) ; + SQLFreeHandle( SQL_HANDLE_DBC, hdbc ) ; + } + + if ( henv != SQL_NULL_HANDLE ) + SQLFreeHandle( SQL_HANDLE_ENV, henv ) ; + + exit( EXIT_FAILURE ) ; +} + +void LogDiagnostics( const char *sqlFunction + , SQLRETURN rc + , bool exitOnError=true + ) +{ + SQLRETURN diagRC = SQL_SUCCESS ; + SQLSMALLINT recordNumber ; + SQLINTEGER nativeError ; + SQLCHAR messageText[SQL_MAX_MESSAGE_LENGTH] ; + SQLCHAR sqlState[6] ; + int diagsPrinted = 0 ; + bool printedErrorLogHeader = false ; + + printf( "Function %s returned %s\n" + , sqlFunction + , SqlRetText( rc ) + ) ; + + /* Log any henv Diagnostics */ + recordNumber = 1 ; + do + { + diagRC = SQLGetDiagRec( SQL_HANDLE_ENV + , henv + , recordNumber + , sqlState + , &nativeError + , messageText + , sizeof(messageText) + , NULL + ) ; + if ( diagRC==SQL_SUCCESS ) + { + if( ! printedErrorLogHeader ) + { + printf( "Diagnostics associated with environment handle:\n" ) ; + printedErrorLogHeader = true ; + } + + printf( "\n\tSQL Diag %d\n\tNative Error: %ld\n\tSQL State: %s\n\tMessage: %s\n" + , recordNumber + , nativeError + , sqlState + , messageText + ) ; + } + + recordNumber++ ; + + } while ( diagRC==SQL_SUCCESS ) ; + + /* Log any hdbc Diagnostics */ + recordNumber = 1 ; + printedErrorLogHeader = false ; + do + { + diagRC = SQLGetDiagRec( SQL_HANDLE_DBC + , hdbc + , recordNumber + , sqlState + , &nativeError + , messageText + , sizeof(messageText) + , NULL + ) ; + if ( diagRC==SQL_SUCCESS ) + { + if( !printedErrorLogHeader ) + { + printf( "Diagnostics associated with connection handle:\n" ) ; + printedErrorLogHeader = true ; + } + + printf( "\n\tSQL Diag %d\n\tNative Error: %ld\n\tSQL State: %s\n\tMessage: %s\n" + , recordNumber + , nativeError + , sqlState + , messageText + ) ; + } + + recordNumber++ ; + + } while (diagRC==SQL_SUCCESS) ; + + /* Log any hstmt Diagnostics */ + recordNumber = 1 ; + printedErrorLogHeader = false ; + do + { + diagRC = SQLGetDiagRec( SQL_HANDLE_STMT + , hstmt + , recordNumber + , sqlState + , &nativeError + , messageText + , sizeof(messageText) + , NULL + ) ; + if (diagRC == SQL_SUCCESS ) + { + if ( !printedErrorLogHeader ) + { + printf( "Diagnostics associated with statmement handle:\n" ) ; + printedErrorLogHeader = true ; + } + + printf( "\n\tSQL Diag %d\n\tNative Error: %ld\n\tSQL State: %s\n\tMessage: %s\n" + , recordNumber + , nativeError + , sqlState + , messageText + ) ; + } + + recordNumber++ ; + + } while ( diagRC==SQL_SUCCESS ) ; + + if ( exitOnError && rc != SQL_SUCCESS_WITH_INFO ) + CleanUp() ; +} + +// Main Program +int main (int argc, char *argv[]) +{ + unsigned char dsnName[20] ; + unsigned char user[20] ; + unsigned char password[20] ; + SQLRETURN returnCode ; + bool testPassed = true ; + SQLCHAR InConnStr[MAX_CONNECT_STRING] ; + SQLCHAR OutConnStr[MAX_CONNECT_STRING] ; + SQLSMALLINT ConnStrLength ; + int errflag = 0 ; + + //optarg = NULL ; + if ( argc != 4 ) + errflag++ ; + + if ( !errflag ) + { + strcpy ( (char *) dsnName, argv[1] ) ; + strcpy ( (char *) user, argv[2] ) ; + strcpy ( (char *) password, argv[3] ) ; + } + + if ( errflag ) + { + printf( "Command line error.\n" ) ; + printf( "Usage: %s <datasource> <userid> <password>\n", argv[0] ) ; + return FALSE ; + } + + // Initialize handles to NULL + henv = SQL_NULL_HANDLE ; + hstmt = SQL_NULL_HANDLE ; + hdbc = SQL_NULL_HANDLE ; + + // Allocate Environment Handle + returnCode = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv )" + , returnCode + ) ; + + // Set ODBC version to 3.0 + returnCode = SQLSetEnvAttr( henv, SQL_ATTR_ODBC_VERSION, (void*) SQL_OV_ODBC3, 0 ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLSetEnvAttr( henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0 )" + , returnCode + , false + ) ; + + // Allocate Connection handle + returnCode = SQLAllocHandle( SQL_HANDLE_DBC, henv, &hdbc ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLAllocHandle( SQL_HANDLE_DBC, henv, &hdbc )", returnCode ) ; + + // Connect to the database + sprintf( (char*) InConnStr + , "DSN=%s;UID=%s;PWD=%s;%c" + , (char*) dsnName + , (char*) user + , (char*) password + , '\0' + ) ; + + printf( "Using Connect String: %s\n", InConnStr ) ; + returnCode = SQLDriverConnect( hdbc + , hWnd + , InConnStr + , SQL_NTS + , OutConnStr + , sizeof( OutConnStr ) + , &ConnStrLength + , SQL_DRIVER_NOPROMPT + ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLDriverConnect", returnCode ) ; + + printf( "Successfully connected using SQLDriverConnect.\n" ) ; + + // Allocate Statement handle + returnCode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt )", returnCode ) ; + + printf( "Drop sample table if it exists...\n" ) ; + // Drop the test table if it exists + // DROP IF EXISTS TASKS ; + returnCode = SQLExecDirect(hstmt, (SQLCHAR*) "DROP TABLE IF EXISTS TASKS", SQL_NTS ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLExecDirect of DROP", returnCode ) ; + + printf( "Creating sample table TASKS...\n" ) ; + + // Create a test table in default schema + // CREATE TABLE TASKS (ID INT NOT NULL, TASK VARCHAR(10), LAST_UPDATE TIMESTAMP, PRIMARY KEY (C1)) ; + returnCode = + SQLExecDirect + ( hstmt + , (SQLCHAR*) "CREATE TABLE TASKS (ID INT NOT NULL, TASK CHAR(20), COMPLETED DATE, PRIMARY KEY (ID))" + , SQL_NTS + ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLExecDirect of CREATE", returnCode ) ; + + printf( "Table TASKS created using SQLExecDirect.\n" ) ; + + printf( "Inserting data using SQLBindParameter, SQLPrepare, SQLExecute\n" ) ; + + // Insert few rows into test table using bound parameters + // INSERT INTO TASKS VALUES (?, ?, ?) ; + SQLINTEGER intID ; + SQLLEN cbID = 0, cbTask = SQL_NTS, cbCompleted = 0 ; + SQLCHAR strTask[200] ; + SQL_DATE_STRUCT dsCompleted ; + + returnCode = SQLBindParameter( hstmt + , 1 + , SQL_PARAM_INPUT + , SQL_C_SHORT + , SQL_INTEGER + , 0 + , 0 + , &intID + , 0 + , &cbID + ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLBindParameter 1", returnCode ) ; + + returnCode = SQLBindParameter( hstmt + , 2 + , SQL_PARAM_INPUT + , SQL_C_CHAR + , SQL_CHAR + , 0 + , 0 + , &strTask + , 0 + , &cbTask + ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLBindParameter 2", returnCode ) ; + + returnCode = SQLBindParameter( hstmt + , 3 + , SQL_PARAM_INPUT + , SQL_C_TYPE_DATE + , SQL_DATE + , sizeof(dsCompleted) + , 0 + , &dsCompleted + , 0 + , &cbCompleted + ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLBindParameter 3", returnCode ) ; + + returnCode = SQLPrepare( hstmt + , (SQLCHAR*) "INSERT INTO TASKS VALUES (?, ?, ?)" + , SQL_NTS + ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLPrepare of INSERT", returnCode ) ; + + intID = 1000 ; + strcpy ( (char*) strTask, "CREATE REPORTS" ) ; + dsCompleted.year = 2014 ; + dsCompleted.month = 3 ; + dsCompleted.day = 22 ; + + returnCode = SQLExecute( hstmt ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLExecute", returnCode ) ; + + printf( "Data inserted.\n" ) ; + + // Select rows from test table and fetch the data + // SELECT * from TASKS WHERE TASK LIKE '%REPORT%' + printf( "Fetching data using SQLExecDirect, SQLFetch, SQLGetData\n" ) ; + + returnCode = SQLExecDirect( hstmt + , (SQLCHAR*) "SELECT ID, TASK, COMPLETED FROM TASKS" + , SQL_NTS + ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLExecDirect of SELECT", returnCode ) ; + + //loop thru resultset + while ( TRUE ) + { + returnCode = SQLFetch( hstmt ) ; + if ( returnCode == SQL_ERROR || returnCode == SQL_SUCCESS_WITH_INFO ) + { + LogDiagnostics( "SQLFetch", returnCode ) ; + } + + if ( returnCode == SQL_SUCCESS || returnCode == SQL_SUCCESS_WITH_INFO ) + { + SQLGetData( hstmt, 1, SQL_C_SHORT, &intID, 0, &cbID ) ; + SQLGetData( hstmt, 2, SQL_C_CHAR, strTask, 20, &cbTask ) ; + SQLGetData( hstmt + , 3 + , SQL_C_TYPE_DATE + , &dsCompleted + , sizeof( dsCompleted ) + , &cbCompleted + ) ; + printf( "Data selected: %d %s %d-%d-%d\n" + , intID + , strTask + , dsCompleted.year + , dsCompleted.month + , dsCompleted.day + ) ; + } + else + break ; + } + + // Free Statement handle + returnCode = SQLFreeHandle( SQL_HANDLE_STMT, hstmt ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLFreeHandle( SQL_HANDLE_STMT, hstmt )", returnCode ) ; + hstmt = SQL_NULL_HANDLE ; + + // Disconnect + returnCode = SQLDisconnect(hdbc) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLDisconnect( hdbc )", returnCode ) ; + + // Free Connection handle + returnCode = SQLFreeHandle( SQL_HANDLE_DBC, hdbc ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLFreeHandle( SQL_HANDLE_DBC, hdbc )", returnCode ) ; + hdbc = SQL_NULL_HANDLE ; + + // Free Environment handle + returnCode = SQLFreeHandle( SQL_HANDLE_ENV, henv ) ; + if ( ! SQL_SUCCEEDED( returnCode ) ) + LogDiagnostics( "SQLFreeHandle( SQL_HANDLE_ENV, henv )", returnCode ) ; + henv = SQL_NULL_HANDLE ; + + printf( "Basic SQL ODBC Test Passed!\n" ) ; + exit( EXIT_SUCCESS ) ; +}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/client_install/src/resources/source/build.bat ---------------------------------------------------------------------- diff --git a/docs/client_install/src/resources/source/build.bat b/docs/client_install/src/resources/source/build.bat index d8ecdda..8fde588 100644 --- a/docs/client_install/src/resources/source/build.bat +++ b/docs/client_install/src/resources/source/build.bat @@ -1,25 +1,25 @@ -@echo off -REM @@@ START COPYRIGHT @@@ -REM -REM Licensed to the Apache Software Foundation (ASF) under one -REM or more contributor license agreements. See the NOTICE file -REM distributed with this work for additional information -REM regarding copyright ownership. The ASF licenses this file -REM to you under the Apache License, Version 2.0 (the -REM "License"); you may not use this file except in compliance -REM with the License. You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, -REM software distributed under the License is distributed on an -REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -REM KIND, either express or implied. See the License for the -REM specific language governing permissions and limitations -REM under the License. -REM -REM @@@ END COPYRIGHT @@@ - -CL /c /Zi /nologo /W3 /WX- /O2 /D "NDEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /D "_MBCS" /Gm /EHsc /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"./" /Gd /errorReport:queue basicsql.cpp - -link /OUT:"./basicsql.exe" /NOLOGO "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /ERRORREPORT:QUEUE basicsql.obj +@echo off +REM @@@ START COPYRIGHT @@@ +REM +REM Licensed to the Apache Software Foundation (ASF) under one +REM or more contributor license agreements. See the NOTICE file +REM distributed with this work for additional information +REM regarding copyright ownership. The ASF licenses this file +REM to you under the Apache License, Version 2.0 (the +REM "License"); you may not use this file except in compliance +REM with the License. You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, +REM software distributed under the License is distributed on an +REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +REM KIND, either express or implied. See the License for the +REM specific language governing permissions and limitations +REM under the License. +REM +REM @@@ END COPYRIGHT @@@ + +CL /c /Zi /nologo /W3 /WX- /O2 /D "NDEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /D "_MBCS" /Gm /EHsc /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"./" /Gd /errorReport:queue basicsql.cpp + +link /OUT:"./basicsql.exe" /NOLOGO "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /ERRORREPORT:QUEUE basicsql.obj http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/client_install/src/resources/source/run.bat ---------------------------------------------------------------------- diff --git a/docs/client_install/src/resources/source/run.bat b/docs/client_install/src/resources/source/run.bat index 98997b9..3b695d1 100644 --- a/docs/client_install/src/resources/source/run.bat +++ b/docs/client_install/src/resources/source/run.bat @@ -1,23 +1,23 @@ -@echo off -REM @@@ START COPYRIGHT @@@ -REM -REM Licensed to the Apache Software Foundation (ASF) under one -REM or more contributor license agreements. See the NOTICE file -REM distributed with this work for additional information -REM regarding copyright ownership. The ASF licenses this file -REM to you under the Apache License, Version 2.0 (the -REM "License"); you may not use this file except in compliance -REM with the License. You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, -REM software distributed under the License is distributed on an -REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -REM KIND, either express or implied. See the License for the -REM specific language governing permissions and limitations -REM under the License. -REM -REM @@@ END COPYRIGHT @@@ - -basicsql.exe Default_Datasource user1 pwd1 +@echo off +REM @@@ START COPYRIGHT @@@ +REM +REM Licensed to the Apache Software Foundation (ASF) under one +REM or more contributor license agreements. See the NOTICE file +REM distributed with this work for additional information +REM regarding copyright ownership. The ASF licenses this file +REM to you under the Apache License, Version 2.0 (the +REM "License"); you may not use this file except in compliance +REM with the License. You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, +REM software distributed under the License is distributed on an +REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +REM KIND, either express or implied. See the License for the +REM specific language governing permissions and limitations +REM under the License. +REM +REM @@@ END COPYRIGHT @@@ + +basicsql.exe Default_Datasource user1 pwd1 http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/client_install/src/resources/tableau/trafodion.tdc ---------------------------------------------------------------------- diff --git a/docs/client_install/src/resources/tableau/trafodion.tdc b/docs/client_install/src/resources/tableau/trafodion.tdc new file mode 100644 index 0000000..bfb1e1e --- /dev/null +++ b/docs/client_install/src/resources/tableau/trafodion.tdc @@ -0,0 +1,16 @@ +<?xml version='1.0' encoding='utf-8' ?> +<connection-customization class='genericodbc' enabled='true' version='9.3' dbname='TRAFODION' odbc-native-protocol='yes' odbc-use-connection-pooling='yes'> + <vendor name='Trafodion' /> + <driver name='TRAF ODBC 2.1' /> + <customizations> + <customization name='CAP_ISOLATION_LEVEL_SERIALIZABLE' value='no'/> + <customization name='CAP_ISOLATION_LEVEL_READ_UNCOMMITTED' value='yes' /> + <customization name='CAP_SET_ISOLATION_LEVEL_VIA_ODBC_API' value='no' /> + <customization name='CAP_CREATE_TEMP_TABLES' value='no' /> + <customization name='CAP_SUPPRESS_DISCOVERY_QUERIES' value='yes' /> + <customization name='CAP_ODBC_METADATA_SUPPRESS_PREPARED_QUERY' value='yes' /> + <customization name='CAP_ODBC_METADATA_SUPPRESS_SELECT_STAR' value='yes' /> + <customization name='CAP_ODBC_METADATA_SUPPRESS_EXECUTED_QUERY' value='yes' /> + <customization name='CAP_ODBC_METADATA_SUPRESS_SQLSTATISTICS_API' value='yes' /> + </customizations> +</connection-customization> http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/client_install/src/resources/tableau/trafodion.tdc.template ---------------------------------------------------------------------- diff --git a/docs/client_install/src/resources/tableau/trafodion.tdc.template b/docs/client_install/src/resources/tableau/trafodion.tdc.template new file mode 100644 index 0000000..8d71f39 --- /dev/null +++ b/docs/client_install/src/resources/tableau/trafodion.tdc.template @@ -0,0 +1,16 @@ +<?xml version='1.0' encoding='utf-8' ?> +<connection-customization class='genericodbc' enabled='true' version='<tableau-version>' dbname='TRAFODION' odbc-native-protocol='yes' odbc-use-connection-pooling='yes'> + <vendor name='Trafodion' /> + <driver name='<trafodion-driver-name>' /> + <customizations> + <customization name='CAP_ISOLATION_LEVEL_SERIALIZABLE' value='no'/> + <customization name='CAP_ISOLATION_LEVEL_READ_UNCOMMITTED' value='yes' /> + <customization name='CAP_SET_ISOLATION_LEVEL_VIA_ODBC_API' value='no' /> + <customization name='CAP_CREATE_TEMP_TABLES' value='no' /> + <customization name='CAP_SUPPRESS_DISCOVERY_QUERIES' value='yes' /> + <customization name='CAP_ODBC_METADATA_SUPPRESS_PREPARED_QUERY' value='yes' /> + <customization name='CAP_ODBC_METADATA_SUPPRESS_SELECT_STAR' value='yes' /> + <customization name='CAP_ODBC_METADATA_SUPPRESS_EXECUTED_QUERY' value='yes' /> + <customization name='CAP_ODBC_METADATA_SUPRESS_SQLSTATISTICS_API' value='yes' /> + </customizations> +</connection-customization> http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/messages_guide/src/asciidoc/_chapters/binder_msgs.adoc ---------------------------------------------------------------------- diff --git a/docs/messages_guide/src/asciidoc/_chapters/binder_msgs.adoc b/docs/messages_guide/src/asciidoc/_chapters/binder_msgs.adoc index a597202..b66b3d3 100644 --- a/docs/messages_guide/src/asciidoc/_chapters/binder_msgs.adoc +++ b/docs/messages_guide/src/asciidoc/_chapters/binder_msgs.adoc @@ -2257,11 +2257,11 @@ statement. == SQL 4169 ``` -Embedded delete statements are not allowed when using DECLARE ... +Embedded delete statements are not allowed when using DECLARE . . . FOR UPDATE clause. ``` -*Cause:* You attempted to perform a DECLARE... FOR UPDATE clause that +*Cause:* You attempted to perform a DECLARE. . . FOR UPDATE clause that included an embedded DELETE statement. *Effect:* {project-name} is unable to compile the @@ -2797,7 +2797,7 @@ A CALL statement is not allowed within a compound statement. ``` *Cause:* In the {project-name} database software statement being compiled, a -CALL statement was present within a BEGIN...END block. +CALL statement was present within a BEGIN. . . END block. *Effect:* {project-name} statement is not compiled. http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/odb_user/src/asciidoc/_chapters/install.adoc ---------------------------------------------------------------------- diff --git a/docs/odb_user/src/asciidoc/_chapters/install.adoc b/docs/odb_user/src/asciidoc/_chapters/install.adoc index f4ce867..5606daa 100644 Binary files a/docs/odb_user/src/asciidoc/_chapters/install.adoc and b/docs/odb_user/src/asciidoc/_chapters/install.adoc differ http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/spj_guide/src/resources/source/partLocations.java ---------------------------------------------------------------------- diff --git a/docs/spj_guide/src/resources/source/partLocations.java b/docs/spj_guide/src/resources/source/partLocations.java new file mode 100644 index 0000000..88cdaae --- /dev/null +++ b/docs/spj_guide/src/resources/source/partLocations.java @@ -0,0 +1,42 @@ +// The PARTLOCATIONS procedure accepts a part number and quantity and returns a +// set of location codes that have the exact quantity and a set of location +// codes that have more than that quantity. +// +// See http://trafodion.incubator.apache.org/docs/spj_guide/index.html#partlocations-procedure +// for more documentation. +public static void partLocations( int partNum + , int quantity + , ResultSet exactly[] + , ResultSet moreThan[] + ) throws SQLException + +{ + Connection conn = + DriverManager.getConnection( "jdbc:default:connection" ) ; + + PreparedStatement getLocationsExact = + conn.prepareStatement( "SELECT L.loc_code, L.partnum, L.qty_on_hand " + + "FROM trafodion.invent.partloc L " + + "WHERE L.partnum = ? " + + " AND L.qty_on_hand = ? " + + " ORDER BY L.partnum " + ) ; + + getLocationsExact.setInt( 1, partNum ) ; + getLocationsExact.setInt( 2, quantity) ; + + PreparedStatement getLocationsMoreThan = + conn.prepareStatement( "SELECT L.loc_code, L.partnum, L.qty_on_hand " + + "FROM trafodion.invent.partloc L " + + "WHERE L.partnum = ? " + + " AND L.qty_on_hand > ? " + + "ORDER BY L.partnum " + ) ; + + getLocationsMoreThan.setInt( 1, partNum ) ; + getLocationsMoreThan.setInt( 2, quantity) ; + + exactly[0] = getLocationsExact.executeQuery() ; + moreThan[0] = getLocationsMoreThan.executeQuery() ; + +} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/spj_guide/src/resources/source/partlocations.java ---------------------------------------------------------------------- diff --git a/docs/spj_guide/src/resources/source/partlocations.java b/docs/spj_guide/src/resources/source/partlocations.java deleted file mode 100644 index 88cdaae..0000000 --- a/docs/spj_guide/src/resources/source/partlocations.java +++ /dev/null @@ -1,42 +0,0 @@ -// The PARTLOCATIONS procedure accepts a part number and quantity and returns a -// set of location codes that have the exact quantity and a set of location -// codes that have more than that quantity. -// -// See http://trafodion.incubator.apache.org/docs/spj_guide/index.html#partlocations-procedure -// for more documentation. -public static void partLocations( int partNum - , int quantity - , ResultSet exactly[] - , ResultSet moreThan[] - ) throws SQLException - -{ - Connection conn = - DriverManager.getConnection( "jdbc:default:connection" ) ; - - PreparedStatement getLocationsExact = - conn.prepareStatement( "SELECT L.loc_code, L.partnum, L.qty_on_hand " - + "FROM trafodion.invent.partloc L " - + "WHERE L.partnum = ? " - + " AND L.qty_on_hand = ? " - + " ORDER BY L.partnum " - ) ; - - getLocationsExact.setInt( 1, partNum ) ; - getLocationsExact.setInt( 2, quantity) ; - - PreparedStatement getLocationsMoreThan = - conn.prepareStatement( "SELECT L.loc_code, L.partnum, L.qty_on_hand " - + "FROM trafodion.invent.partloc L " - + "WHERE L.partnum = ? " - + " AND L.qty_on_hand > ? " - + "ORDER BY L.partnum " - ) ; - - getLocationsMoreThan.setInt( 1, partNum ) ; - getLocationsMoreThan.setInt( 2, quantity) ; - - exactly[0] = getLocationsExact.executeQuery() ; - moreThan[0] = getLocationsMoreThan.executeQuery() ; - -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/spj_guide/src/resources/source/supplierInfo.java ---------------------------------------------------------------------- diff --git a/docs/spj_guide/src/resources/source/supplierInfo.java b/docs/spj_guide/src/resources/source/supplierInfo.java new file mode 100644 index 0000000..c98a392 --- /dev/null +++ b/docs/spj_guide/src/resources/source/supplierInfo.java @@ -0,0 +1,38 @@ +// The SUPPLIERINFO procedure accepts a supplier number and returns the +// supplier's name, street, city, state, and post code to separate output +// parameters. +// +// See http://trafodion.incubator.apache.org/docs/spj_guide/index.html#supplierinfo-procedure +// for more documentation. +public static void supplierInfo( BigDecimal suppNum + , String[] suppName + , String[] streetAddr + , String[] cityName + , String[] stateName + , String[] postCode + ) throws SQLException +{ + Connection conn = + DriverManager.getConnection( "jdbc:default:connection" ) ; + + PreparedStatement getSupplier = + conn.prepareStatement( "SELECT suppname, street, city, " + + " state, postcode " + + "FROM trafodion.invent.supplier " + + "WHERE suppnum = ?" + ) ; + + getSupplier.setBigDecimal( 1, suppNum ) ; + ResultSet rs = getSupplier.executeQuery() ; + rs.next() ; + + suppName[0] = rs.getString( 1 ) ; + streetAddr[0] = rs.getString( 2 ) ; + cityName[0] = rs.getString( 3 ) ; + stateName[0] = rs.getString( 4 ) ; + postCode[0] = rs.getString( 5 ) ; + + rs.close() ; + conn.close() ; + +} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/spj_guide/src/resources/source/supplierinfo.java ---------------------------------------------------------------------- diff --git a/docs/spj_guide/src/resources/source/supplierinfo.java b/docs/spj_guide/src/resources/source/supplierinfo.java deleted file mode 100644 index c98a392..0000000 --- a/docs/spj_guide/src/resources/source/supplierinfo.java +++ /dev/null @@ -1,38 +0,0 @@ -// The SUPPLIERINFO procedure accepts a supplier number and returns the -// supplier's name, street, city, state, and post code to separate output -// parameters. -// -// See http://trafodion.incubator.apache.org/docs/spj_guide/index.html#supplierinfo-procedure -// for more documentation. -public static void supplierInfo( BigDecimal suppNum - , String[] suppName - , String[] streetAddr - , String[] cityName - , String[] stateName - , String[] postCode - ) throws SQLException -{ - Connection conn = - DriverManager.getConnection( "jdbc:default:connection" ) ; - - PreparedStatement getSupplier = - conn.prepareStatement( "SELECT suppname, street, city, " - + " state, postcode " - + "FROM trafodion.invent.supplier " - + "WHERE suppnum = ?" - ) ; - - getSupplier.setBigDecimal( 1, suppNum ) ; - ResultSet rs = getSupplier.executeQuery() ; - rs.next() ; - - suppName[0] = rs.getString( 1 ) ; - streetAddr[0] = rs.getString( 2 ) ; - cityName[0] = rs.getString( 3 ) ; - stateName[0] = rs.getString( 4 ) ; - postCode[0] = rs.getString( 5 ) ; - - rs.close() ; - conn.close() ; - -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/spj_guide/src/resources/source/supplyQuantities.java ---------------------------------------------------------------------- diff --git a/docs/spj_guide/src/resources/source/supplyQuantities.java b/docs/spj_guide/src/resources/source/supplyQuantities.java new file mode 100644 index 0000000..59a6911 --- /dev/null +++ b/docs/spj_guide/src/resources/source/supplyQuantities.java @@ -0,0 +1,32 @@ +// The SUPPLYQUANTITIES procedure returns the average, minimum, and maximum +// quantities of available parts in inventory to separate output +// parameters. +// +// See http://trafodion.incubator.apache.org/docs/spj_guide/index.html#supplyquantities-procedure +// for more documentation. +public static void supplyQuantities( int[] avgQty + , int[] minQty + , int[] maxQty + ) throws SQLException +{ + Connection conn = + DriverManager.getConnection( "jdbc:default:connection" ) ; + + PreparedStatement getQty = + conn.prepareStatement( "SELECT AVG(qty_on_hand), " + + " MIN(qty_on_hand), " + + " MAX(qty_on_hand) " + + "FROM trafodion.invent.partloc" + ) ; + + ResultSet rs = getQty.executeQuery() ; + rs.next() ; + + avgQty[0] = rs.getInt( 1 ) ; + minQty[0] = rs.getInt( 2 ) ; + maxQty[0] = rs.getInt( 3 ) ; + + rs.close() ; + conn.close() ; + +} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/spj_guide/src/resources/source/supplyquantities.java ---------------------------------------------------------------------- diff --git a/docs/spj_guide/src/resources/source/supplyquantities.java b/docs/spj_guide/src/resources/source/supplyquantities.java deleted file mode 100644 index 59a6911..0000000 --- a/docs/spj_guide/src/resources/source/supplyquantities.java +++ /dev/null @@ -1,32 +0,0 @@ -// The SUPPLYQUANTITIES procedure returns the average, minimum, and maximum -// quantities of available parts in inventory to separate output -// parameters. -// -// See http://trafodion.incubator.apache.org/docs/spj_guide/index.html#supplyquantities-procedure -// for more documentation. -public static void supplyQuantities( int[] avgQty - , int[] minQty - , int[] maxQty - ) throws SQLException -{ - Connection conn = - DriverManager.getConnection( "jdbc:default:connection" ) ; - - PreparedStatement getQty = - conn.prepareStatement( "SELECT AVG(qty_on_hand), " - + " MIN(qty_on_hand), " - + " MAX(qty_on_hand) " - + "FROM trafodion.invent.partloc" - ) ; - - ResultSet rs = getQty.executeQuery() ; - rs.next() ; - - avgQty[0] = rs.getInt( 1 ) ; - minQty[0] = rs.getInt( 2 ) ; - maxQty[0] = rs.getInt( 3 ) ; - - rs.close() ; - conn.close() ; - -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/sql_reference/pom.xml ---------------------------------------------------------------------- diff --git a/docs/sql_reference/pom.xml b/docs/sql_reference/pom.xml index c79a6a0..c5ebf3c 100644 --- a/docs/sql_reference/pom.xml +++ b/docs/sql_reference/pom.xml @@ -1,301 +1,301 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <!-- -* @@@ START COPYRIGHT @@@ -* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -* @@@ END COPYRIGHT @@@ ---> - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.trafodion</groupId> - <artifactId>sql-reference-manual</artifactId> - <version>${env.TRAFODION_VER}</version> - <packaging>pom</packaging> - <name>Trafodion SQL Reference Manual</name> - <description>This manual describes reference information about the syntax of SQL statements, - functions, and other SQL language elements supported by the Trafodion projectâs - database software. - </description> - <url>http://trafodion.incubator.apache.org</url> - <inceptionYear>2015</inceptionYear> - <parent> - <groupId>org.apache.trafodion</groupId> - <artifactId>trafodion</artifactId> - <relativePath>../../pom.xml</relativePath> - <version>1.3.0</version> - </parent> - - - <licenses> - <license> - <name>The Apache Software License, Version 2.0</name> - <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> - <distribution>repo</distribution> - <comments>A business-friendly OSS license</comments> - </license> - </licenses> - - <organization> - <name>Apache Software Foundation</name> - <url>http://www.apache.org</url> - </organization> - - <issueManagement> - <system>JIRA</system> - <url>http://issues.apache.org/jira/browse/TRAFODION</url> - </issueManagement> - - <scm> - <connection>scm:git:http://git-wip-us.apache.org/repos/asf/incubator-trafodion.git</connection> - <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/incubator-trafodion.git</developerConnection> - <url>https://git-wip-us.apache.org/repos/asf?p=incubator-trafodion.git</url> - <tag>HEAD</tag> - </scm> - - <ciManagement> - <system>Jenkins</system> - <url>https://jenkins.esgyn.com</url> - </ciManagement> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <asciidoctor.maven.plugin.version>1.5.2.1</asciidoctor.maven.plugin.version> - <asciidoctorj.pdf.version>1.5.0-alpha.11</asciidoctorj.pdf.version> - <asciidoctorj.version>1.5.4</asciidoctorj.version> - <rubygems.prawn.version>2.0.2</rubygems.prawn.version> - <jruby.version>9.0.4.0</jruby.version> - <dependency.locations.enabled>false</dependency.locations.enabled> - </properties> - - <repositories> - <repository> - <id>rubygems-proxy-releases</id> - <name>RubyGems.org Proxy (Releases)</name> - <url>http://rubygems-proxy.torquebox.org/releases</url> - <releases> - <enabled>true</enabled> - </releases> - <snapshots> - <enabled>false</enabled> - </snapshots> - </repository> - </repositories> - - <dependencies> - <dependency> - <groupId>rubygems</groupId> - <artifactId>prawn</artifactId> - <version>${rubygems.prawn.version}</version> - <type>gem</type> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.jruby</groupId> - <artifactId>jruby-complete</artifactId> - <version>${jruby.version}</version> - </dependency> - <dependency> - <groupId>org.asciidoctor</groupId> - <artifactId>asciidoctorj</artifactId> - <version>${asciidoctorj.version}</version> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>de.saumya.mojo</groupId> - <artifactId>gem-maven-plugin</artifactId> - <version>1.0.10</version> - <configuration> - <!-- align JRuby version with AsciidoctorJ to avoid redundant downloading --> - <jrubyVersion>${jruby.version}</jrubyVersion> - <gemHome>${project.build.directory}/gems</gemHome> - <gemPath>${project.build.directory}/gems</gemPath> - </configuration> - <executions> - <execution> - <goals> - <goal>initialize</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-resources-plugin</artifactId> - <version>2.7</version> - <configuration> - <encoding>UTF-8</encoding> - <attributes> - <generateReports>false</generateReports> - </attributes> - </configuration> - </plugin> - <plugin> - <groupId>org.asciidoctor</groupId> - <artifactId>asciidoctor-maven-plugin</artifactId> - <version>${asciidoctor.maven.plugin.version}</version> - <dependencies> - <dependency> - <groupId>org.asciidoctor</groupId> - <artifactId>asciidoctorj-pdf</artifactId> - <version>${asciidoctorj.pdf.version}</version> - </dependency> - <dependency> - <groupId>org.asciidoctor</groupId> - <artifactId>asciidoctorj</artifactId> - <version>${asciidoctorj.version}</version> - </dependency> - </dependencies> - <configuration> - <sourceDirectory>${basedir}/src</sourceDirectory> - <gemPath>${project.build.directory}/gems-provided</gemPath> - </configuration> - <executions> - <execution> - <id>generate-html-doc</id> - <goals> - <goal>process-asciidoc</goal> - </goals> - <phase>site</phase> - <configuration> - <doctype>book</doctype> - <backend>html5</backend> - <sourceHighlighter>coderay</sourceHighlighter> - <outputDirectory>${basedir}/target/site</outputDirectory> - <requires> - <require>${basedir}/../shared/google-analytics-postprocessor.rb</require> - </requires> - <attributes> - <!-- Location of centralized stylesheet --> - <stylesheet>${basedir}/../shared/trafodion-manuals.css</stylesheet> - <project-version>${env.TRAFODION_VER}</project-version> - <project-name>Trafodion</project-name> - <project-logo>${basedir}/../shared/trafodion-logo.jpg</project-logo> - <project-support>[email protected]</project-support> - <docs-url>http://trafodion.incubator.apache.org/docs</docs-url> - <build-date>${maven.build.timestamp}</build-date> - <google-analytics-account>UA-72491210-1</google-analytics-account> - </attributes> - </configuration> - </execution> - <execution> - <id>generate-pdf-doc</id> - <phase>site</phase> - <goals> - <goal>process-asciidoc</goal> - </goals> - <configuration> - <doctype>book</doctype> - <backend>pdf</backend> - <sourceHighlighter>coderay</sourceHighlighter> - <outputDirectory>${basedir}/target</outputDirectory> - <attributes> - <project-version>${env.TRAFODION_VER}</project-version> - <project-name>Trafodion</project-name> - <project-logo>${basedir}/../shared/trafodion-logo.jpg</project-logo> - <project-support>[email protected]</project-support> - <docs-url>http://trafodion.incubator.apache.org/docs</docs-url> - <build-date>${maven.build.timestamp}</build-date> - <pdf-stylesdir>${basedir}/../shared</pdf-stylesdir> - <pdf-style>trafodion</pdf-style> - <icons>font</icons> - <pagenums/> - <toc/> - <idprefix/> - <idseparator>-</idseparator> - </attributes> - </configuration> - </execution> - </executions> - </plugin> - <!-- Copy files to the web-site end destinations. --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-antrun-plugin</artifactId> - <version>1.8</version> - <inherited>false</inherited> - <executions> - <execution> - <id>populate-release-directories</id> - <phase>post-site</phase> - <configuration> - <target name="Populate Release Directories"> - <!-- The website uses the following organization for the docs/target/docs directory: - - To ensure a known location, the base directory contains the LATEST version of the web book and the PDF files. - - The know location is docs/target/docs/<document> - - target/docs/<version>/<document> contains version-specific renderings of the documents. - - target/docs/<version>/<document> contains the PDF version and the web book. The web book is named index.html - --> - <!-- Copy the PDF file to its target directories --> - <copy file="${basedir}/target/index.pdf" tofile="${basedir}/../target/docs/sql_reference/Trafodion_SQL_Reference_Manual.pdf" /> - <copy file="${basedir}/target/index.pdf" tofile="${basedir}/../target/docs/${project.version}/sql_reference/Trafodion_SQL_Reference_Manual.pdf" /> - <!-- Copy the Web Book files to their target directories --> - <copy todir="${basedir}/../target/docs/sql_reference"> - <fileset dir="${basedir}/target/site"> - <include name="**/*.*"/> <!--All sub-directories, too--> - </fileset> - </copy> - <copy todir="${basedir}/../target/docs/${project.version}/sql_reference"> - <fileset dir="${basedir}/target/site"> - <include name="**/*.*"/> <!--All sub-directories, too--> - </fileset> - </copy> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <!-- Included because this is required. No reports are generated. --> - <reporting> - <excludeDefaults>true</excludeDefaults> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-project-info-reports-plugin</artifactId> - <version>2.8</version> - <reportSets> - <reportSet> - <reports> - </reports> - </reportSet> - </reportSets> - </plugin> - </plugins> - </reporting> - - <distributionManagement> - <site> - <id>trafodion.incubator.apache.org</id> - <name>Trafodion Website at incubator.apache.org</name> - <!-- On why this is the tmp dir and not trafodion.incubator.apache.org, see - https://issues.apache.org/jira/browse/HBASE-7593?focusedCommentId=13555866&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13555866 - --> - <url>file:///tmp</url> - </site> - </distributionManagement> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <!-- +* @@@ START COPYRIGHT @@@ +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +* @@@ END COPYRIGHT @@@ +--> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.trafodion</groupId> + <artifactId>sql-reference-manual</artifactId> + <version>${env.TRAFODION_VER}</version> + <packaging>pom</packaging> + <name>Trafodion SQL Reference Manual</name> + <description>This manual describes reference information about the syntax of SQL statements, + functions, and other SQL language elements supported by the Trafodion projectâs + database software. + </description> + <url>http://trafodion.incubator.apache.org</url> + <inceptionYear>2015</inceptionYear> + <parent> + <groupId>org.apache.trafodion</groupId> + <artifactId>trafodion</artifactId> + <relativePath>../../pom.xml</relativePath> + <version>1.3.0</version> + </parent> + + + <licenses> + <license> + <name>The Apache Software License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + <distribution>repo</distribution> + <comments>A business-friendly OSS license</comments> + </license> + </licenses> + + <organization> + <name>Apache Software Foundation</name> + <url>http://www.apache.org</url> + </organization> + + <issueManagement> + <system>JIRA</system> + <url>http://issues.apache.org/jira/browse/TRAFODION</url> + </issueManagement> + + <scm> + <connection>scm:git:http://git-wip-us.apache.org/repos/asf/incubator-trafodion.git</connection> + <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/incubator-trafodion.git</developerConnection> + <url>https://git-wip-us.apache.org/repos/asf?p=incubator-trafodion.git</url> + <tag>HEAD</tag> + </scm> + + <ciManagement> + <system>Jenkins</system> + <url>https://jenkins.esgyn.com</url> + </ciManagement> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <asciidoctor.maven.plugin.version>1.5.2.1</asciidoctor.maven.plugin.version> + <asciidoctorj.pdf.version>1.5.0-alpha.11</asciidoctorj.pdf.version> + <asciidoctorj.version>1.5.4</asciidoctorj.version> + <rubygems.prawn.version>2.0.2</rubygems.prawn.version> + <jruby.version>9.0.4.0</jruby.version> + <dependency.locations.enabled>false</dependency.locations.enabled> + </properties> + + <repositories> + <repository> + <id>rubygems-proxy-releases</id> + <name>RubyGems.org Proxy (Releases)</name> + <url>http://rubygems-proxy.torquebox.org/releases</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + + <dependencies> + <dependency> + <groupId>rubygems</groupId> + <artifactId>prawn</artifactId> + <version>${rubygems.prawn.version}</version> + <type>gem</type> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jruby</groupId> + <artifactId>jruby-complete</artifactId> + <version>${jruby.version}</version> + </dependency> + <dependency> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctorj</artifactId> + <version>${asciidoctorj.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>de.saumya.mojo</groupId> + <artifactId>gem-maven-plugin</artifactId> + <version>1.0.10</version> + <configuration> + <!-- align JRuby version with AsciidoctorJ to avoid redundant downloading --> + <jrubyVersion>${jruby.version}</jrubyVersion> + <gemHome>${project.build.directory}/gems</gemHome> + <gemPath>${project.build.directory}/gems</gemPath> + </configuration> + <executions> + <execution> + <goals> + <goal>initialize</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <version>2.7</version> + <configuration> + <encoding>UTF-8</encoding> + <attributes> + <generateReports>false</generateReports> + </attributes> + </configuration> + </plugin> + <plugin> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctor-maven-plugin</artifactId> + <version>${asciidoctor.maven.plugin.version}</version> + <dependencies> + <dependency> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctorj-pdf</artifactId> + <version>${asciidoctorj.pdf.version}</version> + </dependency> + <dependency> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctorj</artifactId> + <version>${asciidoctorj.version}</version> + </dependency> + </dependencies> + <configuration> + <sourceDirectory>${basedir}/src</sourceDirectory> + <gemPath>${project.build.directory}/gems-provided</gemPath> + </configuration> + <executions> + <execution> + <id>generate-html-doc</id> + <goals> + <goal>process-asciidoc</goal> + </goals> + <phase>site</phase> + <configuration> + <doctype>book</doctype> + <backend>html5</backend> + <sourceHighlighter>coderay</sourceHighlighter> + <outputDirectory>${basedir}/target/site</outputDirectory> + <requires> + <require>${basedir}/../shared/google-analytics-postprocessor.rb</require> + </requires> + <attributes> + <!-- Location of centralized stylesheet --> + <stylesheet>${basedir}/../shared/trafodion-manuals.css</stylesheet> + <project-version>${env.TRAFODION_VER}</project-version> + <project-name>Trafodion</project-name> + <project-logo>${basedir}/../shared/trafodion-logo.jpg</project-logo> + <project-support>[email protected]</project-support> + <docs-url>http://trafodion.incubator.apache.org/docs</docs-url> + <build-date>${maven.build.timestamp}</build-date> + <google-analytics-account>UA-72491210-1</google-analytics-account> + </attributes> + </configuration> + </execution> + <execution> + <id>generate-pdf-doc</id> + <phase>site</phase> + <goals> + <goal>process-asciidoc</goal> + </goals> + <configuration> + <doctype>book</doctype> + <backend>pdf</backend> + <sourceHighlighter>coderay</sourceHighlighter> + <outputDirectory>${basedir}/target</outputDirectory> + <attributes> + <project-version>${env.TRAFODION_VER}</project-version> + <project-name>Trafodion</project-name> + <project-logo>${basedir}/../shared/trafodion-logo.jpg</project-logo> + <project-support>[email protected]</project-support> + <docs-url>http://trafodion.incubator.apache.org/docs</docs-url> + <build-date>${maven.build.timestamp}</build-date> + <pdf-stylesdir>${basedir}/../shared</pdf-stylesdir> + <pdf-style>trafodion</pdf-style> + <icons>font</icons> + <pagenums/> + <toc/> + <idprefix/> + <idseparator>-</idseparator> + </attributes> + </configuration> + </execution> + </executions> + </plugin> + <!-- Copy files to the web-site end destinations. --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.8</version> + <inherited>false</inherited> + <executions> + <execution> + <id>populate-release-directories</id> + <phase>post-site</phase> + <configuration> + <target name="Populate Release Directories"> + <!-- The website uses the following organization for the docs/target/docs directory: + - To ensure a known location, the base directory contains the LATEST version of the web book and the PDF files. + - The know location is docs/target/docs/<document> + - target/docs/<version>/<document> contains version-specific renderings of the documents. + - target/docs/<version>/<document> contains the PDF version and the web book. The web book is named index.html + --> + <!-- Copy the PDF file to its target directories --> + <copy file="${basedir}/target/index.pdf" tofile="${basedir}/../target/docs/sql_reference/Trafodion_SQL_Reference_Manual.pdf" /> + <copy file="${basedir}/target/index.pdf" tofile="${basedir}/../target/docs/${project.version}/sql_reference/Trafodion_SQL_Reference_Manual.pdf" /> + <!-- Copy the Web Book files to their target directories --> + <copy todir="${basedir}/../target/docs/sql_reference"> + <fileset dir="${basedir}/target/site"> + <include name="**/*.*"/> <!--All sub-directories, too--> + </fileset> + </copy> + <copy todir="${basedir}/../target/docs/${project.version}/sql_reference"> + <fileset dir="${basedir}/target/site"> + <include name="**/*.*"/> <!--All sub-directories, too--> + </fileset> + </copy> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <!-- Included because this is required. No reports are generated. --> + <reporting> + <excludeDefaults>true</excludeDefaults> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-project-info-reports-plugin</artifactId> + <version>2.8</version> + <reportSets> + <reportSet> + <reports> + </reports> + </reportSet> + </reportSets> + </plugin> + </plugins> + </reporting> + + <distributionManagement> + <site> + <id>trafodion.incubator.apache.org</id> + <name>Trafodion Website at incubator.apache.org</name> + <!-- On why this is the tmp dir and not trafodion.incubator.apache.org, see + https://issues.apache.org/jira/browse/HBASE-7593?focusedCommentId=13555866&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13555866 + --> + <url>file:///tmp</url> + </site> + </distributionManagement> +</project> http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/da748b4d/docs/sql_reference/src/asciidoc/_chapters/about.adoc ---------------------------------------------------------------------- diff --git a/docs/sql_reference/src/asciidoc/_chapters/about.adoc b/docs/sql_reference/src/asciidoc/_chapters/about.adoc index b3b9ef6..7dc74ad 100644 --- a/docs/sql_reference/src/asciidoc/_chapters/about.adoc +++ b/docs/sql_reference/src/asciidoc/_chapters/about.adoc @@ -1,212 +1,212 @@ -//// -/** -* @@@ START COPYRIGHT @@@ -* -* Licensed to the Apache Software Foundation (ASF) under one -* or more contributor license agreements. See the NOTICE file -* distributed with this work for additional information -* regarding copyright ownership. The ASF licenses this file -* to you under the Apache License, Version 2.0 (the -* "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -* -* @@@ END COPYRIGHT @@@ -*/ -//// - -[[About_This_Document]] -= About This Document -This manual describes reference information about the syntax of SQL statements, functions, and other -SQL language elements supported by the {project-name} projectâs database software. - -{project-name} SQL statements and utilities are entered interactively or from script files using a client-based tool, -such as the Trafodion Command Interface (TrafCI). To install and configure a client application that enables you -to connect to and use a {project-name} database, see the -{docs-url}/client_install/index.html[_{project-name} Client Installation Guide_]. - -NOTE: In this manual, SQL language elements, statements, and clauses within statements are based on the -ANSI SQL:1999 standard. - -[[Intended_Audience]] -== Intended Audience -This manual is intended for database administrators and application programmers who are using SQL to read, update, -and create {project-name} SQL tables, which map to HBase tables, and to access native HBase and Hive tables. - -You should be familiar with structured query language (SQL) and with the American National Standard Database Language SQL:1999. - -<<< -[[New_and_Changed_Information]] -== New and Changed Information -This edition includes updates for these new features: - -[cols="50%,50%",options="header"] -|=== -| New Feature | Location in the Manual -| Incremental UPDATE STATISTICS | <<update_statistics_statement,UPDATE STATISTICS Statement>> -|=== - -<<< -[[Document_Organization]] -== Document Organization - -[cols="50%,50%",options="header"] -|=== -|Chapter or Appendix | Description -| <<Introduction,Introduction>> | Introduces {project-name} SQL and covers topics such as data consistency, -transaction management, and ANSI compliance. -| <<SQL_Statements,SQL Statements>> | Describes the SQL statements supported by {project-name} SQL. -| <<SQL_Utilities,SQL Utilities>> | Describes the SQL utilities supported by {project-name} SQL. -| <<SQL_Language Elements,SQL Language Elements>> | Describes parts of the language, such as database objects, data types, -expressions, identifiers, literals, and predicates, which occur within the syntax of {project-name} SQL statements. -| <<SQL_Clauses,SQL Clauses>> | Describes clauses used by {project-name} SQL statements. -| <<SQL_Functions_and_Expressions,SQL Functions and Expressions>> | Describes specific functions and expressions that you can use in -{project-name} SQL statements. -| <<SQL_Runtime_Statistics,SQL Runtime Statistics>> | Describes how to gather statistics for active queries or for the Runtime -Management System (RMS) and describes the RMS counters that are returned. -| <<OLAP_Functions,OLAP Functions>> | Describes specific on line analytical processing functions. -| <<Reserved_Words,Appendix A: Reserved Words>> | Lists the words that are reserved in {project-name} SQL. -| <<Limits,Appendix B: Limits>> | Describes limits in {project-name} SQL. -|=== - - -<<< -== Notation Conventions -This list summarizes the notation conventions for syntax presentation in this manual. - -* UPPERCASE LETTERS -+ -Uppercase letters indicate keywords and reserved words. Type these items exactly as shown. Items not enclosed in brackets are required. -+ -``` -SELECT -``` - -* lowercase letters -+ -Lowercase letters, regardless of font, indicate variable items that you supply. Items not enclosed in brackets are required. -+ -``` -file-name -``` - -* [ ] Brackets -+ -Brackets enclose optional syntax items. -+ -``` -DATETIME [start-field TO] end-field -``` -+ -A group of items enclosed in brackets is a list from which you can choose one item or none. -+ -The items in the list can be arranged either vertically, with aligned brackets on each side of the list, or horizontally, enclosed in a pair of brackets and separated by vertical lines. -+ -For example: -+ -``` -DROP SCHEMA schema [CASCADE] -DROP SCHEMA schema [ CASCADE | RESTRICT ] -``` - -<<< -* { } Braces -+ -Braces enclose required syntax items. -+ -``` -FROM { grantee [, grantee ] ... } -``` -+ -A group of items enclosed in braces is a list from which you are required to choose one item. -+ -The items in the list can be arranged either vertically, with aligned braces on each side of the list, or horizontally, enclosed in a pair of braces and separated by vertical lines. -+ -For example: -+ -``` -INTERVAL { start-field TO end-field } -{ single-field } -INTERVAL { start-field TO end-field | single-field } -``` -* | Vertical Line -+ -A vertical line separates alternatives in a horizontal list that is enclosed in brackets or braces. -+ -``` -{expression | NULL} -``` -* … Ellipsis -+ -An ellipsis immediately following a pair of brackets or braces indicates that you can repeat the enclosed sequence of syntax items any number of times. -+ -``` -ATTRIBUTE[S] attribute [, attribute] ... -{, sql-expression } ... -``` -+ -An ellipsis immediately following a single syntax item indicates that you can repeat that syntax item any number of times. -+ -For example: -+ -``` -expression-n ... -``` - -<<< -* Punctuation -+ -Parentheses, commas, semicolons, and other symbols not previously described must be typed as shown. -+ -``` -DAY (datetime-expression) -@script-file -``` -+ -Quotation marks around a symbol such as a bracket or brace indicate the symbol is a required character that you must type as shown. -+ -For example: -+ -``` -"{" module-name [, module-name] ... "}" -``` - -* Item Spacing -+ -Spaces shown between items are required unless one of the items is a punctuation symbol such as a parenthesis or a comma. -+ -``` -DAY (datetime-expression) DAY(datetime-expression) -``` -+ -If there is no space between two items, spaces are not permitted. In this example, no spaces are permitted between the period and any other items: -+ -``` -myfile.sh -``` - -* Line Spacing -+ -If the syntax of a command is too long to fit on a single line, each continuation line is indented three spaces and is separated from the preceding line by a blank line. -+ -This spacing distinguishes items in a continuation line from items in a vertical list of selections. -+ -``` -match-value [NOT] LIKE _pattern - [ESCAPE esc-char-expression] -``` - -<<< -== Comments Encouraged -We encourage your comments concerning this document. We are committed to providing documentation that meets your -needs. Send any errors found, suggestions for improvement, or compliments to {project-support}. - -Include the document title and any comment, error found, or suggestion for improvement you have concerning this document. +//// +/** +* @@@ START COPYRIGHT @@@ +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +* @@@ END COPYRIGHT @@@ +*/ +//// + +[[About_This_Document]] += About This Document +This manual describes reference information about the syntax of SQL statements, functions, and other +SQL language elements supported by the {project-name} projectâs database software. + +{project-name} SQL statements and utilities are entered interactively or from script files using a client-based tool, +such as the Trafodion Command Interface (TrafCI). To install and configure a client application that enables you +to connect to and use a {project-name} database, see the +{docs-url}/client_install/index.html[_{project-name} Client Installation Guide_]. + +NOTE: In this manual, SQL language elements, statements, and clauses within statements are based on the +ANSI SQL:1999 standard. + +[[Intended_Audience]] +== Intended Audience +This manual is intended for database administrators and application programmers who are using SQL to read, update, +and create {project-name} SQL tables, which map to HBase tables, and to access native HBase and Hive tables. + +You should be familiar with structured query language (SQL) and with the American National Standard Database Language SQL:1999. + +<<< +[[New_and_Changed_Information]] +== New and Changed Information +This edition includes updates for these new features: + +[cols="50%,50%",options="header"] +|=== +| New Feature | Location in the Manual +| Incremental UPDATE STATISTICS | <<update_statistics_statement,UPDATE STATISTICS Statement>> +|=== + +<<< +[[Document_Organization]] +== Document Organization + +[cols="50%,50%",options="header"] +|=== +|Chapter or Appendix | Description +| <<Introduction,Introduction>> | Introduces {project-name} SQL and covers topics such as data consistency, +transaction management, and ANSI compliance. +| <<SQL_Statements,SQL Statements>> | Describes the SQL statements supported by {project-name} SQL. +| <<SQL_Utilities,SQL Utilities>> | Describes the SQL utilities supported by {project-name} SQL. +| <<SQL_Language Elements,SQL Language Elements>> | Describes parts of the language, such as database objects, data types, +expressions, identifiers, literals, and predicates, which occur within the syntax of {project-name} SQL statements. +| <<SQL_Clauses,SQL Clauses>> | Describes clauses used by {project-name} SQL statements. +| <<SQL_Functions_and_Expressions,SQL Functions and Expressions>> | Describes specific functions and expressions that you can use in +{project-name} SQL statements. +| <<SQL_Runtime_Statistics,SQL Runtime Statistics>> | Describes how to gather statistics for active queries or for the Runtime +Management System (RMS) and describes the RMS counters that are returned. +| <<OLAP_Functions,OLAP Functions>> | Describes specific on line analytical processing functions. +| <<Reserved_Words,Appendix A: Reserved Words>> | Lists the words that are reserved in {project-name} SQL. +| <<Limits,Appendix B: Limits>> | Describes limits in {project-name} SQL. +|=== + + +<<< +== Notation Conventions +This list summarizes the notation conventions for syntax presentation in this manual. + +* UPPERCASE LETTERS ++ +Uppercase letters indicate keywords and reserved words. Type these items exactly as shown. Items not enclosed in brackets are required. ++ +``` +SELECT +``` + +* lowercase letters ++ +Lowercase letters, regardless of font, indicate variable items that you supply. Items not enclosed in brackets are required. ++ +``` +file-name +``` + +* [ ] Brackets ++ +Brackets enclose optional syntax items. ++ +``` +DATETIME [start-field TO] end-field +``` ++ +A group of items enclosed in brackets is a list from which you can choose one item or none. ++ +The items in the list can be arranged either vertically, with aligned brackets on each side of the list, or horizontally, enclosed in a pair of brackets and separated by vertical lines. ++ +For example: ++ +``` +DROP SCHEMA schema [CASCADE] +DROP SCHEMA schema [ CASCADE | RESTRICT ] +``` + +<<< +* { } Braces ++ +Braces enclose required syntax items. ++ +``` +FROM { grantee [, grantee ] ... } +``` ++ +A group of items enclosed in braces is a list from which you are required to choose one item. ++ +The items in the list can be arranged either vertically, with aligned braces on each side of the list, or horizontally, enclosed in a pair of braces and separated by vertical lines. ++ +For example: ++ +``` +INTERVAL { start-field TO end-field } +{ single-field } +INTERVAL { start-field TO end-field | single-field } +``` +* | Vertical Line ++ +A vertical line separates alternatives in a horizontal list that is enclosed in brackets or braces. ++ +``` +{expression | NULL} +``` +* … Ellipsis ++ +An ellipsis immediately following a pair of brackets or braces indicates that you can repeat the enclosed sequence of syntax items any number of times. ++ +``` +ATTRIBUTE[S] attribute [, attribute] ... +{, sql-expression } ... +``` ++ +An ellipsis immediately following a single syntax item indicates that you can repeat that syntax item any number of times. ++ +For example: ++ +``` +expression-n ... +``` + +<<< +* Punctuation ++ +Parentheses, commas, semicolons, and other symbols not previously described must be typed as shown. ++ +``` +DAY (datetime-expression) +@script-file +``` ++ +Quotation marks around a symbol such as a bracket or brace indicate the symbol is a required character that you must type as shown. ++ +For example: ++ +``` +"{" module-name [, module-name] ... "}" +``` + +* Item Spacing ++ +Spaces shown between items are required unless one of the items is a punctuation symbol such as a parenthesis or a comma. ++ +``` +DAY (datetime-expression) DAY(datetime-expression) +``` ++ +If there is no space between two items, spaces are not permitted. In this example, no spaces are permitted between the period and any other items: ++ +``` +myfile.sh +``` + +* Line Spacing ++ +If the syntax of a command is too long to fit on a single line, each continuation line is indented three spaces and is separated from the preceding line by a blank line. ++ +This spacing distinguishes items in a continuation line from items in a vertical list of selections. ++ +``` +match-value [NOT] LIKE _pattern + [ESCAPE esc-char-expression] +``` + +<<< +== Comments Encouraged +We encourage your comments concerning this document. We are committed to providing documentation that meets your +needs. Send any errors found, suggestions for improvement, or compliments to {project-support}. + +Include the document title and any comment, error found, or suggestion for improvement you have concerning this document.
