First version.
|
@ -0,0 +1,8 @@
|
|||
.bundle/
|
||||
log/*.log
|
||||
pkg/
|
||||
test/dummy/db/*.sqlite3
|
||||
test/dummy/db/*.sqlite3-journal
|
||||
test/dummy/log/*.log
|
||||
test/dummy/storage/
|
||||
test/dummy/tmp/
|
|
@ -0,0 +1,15 @@
|
|||
source 'https://rubygems.org'
|
||||
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
||||
|
||||
# Declare your gem's dependencies in sync_nccu_personal_data.gemspec.
|
||||
# Bundler will treat runtime dependencies like base dependencies, and
|
||||
# development dependencies will be added by default to the :development group.
|
||||
gemspec
|
||||
|
||||
# Declare any dependencies that are still in development here instead of in
|
||||
# your gemspec. These might include edge Rails or gems from your path or
|
||||
# Git. Remember to move these dependencies to your gemspec before releasing
|
||||
# your gem to rubygems.org.
|
||||
|
||||
# To use a debugger
|
||||
# gem 'byebug', group: [:development, :test]
|
|
@ -0,0 +1,17 @@
|
|||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
sync_nccu_personal_data (0.1.1)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
|
||||
PLATFORMS
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
sync_nccu_personal_data!
|
||||
|
||||
BUNDLED WITH
|
||||
2.3.19
|
|
@ -0,0 +1,20 @@
|
|||
Copyright 2019 Eric Tsai
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,2 @@
|
|||
# Usage
|
||||
* set cron job to run `bundle exec rake sync_nccu_personal_plugins:sync` for asia everyday
|
|
@ -0,0 +1,32 @@
|
|||
begin
|
||||
require 'bundler/setup'
|
||||
rescue LoadError
|
||||
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
||||
end
|
||||
|
||||
require 'rdoc/task'
|
||||
|
||||
RDoc::Task.new(:rdoc) do |rdoc|
|
||||
rdoc.rdoc_dir = 'rdoc'
|
||||
rdoc.title = 'SyncNccuPersonalData'
|
||||
rdoc.options << '--line-numbers'
|
||||
rdoc.rdoc_files.include('README.md')
|
||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
end
|
||||
|
||||
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
||||
load 'rails/tasks/engine.rake'
|
||||
|
||||
load 'rails/tasks/statistics.rake'
|
||||
|
||||
require 'bundler/gem_tasks'
|
||||
|
||||
require 'rake/testtask'
|
||||
|
||||
Rake::TestTask.new(:test) do |t|
|
||||
t.libs << 'test'
|
||||
t.pattern = 'test/**/*_test.rb'
|
||||
t.verbose = false
|
||||
end
|
||||
|
||||
task default: :test
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env ruby
|
||||
# This command will automatically be run when you run "rails" with Rails gems
|
||||
# installed from the root of your application.
|
||||
|
||||
ENGINE_ROOT = File.expand_path('..', __dir__)
|
||||
ENGINE_PATH = File.expand_path('../lib/sync_nccu_personal_data/engine', __dir__)
|
||||
APP_PATH = File.expand_path('../test/dummy/config/application', __dir__)
|
||||
|
||||
# Set up gems listed in the Gemfile.
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
||||
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
||||
|
||||
require 'rails/all'
|
||||
require 'rails/engine/commands'
|
|
@ -0,0 +1,2 @@
|
|||
Rails.application.routes.draw do
|
||||
end
|
|
@ -0,0 +1,388 @@
|
|||
#! /bin/sh
|
||||
# $Id: osql,v 1.12 2011-05-11 03:08:13 jklowden Exp $
|
||||
#
|
||||
# Check odbc.ini, odbcinst, and, optionally, freetds.conf,
|
||||
# then execute isql (assume it's unixODBC's isql).
|
||||
#
|
||||
|
||||
USAGE="Syntax: $(basename $0) -S server -U user -P password"
|
||||
|
||||
while getopts I:S:U:P: OPTION
|
||||
do
|
||||
case ${OPTION} in
|
||||
I) OVER_DIR=${OPTARG} # override
|
||||
;;
|
||||
S) DSN=${OPTARG}
|
||||
;;
|
||||
U) USERNAME=${OPTARG}
|
||||
;;
|
||||
P) PASSWORD=${OPTARG}
|
||||
;;
|
||||
\?) echo $USAGE
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#cho ${DSN} ${USERNAME} ${PASSWORD}
|
||||
if [ -z "${DSN}" -o -z "${USERNAME}" -o -z "${PASSWORD}" ]
|
||||
then
|
||||
|
||||
echo $USAGE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ISQL=$(command -v isql)
|
||||
if [ -z "${ISQL}" ]
|
||||
then
|
||||
echo "$(basename $0): error: no \"isql\" command found. Is unixODBC installed?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Establish ODBC prefix directory
|
||||
|
||||
ISQL_DIR=$(strings ${ISQL} | grep ^/ | grep -v elf | grep -v '\.so\.' | head -1 | sed 's/lib$/etc/' )
|
||||
|
||||
INI_DIRNAME="/tmp/$(basename $0).$$"
|
||||
exec 3> ${INI_DIRNAME}
|
||||
|
||||
# Check the libraries, too.
|
||||
if [ -z "${OVER_DIR}" ]
|
||||
then
|
||||
echo "checking shared odbc libraries linked to isql for default directories..."
|
||||
(echo ${ISQL_DIR}; ldd "${ISQL}" | awk '/libodbc\./ {print $3}') \
|
||||
| while read L
|
||||
do
|
||||
strings "$L" | grep '^/' | grep -v '/lib' \
|
||||
| while read D
|
||||
do
|
||||
if [ ! -s "${INI_DIRNAME}" ]
|
||||
then
|
||||
printf " trying $D ... "
|
||||
if [ -d "$D" -a -r "${D}/odbc.ini" ]
|
||||
then
|
||||
printf $D >&3
|
||||
printf "OK"
|
||||
else
|
||||
printf "no"
|
||||
fi
|
||||
printf "\n"
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
ODBC_DIR=$(cat ${INI_DIRNAME}) && rm ${INI_DIRNAME}
|
||||
|
||||
if [ -z "${ODBC_DIR}" -a -z "${OVER_DIR}" ]
|
||||
then
|
||||
echo "$(basename $0): problem: no potential directory strings in \"$(command -v isql)\""
|
||||
echo "$(basename $0): advice: use \"osql -I DIR\" where DIR unixODBC\'s install prefix e.g. /usr/local"
|
||||
echo "isql strings are:"
|
||||
strings ${ISQL} | grep ^/ | sed 's/^/+ /'
|
||||
#xit 1
|
||||
fi
|
||||
|
||||
if [ "${OVER_DIR}" ]
|
||||
then
|
||||
if [ -d "${ODBC_DIR}" ]
|
||||
then
|
||||
echo "\"${ODBC_DIR}\" is a directory, overridden by"
|
||||
else
|
||||
echo "\"${ODBC_DIR}\" is NOT a directory, overridden by"
|
||||
fi
|
||||
echo "\"${OVER_DIR}\"."
|
||||
|
||||
if [ -d "${OVER_DIR}" ]
|
||||
then
|
||||
ODBC_DIR=${OVER_DIR}
|
||||
else
|
||||
echo "$(basename $0): error: \"${OVER_DIR}\" is not a directory"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Look for server entry in odbc.ini
|
||||
echo 'checking odbc.ini files'
|
||||
for F in "${HOME}/.odbc.ini" "${ODBC_DIR}/odbc.ini"
|
||||
do
|
||||
if [ ! -d "$(dirname $F)" ]
|
||||
then
|
||||
echo "warning: $(dirname $F) is not a directory"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ -r "$F" ]
|
||||
then
|
||||
echo " reading $F"
|
||||
else
|
||||
echo " cannot read \"$F\""
|
||||
continue
|
||||
fi
|
||||
|
||||
grep -F "[${DSN}]" $F > /dev/null
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "[${DSN}] found in $F"
|
||||
ODBC_INI=$F
|
||||
break
|
||||
else
|
||||
echo "[${DSN}] not found in $F"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "${ODBC_INI}" ]
|
||||
then
|
||||
echo "$(basename $0): error: unable to locate ${DSN} in any odbc.ini"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Report finding of server entry
|
||||
echo found this section:
|
||||
SED_CMD="/^\[${DSN}\]/,/^[[:space:]]*$/ { s/^/ /; p; }"
|
||||
sed -ne "${SED_CMD}" ${ODBC_INI}
|
||||
|
||||
#
|
||||
# Examine server entry in odbc.ini
|
||||
#
|
||||
|
||||
# Find the driver in the servername or default section
|
||||
for D in "${DSN}" 'default'
|
||||
do
|
||||
echo "looking for driver for DSN [$D] in ${ODBC_INI}"
|
||||
grep "$D" ${ODBC_INI} > /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
CMD="/^\[$D\]/,/^[[:space:]]*$/ { s/^/ /; p; }"
|
||||
DRIVER_LINE=$(sed -ne "${CMD}" ${ODBC_INI} \
|
||||
| grep -Ei '^[[:space:]]*driver[[:space:]]*=')
|
||||
if [ -z "${DRIVER_LINE}" ]
|
||||
then
|
||||
echo " no driver mentioned for [$D] in $(basename ${ODBC_INI})"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo " found driver line: \"${DRIVER_LINE}\""
|
||||
DRIVER=$(echo ${DRIVER_LINE} \
|
||||
| awk -F ' *= *' '{print $2}' \
|
||||
| sed 's/[[:space:]][[:space:]]*//g')
|
||||
if [ "${DRIVER}" ]
|
||||
then
|
||||
echo " driver \"${DRIVER}\" found for [$D] in $(basename ${ODBC_INI})"
|
||||
break
|
||||
else
|
||||
echo " driver line for [$D] incomplete in $(basename ${ODBC_INI})"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "${DRIVER}" ]
|
||||
then
|
||||
echo "$(basename $0): error: no driver found for [${DSN}] in $(basename ${ODBC_INI})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get filename of driver
|
||||
echo found driver named \"${DRIVER}\"
|
||||
if [ -d "${DRIVER}" -o ! -x "${DRIVER}" ]
|
||||
then
|
||||
# not a filename, look it up
|
||||
DRIVERNAME=${DRIVER}
|
||||
ODBC_INST="${ODBC_DIR}/odbcinst.ini"
|
||||
echo "\"${DRIVERNAME}\" is not an executable file"
|
||||
echo "looking for entry named [${DRIVERNAME}] in ${ODBC_INST}"
|
||||
|
||||
grep "${DRIVERNAME}" ${ODBC_INST} > /dev/null
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
echo "$(basename $0): error: no driver entry [${DRIVERNAME}] in ${ODBC_INST}"
|
||||
fi
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
CMD="/^\[${DRIVERNAME}\]/,/^[[:space:]]*$/ { s/^/ /; p; }"
|
||||
DRIVER_LINE=$(sed -ne "${CMD}" ${ODBC_INST} \
|
||||
| grep -Ei '^[[:space:]]*driver[[:space:]]*=')
|
||||
if [ -z "${DRIVER_LINE}" ]
|
||||
then
|
||||
echo "$(basename $0): no driver mentioned for [${DRIVERNAME}] in $(basename ${ODBC_INST})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo " found driver line: \"${DRIVER_LINE}\""
|
||||
DRIVER=$(echo ${DRIVER_LINE} | awk -F ' *= *' '{print $2}')
|
||||
if [ -z "${DRIVER}" ]
|
||||
then
|
||||
echo "$(basename $0): driver line incomplete for [${DRIVERNAME}] in $(basename ${ODBC_INST})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo " found driver ${DRIVER} for [${DRIVERNAME}] in $(basename ${ODBC_INST})"
|
||||
fi
|
||||
|
||||
if [ -z "${DRIVER}" ]
|
||||
then
|
||||
echo $(basename $0): 'error: sorry, failed sanity check: ${DRIVER} is null'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -x "${DRIVER}" ]
|
||||
then
|
||||
echo "${DRIVER} is an executable file"
|
||||
else
|
||||
echo "${DRIVER} is not an executable file"
|
||||
echo "$(basename $0): error: no driver found for ${DSN}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# find the server/servername
|
||||
SERVER_LINE=$(sed -ne "${SED_CMD}" ${ODBC_INI} \
|
||||
| grep -Ei '^[[:space:]]*server(name)*[[:space:]]*=')
|
||||
|
||||
ATTRIBUTE=$(echo ${SERVER_LINE} | awk -F' *= *' '{print $1}')
|
||||
|
||||
if [ -z "${ATTRIBUTE}" ]
|
||||
then
|
||||
echo "$(basename $0): neither \"Server\" nor \"Servername\" found for [${DSN}] in $(basename ${ODBC_INI})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ${SERVER_LINE} | grep -i servername >/dev/null
|
||||
|
||||
#
|
||||
# Find the server's hostname
|
||||
#
|
||||
if [ $? -eq 0 ] # ODBC-Combined
|
||||
then
|
||||
TDS_SERVER=$(echo ${SERVER_LINE} | awk -F ' *= *' '{print $2}')
|
||||
echo 'Using ODBC-Combined strategy'
|
||||
echo "DSN [${DSN}] has servername \"${TDS_SERVER}\" (from ${ODBC_INI})"
|
||||
if [ -z "${TDS_SERVER}" ]
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Look for $TDS_SERVER in freetds.conf
|
||||
|
||||
FREETDS_DIR=$(tsql -C | grep 'freetds.conf directory' | awk -F: '{print $2}' | sed 's/^ *//')
|
||||
if [ -z "${FREETDS_DIR}" ]
|
||||
then
|
||||
echo "$(basename $0): error: unable to locate directory for freetds.conf using \"$(command -v tsql)\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for F in "${HOME}/.freetds.conf" "${FREETDS_DIR}/freetds.conf"
|
||||
do
|
||||
if [ -r "$F" ]
|
||||
then
|
||||
echo $F is a readable file
|
||||
else
|
||||
echo cannot read \"$F\"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "looking for [${TDS_SERVER}] in $F"
|
||||
grep -F "[${TDS_SERVER}]" $F > /dev/null
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
FREETDS_CONF=$F
|
||||
break
|
||||
else
|
||||
echo "[${TDS_SERVER}]" not found in $F
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "${FREETDS_CONF}" ]
|
||||
then
|
||||
echo "$(basename $0): error: unable to locate ${TDS_SERVER} in any freetds.conf"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Examine server entry in freetds.conf
|
||||
|
||||
echo found this section:
|
||||
SED_CMD="/^\[${TDS_SERVER}\]/,/^[[:space:]]*$/ { s/^/ /; p; }"
|
||||
sed -ne "${SED_CMD}" ${FREETDS_CONF}
|
||||
|
||||
SERVER_LINE=$(sed -ne "${SED_CMD}" ${FREETDS_CONF} \
|
||||
| grep -Ei '^[[:space:]]*host[[:space:]]*=')
|
||||
|
||||
# No character class support in mawk,
|
||||
# cf. "Mawk does not support Posix character classes in expressions"
|
||||
# https://bugs.launchpad.net/ubuntu/+source/mawk/+bug/69724
|
||||
HOST=$(echo ${SERVER_LINE} | awk -F' *= *' '{print $2}')
|
||||
|
||||
if [ -z "${HOST}" ]
|
||||
then
|
||||
echo "$(basename $0): no \"host\" entry found for [${TDS_SERVER}] in $(basename ${FREETDS_CONF})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
else # odbc.ini contains a "server", a DNS host
|
||||
HOST=$(echo ${SERVER_LINE} | awk -F ' *= *' '{print $2}')
|
||||
echo "\"${ATTRIBUTE}\" found, not using freetds.conf"
|
||||
echo "${ATTRIBUTE} is \"${HOST}\""
|
||||
if [ -z "${HOST}" ]
|
||||
then
|
||||
echo "$(basename $0): no value found for \"${ATTRIBUTE}\" entry in $(basename ${ODBC_INI})"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# If the "host" is an ip address, look up the name, for neatness, e.g.
|
||||
## $ host 10.81.36.39
|
||||
## 39.36.81.10.IN-ADDR.ARPA domain name pointer ntc5003.eg.com
|
||||
if [ "${HOST}" = "$(echo ${HOST} | sed 's/[^.0-9]*//')" ]
|
||||
then
|
||||
ADDRESS=${HOST}
|
||||
echo 'looking up hostname for ip address' ${ADDRESS}
|
||||
HOST=$(host ${HOST} | awk '/domain/ {print $5}' | sed 's/\.$//')
|
||||
if [ -z "${HOST}" ]
|
||||
then
|
||||
echo "$(basename $0): warning: no DNS hostname found for \"${ADDRESS}\""
|
||||
HOST=${ADDRESS} # restore host address string
|
||||
fi
|
||||
fi
|
||||
|
||||
# Now we have a DNS hostname for the server in HOST
|
||||
if [ "${HOST}" != "${ADDRESS}" ]
|
||||
then
|
||||
ADDRESS=$(host ${HOST} | awk '/has address/ {print $4}' | head -1)
|
||||
fi
|
||||
if [ -z "${ADDRESS}" ]
|
||||
then
|
||||
echo "$(basename $0): no IP address found for \"${HOST}\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#cho ${HOST} has address ${ADDRESS}
|
||||
|
||||
# Report what we know and exec isql
|
||||
|
||||
printf "\n"
|
||||
printf "Configuration looks OK. Connection details:\n\n"
|
||||
printf "%22s:\t%-30s\n" DSN ${DSN}
|
||||
printf "%22s:\t%-30s\n" odbc.ini "${ODBC_INI}"
|
||||
printf "%22s:\t%-30s\n" Driver ${DRIVER}
|
||||
printf "%22s:\t%-30s\n" "Server hostname" ${HOST}
|
||||
printf "%22s:\t%-30s\n" Address ${ADDRESS}
|
||||
printf "\n"
|
||||
|
||||
echo Attempting connection as ${USERNAME} ...
|
||||
|
||||
if [ -z "${TDSDUMP}" ]
|
||||
then
|
||||
TDSDUMP_AUTO="/tmp/$(basename $0).dump.$$"
|
||||
export TDSDUMP=${TDSDUMP_AUTO}
|
||||
fi
|
||||
|
||||
( set -x; isql ${DSN} ${USERNAME} ${PASSWORD} -v ) \
|
||||
|| sed -ne 's/Connecting/FAILED &/p' ${TDSDUMP}
|
||||
|
||||
test "${TDSDUMP_AUTO}" && rm -f ${TDSDUMP_AUTO}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#
|
||||
# This file is installed by FreeTDS if no file by the same
|
||||
# name is found in the installation directory.
|
||||
#
|
||||
# For information about the layout of this file and its settings,
|
||||
# see the freetds.conf manpage "man freetds.conf".
|
||||
|
||||
# Global settings are overridden by those in a database
|
||||
# server specific section
|
||||
[global]
|
||||
# TDS protocol version
|
||||
tds version = auto
|
||||
|
||||
# Whether to write a TDSDUMP file for diagnostic purposes
|
||||
# (setting this to /tmp is insecure on a multi-user system)
|
||||
; dump file = /tmp/freetds.log
|
||||
; debug flags = 0xffff
|
||||
|
||||
# Command and connection timeouts
|
||||
; timeout = 10
|
||||
; connect timeout = 10
|
||||
|
||||
# To reduce data sent from server for BLOBs (like TEXT or
|
||||
# IMAGE) try setting 'text size' to a reasonable limit
|
||||
; text size = 64512
|
||||
|
||||
# If you experience TLS handshake errors and are using openssl,
|
||||
# try adjusting the cipher list (don't surround in double or single quotes)
|
||||
# openssl ciphers = HIGH:!SSLv2:!aNULL:-DH
|
||||
|
||||
# A typical Sybase server
|
||||
[egServer50]
|
||||
host = symachine.domain.com
|
||||
port = 5000
|
||||
tds version = 5.0
|
||||
|
||||
# A typical Microsoft server
|
||||
[egServer73]
|
||||
host = ntmachine.domain.com
|
||||
port = 1433
|
||||
tds version = 7.3
|
|
@ -0,0 +1,23 @@
|
|||
[default]
|
||||
date format = %b %e %Y %I:%M:%S:%z%p
|
||||
|
||||
[en_US]
|
||||
date format = %b %e %Y %I:%M:%S:%z%p
|
||||
language = us_english
|
||||
charset = iso_1
|
||||
|
||||
[es_ES]
|
||||
date format = %b %d %Y %I:%M%p
|
||||
language = spanish
|
||||
charset = iso_1
|
||||
|
||||
[pt_BR]
|
||||
date format = %d/%m/%Y %H:%M
|
||||
language = Portuguese
|
||||
charset = iso_1
|
||||
|
||||
[it_IT]
|
||||
date format = %d/%m/%Y %H:%M
|
||||
language = Italiano
|
||||
charset = iso_1
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
[global]
|
||||
min pool conn = 5
|
||||
max pool conn = 10
|
||||
max member age = 120
|
||||
|
||||
[mypool]
|
||||
user = guest
|
||||
password = sybase
|
||||
database = tempdb
|
||||
server = JDBC_42
|
||||
port = 5000
|
|
@ -0,0 +1,69 @@
|
|||
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
|
||||
* Copyright (C) 1998-1999 Brian Bruns
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _bkpublic_h_
|
||||
#define _bkpublic_h_
|
||||
|
||||
static const char rcsid_bkpublic_h[] = "$Id: bkpublic.h,v 1.5 2004-10-28 12:42:11 freddy77 Exp $";
|
||||
static const void *const no_unused_bkpublic_h_warn[] = { rcsid_bkpublic_h, no_unused_bkpublic_h_warn };
|
||||
|
||||
/* seperate this stuff out later */
|
||||
#include <cspublic.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* buld properties start with 1 i guess */
|
||||
#define BLK_IDENTITY 1
|
||||
|
||||
CS_RETCODE blk_alloc(CS_CONNECTION * connection, CS_INT version, CS_BLKDESC ** blk_pointer);
|
||||
CS_RETCODE blk_bind(CS_BLKDESC * blkdesc, CS_INT colnum, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT * datalen,
|
||||
CS_SMALLINT * indicator);
|
||||
CS_RETCODE blk_colval(SRV_PROC * srvproc, CS_BLKDESC * blkdescp, CS_BLK_ROW * rowp, CS_INT colnum, CS_VOID * valuep,
|
||||
CS_INT valuelen, CS_INT * outlenp);
|
||||
CS_RETCODE blk_default(CS_BLKDESC * blkdesc, CS_INT colnum, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
|
||||
CS_RETCODE blk_describe(CS_BLKDESC * blkdesc, CS_INT colnum, CS_DATAFMT * datafmt);
|
||||
CS_RETCODE blk_done(CS_BLKDESC * blkdesc, CS_INT type, CS_INT * outrow);
|
||||
CS_RETCODE blk_drop(CS_BLKDESC * blkdesc);
|
||||
CS_RETCODE blk_getrow(SRV_PROC * srvproc, CS_BLKDESC * blkdescp, CS_BLK_ROW * rowp);
|
||||
CS_RETCODE blk_gettext(SRV_PROC * srvproc, CS_BLKDESC * blkdescp, CS_BLK_ROW * rowp, CS_INT bufsize, CS_INT * outlenp);
|
||||
CS_RETCODE blk_init(CS_BLKDESC * blkdesc, CS_INT direction, CS_CHAR * tablename, CS_INT tnamelen);
|
||||
CS_RETCODE blk_props(CS_BLKDESC * blkdesc, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
|
||||
CS_RETCODE blk_rowalloc(SRV_PROC * srvproc, CS_BLK_ROW ** row);
|
||||
CS_RETCODE blk_rowdrop(SRV_PROC * srvproc, CS_BLK_ROW * row);
|
||||
CS_RETCODE blk_rowxfer(CS_BLKDESC * blkdesc);
|
||||
CS_RETCODE blk_rowxfer_mult(CS_BLKDESC * blkdesc, CS_INT * row_count);
|
||||
CS_RETCODE blk_sendrow(CS_BLKDESC * blkdesc, CS_BLK_ROW * row);
|
||||
CS_RETCODE blk_sendtext(CS_BLKDESC * blkdesc, CS_BLK_ROW * row, CS_BYTE * buffer, CS_INT buflen);
|
||||
CS_RETCODE blk_srvinit(SRV_PROC * srvproc, CS_BLKDESC * blkdescp);
|
||||
CS_RETCODE blk_textxfer(CS_BLKDESC * blkdesc, CS_BYTE * buffer, CS_INT buflen, CS_INT * outlen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if 0
|
||||
{
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,776 @@
|
|||
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _cspublic_h_
|
||||
#define _cspublic_h_
|
||||
|
||||
#include <cstypes.h>
|
||||
|
||||
#undef TDS_STATIC_CAST
|
||||
#ifdef __cplusplus
|
||||
#define TDS_STATIC_CAST(type, a) static_cast<type>(a)
|
||||
extern "C"
|
||||
{
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#define TDS_STATIC_CAST(type, a) ((type)(a))
|
||||
#endif
|
||||
|
||||
#define CS_PUBLIC
|
||||
#define CS_STATIC static
|
||||
|
||||
#define CS_SUCCEED 1
|
||||
#define CS_FAIL 0
|
||||
#define CS_MEM_ERROR -1
|
||||
#define CS_PENDING -2
|
||||
#define CS_QUIET -3
|
||||
#define CS_BUSY -4
|
||||
#define CS_INTERRUPT -5
|
||||
#define CS_BLK_HAS_TEXT -6
|
||||
#define CS_CONTINUE -7
|
||||
#define CS_FATAL -8
|
||||
#define CS_RET_HAFAILOVER -9
|
||||
#define CS_UNSUPPORTED -10
|
||||
|
||||
#define CS_CANCELED -202
|
||||
#define CS_ROW_FAIL -203
|
||||
#define CS_END_DATA -204
|
||||
#define CS_END_RESULTS -205
|
||||
#define CS_END_ITEM -206
|
||||
#define CS_NOMSG -207
|
||||
#define CS_TIMED_OUT -208
|
||||
|
||||
#define CS_SIZEOF(x) sizeof(x)
|
||||
|
||||
#define CS_LAYER(x) (((x) >> 24) & 0xFF)
|
||||
#define CS_ORIGIN(x) (((x) >> 16) & 0xFF)
|
||||
#define CS_SEVERITY(x) (((x) >> 8) & 0xFF)
|
||||
#define CS_NUMBER(x) ((x) & 0xFF)
|
||||
|
||||
/* forward declarations */
|
||||
typedef CS_RETCODE(*CS_CSLIBMSG_FUNC) (CS_CONTEXT *, CS_CLIENTMSG *);
|
||||
typedef CS_RETCODE(*CS_CLIENTMSG_FUNC) (CS_CONTEXT *, CS_CONNECTION *, CS_CLIENTMSG *);
|
||||
typedef CS_RETCODE(*CS_SERVERMSG_FUNC) (CS_CONTEXT *, CS_CONNECTION *, CS_SERVERMSG *);
|
||||
|
||||
|
||||
#define CS_IODATA TDS_STATIC_CAST(CS_INT, 1600)
|
||||
#define CS_SRC_VALUE -2562
|
||||
|
||||
|
||||
|
||||
/* status bits for CS_SERVERMSG */
|
||||
#define CS_HASEED 0x01
|
||||
|
||||
typedef struct _cs_blkdesc CS_BLKDESC;
|
||||
|
||||
/* CS_CAP_REQUEST values */
|
||||
#define CS_REQ_LANG 1
|
||||
#define CS_REQ_RPC 2
|
||||
#define CS_REQ_NOTIF 3
|
||||
#define CS_REQ_MSTMT 4
|
||||
#define CS_REQ_BCP 5
|
||||
#define CS_REQ_CURSOR 6
|
||||
#define CS_REQ_DYN 7
|
||||
#define CS_REQ_MSG 8
|
||||
#define CS_REQ_PARAM 9
|
||||
#define CS_DATA_INT1 10
|
||||
#define CS_DATA_INT2 11
|
||||
#define CS_DATA_INT4 12
|
||||
#define CS_DATA_BIT 13
|
||||
#define CS_DATA_CHAR 14
|
||||
#define CS_DATA_VCHAR 15
|
||||
#define CS_DATA_BIN 16
|
||||
#define CS_DATA_VBIN 17
|
||||
#define CS_DATA_MNY8 18
|
||||
#define CS_DATA_MNY4 19
|
||||
#define CS_DATA_DATE8 20
|
||||
#define CS_DATA_DATE4 21
|
||||
#define CS_DATA_FLT4 22
|
||||
#define CS_DATA_FLT8 23
|
||||
#define CS_DATA_NUM 24
|
||||
#define CS_DATA_TEXT 25
|
||||
#define CS_DATA_IMAGE 26
|
||||
#define CS_DATA_DEC 27
|
||||
#define CS_DATA_LCHAR 28
|
||||
#define CS_DATA_LBIN 29
|
||||
#define CS_DATA_INTN 30
|
||||
#define CS_DATA_DATETIMEN 31
|
||||
#define CS_DATA_MONEYN 32
|
||||
#define CS_CSR_PREV 33
|
||||
#define CS_CSR_FIRST 34
|
||||
#define CS_CSR_LAST 35
|
||||
#define CS_CSR_ABS 36
|
||||
#define CS_CSR_REL 37
|
||||
#define CS_CSR_MULTI 38
|
||||
#define CS_CON_OOB 39
|
||||
#define CS_CON_INBAND 40
|
||||
#define CS_CON_LOGICAL 41
|
||||
#define CS_PROTO_TEXT 42
|
||||
#define CS_PROTO_BULK 43
|
||||
#define CS_REQ_URGNOTIF 44
|
||||
#define CS_DATA_SENSITIVITY 45
|
||||
#define CS_DATA_BOUNDARY 46
|
||||
#define CS_PROTO_DYNAMIC 47
|
||||
#define CS_PROTO_DYNPROC 48
|
||||
#define CS_DATA_FLTN 49
|
||||
#define CS_DATA_BITN 50
|
||||
#define CS_OPTION_GET 51
|
||||
#define CS_DATA_INT8 52
|
||||
#define CS_DATA_VOID 53
|
||||
|
||||
/* CS_CAP_RESPONSE values */
|
||||
#define CS_RES_NOMSG 1
|
||||
#define CS_RES_NOEED 2
|
||||
#define CS_RES_NOPARAM 3
|
||||
#define CS_DATA_NOINT1 4
|
||||
#define CS_DATA_NOINT2 5
|
||||
#define CS_DATA_NOINT4 6
|
||||
#define CS_DATA_NOBIT 7
|
||||
#define CS_DATA_NOCHAR 8
|
||||
#define CS_DATA_NOVCHAR 9
|
||||
#define CS_DATA_NOBIN 10
|
||||
#define CS_DATA_NOVBIN 11
|
||||
#define CS_DATA_NOMNY8 12
|
||||
#define CS_DATA_NOMNY4 13
|
||||
#define CS_DATA_NODATE8 14
|
||||
#define CS_DATA_NODATE4 15
|
||||
#define CS_DATA_NOFLT4 16
|
||||
#define CS_DATA_NOFLT8 17
|
||||
#define CS_DATA_NONUM 18
|
||||
#define CS_DATA_NOTEXT 19
|
||||
#define CS_DATA_NOIMAGE 20
|
||||
#define CS_DATA_NODEC 21
|
||||
#define CS_DATA_NOLCHAR 22
|
||||
#define CS_DATA_NOLBIN 23
|
||||
#define CS_DATA_NOINTN 24
|
||||
#define CS_DATA_NODATETIMEN 25
|
||||
#define CS_DATA_NOMONEYN 26
|
||||
#define CS_CON_NOOOB 27
|
||||
#define CS_CON_NOINBAND 28
|
||||
#define CS_PROTO_NOTEXT 29
|
||||
#define CS_PROTO_NOBULK 30
|
||||
#define CS_DATA_NOSENSITIVITY 31
|
||||
#define CS_DATA_NOBOUNDARY 32
|
||||
#define CS_RES_NOTDSDEBUG 33
|
||||
#define CS_RES_NOSTRIPBLANKS 34
|
||||
#define CS_DATA_NOINT8 35
|
||||
|
||||
/* Properties */
|
||||
enum
|
||||
{
|
||||
/*
|
||||
* These defines looks weird but programs can test support for defines,
|
||||
* compiler can check enum and there are no define side effecs
|
||||
*/
|
||||
CS_USERNAME = 9100,
|
||||
#define CS_USERNAME CS_USERNAME
|
||||
CS_PASSWORD = 9101,
|
||||
#define CS_PASSWORD CS_PASSWORD
|
||||
CS_APPNAME = 9102,
|
||||
#define CS_APPNAME CS_APPNAME
|
||||
CS_HOSTNAME = 9103,
|
||||
#define CS_HOSTNAME CS_HOSTNAME
|
||||
CS_LOGIN_STATUS = 9104,
|
||||
#define CS_LOGIN_STATUS CS_LOGIN_STATUS
|
||||
CS_TDS_VERSION = 9105,
|
||||
#define CS_TDS_VERSION CS_TDS_VERSION
|
||||
CS_CHARSETCNV = 9106,
|
||||
#define CS_CHARSETCNV CS_CHARSETCNV
|
||||
CS_PACKETSIZE = 9107,
|
||||
#define CS_PACKETSIZE CS_PACKETSIZE
|
||||
CS_USERDATA = 9108,
|
||||
#define CS_USERDATA CS_USERDATA
|
||||
CS_NETIO = 9110,
|
||||
#define CS_NETIO CS_NETIO
|
||||
CS_TEXTLIMIT = 9112,
|
||||
#define CS_TEXTLIMIT CS_TEXTLIMIT
|
||||
CS_HIDDEN_KEYS = 9113,
|
||||
#define CS_HIDDEN_KEYS CS_HIDDEN_KEYS
|
||||
CS_VERSION = 9114,
|
||||
#define CS_VERSION CS_VERSION
|
||||
CS_IFILE = 9115,
|
||||
#define CS_IFILE CS_IFILE
|
||||
CS_LOGIN_TIMEOUT = 9116,
|
||||
#define CS_LOGIN_TIMEOUT CS_LOGIN_TIMEOUT
|
||||
CS_TIMEOUT = 9117,
|
||||
#define CS_TIMEOUT CS_TIMEOUT
|
||||
CS_MAX_CONNECT = 9118,
|
||||
#define CS_MAX_CONNECT CS_MAX_CONNECT
|
||||
CS_EXPOSE_FMTS = 9120,
|
||||
#define CS_EXPOSE_FMTS CS_EXPOSE_FMTS
|
||||
CS_EXTRA_INF = 9121,
|
||||
#define CS_EXTRA_INF CS_EXTRA_INF
|
||||
CS_ANSI_BINDS = 9123,
|
||||
#define CS_ANSI_BINDS CS_ANSI_BINDS
|
||||
CS_BULK_LOGIN = 9124,
|
||||
#define CS_BULK_LOGIN CS_BULK_LOGIN
|
||||
CS_LOC_PROP = 9125,
|
||||
#define CS_LOC_PROP CS_LOC_PROP
|
||||
CS_PARENT_HANDLE = 9130,
|
||||
#define CS_PARENT_HANDLE CS_PARENT_HANDLE
|
||||
CS_EED_CMD = 9131,
|
||||
#define CS_EED_CMD CS_EED_CMD
|
||||
CS_DIAG_TIMEOUT = 9132,
|
||||
#define CS_DIAG_TIMEOUT CS_DIAG_TIMEOUT
|
||||
CS_DISABLE_POLL = 9133,
|
||||
#define CS_DISABLE_POLL CS_DISABLE_POLL
|
||||
CS_SEC_ENCRYPTION = 9135,
|
||||
#define CS_SEC_ENCRYPTION CS_SEC_ENCRYPTION
|
||||
CS_SEC_CHALLENGE = 9136,
|
||||
#define CS_SEC_CHALLENGE CS_SEC_CHALLENGE
|
||||
CS_SEC_NEGOTIATE = 9137,
|
||||
#define CS_SEC_NEGOTIATE CS_SEC_NEGOTIATE
|
||||
CS_CON_STATUS = 9143,
|
||||
#define CS_CON_STATUS CS_CON_STATUS
|
||||
CS_VER_STRING = 9144,
|
||||
#define CS_VER_STRING CS_VER_STRING
|
||||
CS_SERVERNAME = 9146,
|
||||
#define CS_SERVERNAME CS_SERVERNAME
|
||||
CS_SEC_APPDEFINED = 9149,
|
||||
#define CS_SEC_APPDEFINED CS_SEC_APPDEFINED
|
||||
CS_STICKY_BINDS = 9151,
|
||||
#define CS_STICKY_BINDS CS_STICKY_BINDS
|
||||
CS_SERVERADDR = 9206,
|
||||
#define CS_SERVERADDR CS_SERVERADDR
|
||||
CS_PORT = 9300,
|
||||
#define CS_PORT CS_PORT
|
||||
CS_CLIENTCHARSET = 9301,
|
||||
#define CS_CLIENTCHARSET CS_CLIENTCHARSET
|
||||
CS_DATABASE = 9302
|
||||
#define CS_DATABASE CS_DATABASE
|
||||
};
|
||||
|
||||
/* Arbitrary precision math operators */
|
||||
enum
|
||||
{
|
||||
CS_ADD = 1,
|
||||
CS_SUB,
|
||||
CS_MULT,
|
||||
CS_DIV
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
#define CS_TDS_AUTO CS_TDS_AUTO
|
||||
CS_TDS_AUTO = 0,
|
||||
CS_TDS_40 = 7360,
|
||||
CS_TDS_42,
|
||||
CS_TDS_46,
|
||||
CS_TDS_495,
|
||||
CS_TDS_50,
|
||||
CS_TDS_70,
|
||||
CS_TDS_71,
|
||||
#define CS_TDS_71 CS_TDS_71
|
||||
CS_TDS_72,
|
||||
#define CS_TDS_72 CS_TDS_72
|
||||
CS_TDS_73,
|
||||
#define CS_TDS_73 CS_TDS_73
|
||||
CS_TDS_74,
|
||||
#define CS_TDS_74 CS_TDS_74
|
||||
};
|
||||
|
||||
/* bit mask values used by CS_DATAFMT.status */
|
||||
#define CS_HIDDEN (1 << 0)
|
||||
#define CS_KEY (1 << 1)
|
||||
#define CS_VERSION_KEY (1 << 2)
|
||||
#define CS_NODATA (1 << 3)
|
||||
#define CS_UPDATABLE (1 << 4)
|
||||
#define CS_CANBENULL (1 << 5)
|
||||
#define CS_DESCIN (1 << 6)
|
||||
#define CS_DESCOUT (1 << 7)
|
||||
#define CS_INPUTVALUE (1 << 8)
|
||||
#define CS_UPDATECOL (1 << 9)
|
||||
#define CS_RETURN (1 << 10)
|
||||
#define CS_TIMESTAMP (1 << 13)
|
||||
#define CS_NODEFAULT (1 << 14)
|
||||
#define CS_IDENTITY (1 << 15)
|
||||
|
||||
/*
|
||||
* DBD::Sybase compares indicator to CS_NULLDATA so this is -1
|
||||
* (the documentation states -1)
|
||||
*/
|
||||
#define CS_GOODDATA 0
|
||||
#define CS_NULLDATA (-1)
|
||||
|
||||
/* CS_CON_STATUS read-only property bit mask values */
|
||||
#define CS_CONSTAT_CONNECTED 0x01
|
||||
#define CS_CONSTAT_DEAD 0x02
|
||||
|
||||
/*
|
||||
* Code added for CURSOR support
|
||||
* types accepted by ct_cursor
|
||||
*/
|
||||
#define CS_CURSOR_DECLARE 700
|
||||
#define CS_CURSOR_OPEN 701
|
||||
#define CS_CURSOR_ROWS 703
|
||||
#define CS_CURSOR_UPDATE 704
|
||||
#define CS_CURSOR_DELETE 705
|
||||
#define CS_CURSOR_CLOSE 706
|
||||
#define CS_CURSOR_DEALLOC 707
|
||||
#define CS_CURSOR_OPTION 725
|
||||
|
||||
#define CS_FOR_UPDATE TDS_STATIC_CAST(CS_INT, 0x1)
|
||||
#define CS_READ_ONLY TDS_STATIC_CAST(CS_INT, 0x2)
|
||||
#define CS_RESTORE_OPEN TDS_STATIC_CAST(CS_INT, 0x8)
|
||||
#define CS_IMPLICIT_CURSOR TDS_STATIC_CAST(CS_INT, 0x40)
|
||||
|
||||
|
||||
#define CS_CURSTAT_NONE TDS_STATIC_CAST(CS_INT, 0x0)
|
||||
#define CS_CURSTAT_DECLARED TDS_STATIC_CAST(CS_INT, 0x1)
|
||||
#define CS_CURSTAT_OPEN TDS_STATIC_CAST(CS_INT, 0x2)
|
||||
#define CS_CURSTAT_CLOSED TDS_STATIC_CAST(CS_INT, 0x4)
|
||||
#define CS_CURSTAT_RDONLY TDS_STATIC_CAST(CS_INT, 0x8)
|
||||
#define CS_CURSTAT_UPDATABLE TDS_STATIC_CAST(CS_INT, 0x10)
|
||||
#define CS_CURSTAT_ROWCOUNT TDS_STATIC_CAST(CS_INT, 0x20)
|
||||
#define CS_CURSTAT_DEALLOC TDS_STATIC_CAST(CS_INT, 0x40)
|
||||
|
||||
#define CS_CUR_STATUS TDS_STATIC_CAST(CS_INT, 9126)
|
||||
#define CS_CUR_ID TDS_STATIC_CAST(CS_INT, 9127)
|
||||
#define CS_CUR_NAME TDS_STATIC_CAST(CS_INT, 9128)
|
||||
#define CS_CUR_ROWCOUNT TDS_STATIC_CAST(CS_INT, 9129)
|
||||
|
||||
/* options accepted by ct_options() */
|
||||
#define CS_OPT_DATEFIRST 5001
|
||||
#define CS_OPT_TEXTSIZE 5002
|
||||
#define CS_OPT_STATS_TIME 5003
|
||||
#define CS_OPT_STATS_IO 5004
|
||||
#define CS_OPT_ROWCOUNT 5005
|
||||
#define CS_OPT_DATEFORMAT 5007
|
||||
#define CS_OPT_ISOLATION 5008
|
||||
#define CS_OPT_AUTHON 5009
|
||||
#define CS_OPT_SHOWPLAN 5013
|
||||
#define CS_OPT_NOEXEC 5014
|
||||
#define CS_OPT_ARITHIGNORE 5015
|
||||
#define CS_OPT_TRUNCIGNORE 5016
|
||||
#define CS_OPT_ARITHABORT 5017
|
||||
#define CS_OPT_PARSEONLY 5018
|
||||
#define CS_OPT_GETDATA 5020
|
||||
#define CS_OPT_NOCOUNT 5021
|
||||
#define CS_OPT_FORCEPLAN 5023
|
||||
#define CS_OPT_FORMATONLY 5024
|
||||
#define CS_OPT_CHAINXACTS 5025
|
||||
#define CS_OPT_CURCLOSEONXACT 5026
|
||||
#define CS_OPT_FIPSFLAG 5027
|
||||
#define CS_OPT_RESTREES 5028
|
||||
#define CS_OPT_IDENTITYON 5029
|
||||
#define CS_OPT_CURREAD 5030
|
||||
#define CS_OPT_CURWRITE 5031
|
||||
#define CS_OPT_IDENTITYOFF 5032
|
||||
#define CS_OPT_AUTHOFF 5033
|
||||
#define CS_OPT_ANSINULL 5034
|
||||
#define CS_OPT_QUOTED_IDENT 5035
|
||||
#define CS_OPT_ANSIPERM 5036
|
||||
#define CS_OPT_STR_RTRUNC 5037
|
||||
|
||||
/* options accepted by ct_command() */
|
||||
enum ct_command_options
|
||||
{
|
||||
CS_MORE = 16,
|
||||
CS_END = 32,
|
||||
CS_RECOMPILE = 188,
|
||||
CS_NO_RECOMPILE,
|
||||
CS_BULK_INIT,
|
||||
CS_BULK_CONT,
|
||||
CS_BULK_DATA,
|
||||
CS_COLUMN_DATA
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* bind formats, should be mapped to TDS types
|
||||
* can be a combination of bit
|
||||
*/
|
||||
enum
|
||||
{
|
||||
CS_FMT_UNUSED = 0,
|
||||
#define CS_FMT_UNUSED CS_FMT_UNUSED
|
||||
CS_FMT_NULLTERM = 1,
|
||||
#define CS_FMT_NULLTERM CS_FMT_NULLTERM
|
||||
CS_FMT_PADNULL = 2,
|
||||
#define CS_FMT_PADBLANK CS_FMT_PADBLANK
|
||||
CS_FMT_PADBLANK = 4,
|
||||
#define CS_FMT_PADNULL CS_FMT_PADNULL
|
||||
CS_FMT_JUSTIFY_RT = 8
|
||||
#define CS_FMT_JUSTIFY_RT CS_FMT_JUSTIFY_RT
|
||||
};
|
||||
|
||||
/* callbacks */
|
||||
#define CS_COMPLETION_CB 1
|
||||
#define CS_SERVERMSG_CB 2
|
||||
#define CS_CLIENTMSG_CB 3
|
||||
#define CS_NOTIF_CB 4
|
||||
#define CS_ENCRYPT_CB 5
|
||||
#define CS_CHALLENGE_CB 6
|
||||
#define CS_DS_LOOKUP_CB 7
|
||||
#define CS_SECSESSION_CB 8
|
||||
#define CS_SIGNAL_CB 100
|
||||
#define CS_MESSAGE_CB 9119
|
||||
|
||||
/* string types */
|
||||
#define CS_NULLTERM -9
|
||||
#define CS_WILDCARD -99
|
||||
#define CS_NO_LIMIT -9999
|
||||
#define CS_UNUSED -99999
|
||||
|
||||
/* other */
|
||||
#define CS_GET 33
|
||||
#define CS_SET 34
|
||||
#define CS_CLEAR 35
|
||||
#define CS_INIT 36
|
||||
#define CS_STATUS 37
|
||||
#define CS_MSGLIMIT 38
|
||||
#define CS_SUPPORTED 40
|
||||
|
||||
#define CS_CMD_DONE 4046
|
||||
#define CS_CMD_SUCCEED 4047
|
||||
#define CS_CMD_FAIL 4048
|
||||
|
||||
/* commands */
|
||||
#define CS_LANG_CMD 148
|
||||
#define CS_RPC_CMD 149
|
||||
#define CS_SEND_DATA_CMD 151
|
||||
#define CS_SEND_BULK_CMD 153
|
||||
|
||||
#define CS_VERSION_100 112
|
||||
#define CS_VERSION_110 1100
|
||||
#define CS_VERSION_120 1100
|
||||
#define CS_VERSION_125 12500
|
||||
#define CS_VERSION_150 15000
|
||||
|
||||
#define BLK_VERSION_100 CS_VERSION_100
|
||||
#define BLK_VERSION_110 CS_VERSION_110
|
||||
#define BLK_VERSION_120 CS_VERSION_120
|
||||
#define BLK_VERSION_125 CS_VERSION_125
|
||||
#define BLK_VERSION_150 CS_VERSION_150
|
||||
|
||||
#define CS_FORCE_EXIT 300
|
||||
#define CS_FORCE_CLOSE 301
|
||||
|
||||
#define CS_SYNC_IO 8111
|
||||
#define CS_ASYNC_IO 8112
|
||||
#define CS_DEFER_IO 8113
|
||||
|
||||
#define CS_CANCEL_CURRENT 6000
|
||||
#define CS_CANCEL_ALL 6001
|
||||
#define CS_CANCEL_ATTN 6002
|
||||
|
||||
#define CS_ROW_COUNT 800
|
||||
#define CS_CMD_NUMBER 801
|
||||
#define CS_NUM_COMPUTES 802
|
||||
#define CS_NUMDATA 803
|
||||
#define CS_NUMORDERCOLS 805
|
||||
#define CS_MSGTYPE 806
|
||||
#define CS_BROWSE_INFO 807
|
||||
#define CS_TRANS_STATE 808
|
||||
|
||||
#define CS_TRAN_UNDEFINED 0
|
||||
#define CS_TRAN_IN_PROGRESS 1
|
||||
#define CS_TRAN_COMPLETED 2
|
||||
#define CS_TRAN_FAIL 3
|
||||
#define CS_TRAN_STMT_FAIL 4
|
||||
|
||||
#define CS_COMP_OP 5350
|
||||
#define CS_COMP_ID 5351
|
||||
#define CS_COMP_COLID 5352
|
||||
#define CS_COMP_BYLIST 5353
|
||||
#define CS_BYLIST_LEN 5354
|
||||
|
||||
#define CS_NO_COUNT -1
|
||||
|
||||
#define CS_OP_SUM 5370
|
||||
#define CS_OP_AVG 5371
|
||||
#define CS_OP_COUNT 5372
|
||||
#define CS_OP_MIN 5373
|
||||
#define CS_OP_MAX 5374
|
||||
|
||||
#define CS_CAP_REQUEST 1
|
||||
#define CS_CAP_RESPONSE 2
|
||||
|
||||
#define CS_PREPARE 717
|
||||
#define CS_EXECUTE 718
|
||||
#define CS_DESCRIBE_INPUT 720
|
||||
#define CS_DESCRIBE_OUTPUT 721
|
||||
|
||||
#define CS_DEALLOC 711
|
||||
|
||||
#define CS_LC_ALL 7
|
||||
#define CS_SYB_LANG 8
|
||||
#define CS_SYB_CHARSET 9
|
||||
#define CS_SYB_SORTORDER 10
|
||||
#define CS_SYB_COLLATE CS_SYB_SORTORDER
|
||||
#define CS_SYB_LANG_CHARSET 11
|
||||
|
||||
#define CS_BLK_IN 1
|
||||
#define CS_BLK_OUT 2
|
||||
|
||||
#define CS_BLK_BATCH 1
|
||||
#define CS_BLK_ALL 2
|
||||
#define CS_BLK_CANCEL 3
|
||||
|
||||
/* to do support these */
|
||||
|
||||
#define CS_BLK_ARRAY_MAXLEN 0x1000
|
||||
#define CS_DEF_PREC 18
|
||||
|
||||
/* Error Severities */
|
||||
#define CS_SV_INFORM TDS_STATIC_CAST(CS_INT, 0)
|
||||
#define CS_SV_API_FAIL TDS_STATIC_CAST(CS_INT, 1)
|
||||
#define CS_SV_RETRY_FAIL TDS_STATIC_CAST(CS_INT, 2)
|
||||
#define CS_SV_RESOURCE_FAIL TDS_STATIC_CAST(CS_INT, 3)
|
||||
#define CS_SV_CONFIG_FAIL TDS_STATIC_CAST(CS_INT, 4)
|
||||
#define CS_SV_COMM_FAIL TDS_STATIC_CAST(CS_INT, 5)
|
||||
#define CS_SV_INTERNAL_FAIL TDS_STATIC_CAST(CS_INT, 6)
|
||||
#define CS_SV_FATAL TDS_STATIC_CAST(CS_INT, 7)
|
||||
|
||||
/* result_types */
|
||||
#define CS_COMPUTE_RESULT 4045
|
||||
#define CS_CURSOR_RESULT 4041
|
||||
#define CS_PARAM_RESULT 4042
|
||||
#define CS_ROW_RESULT 4040
|
||||
#define CS_STATUS_RESULT 4043
|
||||
#define CS_COMPUTEFMT_RESULT 4050
|
||||
#define CS_ROWFMT_RESULT 4049
|
||||
#define CS_MSG_RESULT 4044
|
||||
#define CS_DESCRIBE_RESULT 4051
|
||||
|
||||
/* bind types */
|
||||
#define CS_ILLEGAL_TYPE TDS_STATIC_CAST(CS_INT, -1)
|
||||
#define CS_CHAR_TYPE TDS_STATIC_CAST(CS_INT, 0)
|
||||
#define CS_BINARY_TYPE TDS_STATIC_CAST(CS_INT, 1)
|
||||
#define CS_LONGCHAR_TYPE TDS_STATIC_CAST(CS_INT, 2)
|
||||
#define CS_LONGBINARY_TYPE TDS_STATIC_CAST(CS_INT, 3)
|
||||
#define CS_TEXT_TYPE TDS_STATIC_CAST(CS_INT, 4)
|
||||
#define CS_IMAGE_TYPE TDS_STATIC_CAST(CS_INT, 5)
|
||||
#define CS_TINYINT_TYPE TDS_STATIC_CAST(CS_INT, 6)
|
||||
#define CS_SMALLINT_TYPE TDS_STATIC_CAST(CS_INT, 7)
|
||||
#define CS_INT_TYPE TDS_STATIC_CAST(CS_INT, 8)
|
||||
#define CS_REAL_TYPE TDS_STATIC_CAST(CS_INT, 9)
|
||||
#define CS_FLOAT_TYPE TDS_STATIC_CAST(CS_INT, 10)
|
||||
#define CS_BIT_TYPE TDS_STATIC_CAST(CS_INT, 11)
|
||||
#define CS_DATETIME_TYPE TDS_STATIC_CAST(CS_INT, 12)
|
||||
#define CS_DATETIME4_TYPE TDS_STATIC_CAST(CS_INT, 13)
|
||||
#define CS_MONEY_TYPE TDS_STATIC_CAST(CS_INT, 14)
|
||||
#define CS_MONEY4_TYPE TDS_STATIC_CAST(CS_INT, 15)
|
||||
#define CS_NUMERIC_TYPE TDS_STATIC_CAST(CS_INT, 16)
|
||||
#define CS_DECIMAL_TYPE TDS_STATIC_CAST(CS_INT, 17)
|
||||
#define CS_VARCHAR_TYPE TDS_STATIC_CAST(CS_INT, 18)
|
||||
#define CS_VARBINARY_TYPE TDS_STATIC_CAST(CS_INT, 19)
|
||||
#define CS_LONG_TYPE TDS_STATIC_CAST(CS_INT, 20)
|
||||
#define CS_SENSITIVITY_TYPE TDS_STATIC_CAST(CS_INT, 21)
|
||||
#define CS_BOUNDARY_TYPE TDS_STATIC_CAST(CS_INT, 22)
|
||||
#define CS_VOID_TYPE TDS_STATIC_CAST(CS_INT, 23)
|
||||
#define CS_USHORT_TYPE TDS_STATIC_CAST(CS_INT, 24)
|
||||
#define CS_UNICHAR_TYPE TDS_STATIC_CAST(CS_INT, 25)
|
||||
#define CS_BLOB_TYPE TDS_STATIC_CAST(CS_INT, 26)
|
||||
#define CS_DATE_TYPE TDS_STATIC_CAST(CS_INT, 27)
|
||||
#define CS_TIME_TYPE TDS_STATIC_CAST(CS_INT, 28)
|
||||
#define CS_UNITEXT_TYPE TDS_STATIC_CAST(CS_INT, 29)
|
||||
#define CS_BIGINT_TYPE TDS_STATIC_CAST(CS_INT, 30)
|
||||
#define CS_USMALLINT_TYPE TDS_STATIC_CAST(CS_INT, 31)
|
||||
#define CS_UINT_TYPE TDS_STATIC_CAST(CS_INT, 32)
|
||||
#define CS_UBIGINT_TYPE TDS_STATIC_CAST(CS_INT, 33)
|
||||
#define CS_XML_TYPE TDS_STATIC_CAST(CS_INT, 34)
|
||||
#define CS_BIGDATETIME_TYPE TDS_STATIC_CAST(CS_INT, 35)
|
||||
#define CS_BIGTIME_TYPE TDS_STATIC_CAST(CS_INT, 36)
|
||||
#define CS_UNIQUE_TYPE TDS_STATIC_CAST(CS_INT, 40)
|
||||
|
||||
#define CS_USER_TYPE TDS_STATIC_CAST(CS_INT, 100)
|
||||
/* cs_dt_info type values */
|
||||
enum
|
||||
{
|
||||
CS_MONTH = 7340,
|
||||
#define CS_MONTH CS_MONTH
|
||||
CS_SHORTMONTH,
|
||||
#define CS_SHORTMONTH CS_SHORTMONTH
|
||||
CS_DAYNAME,
|
||||
#define CS_DAYNAME CS_DAYNAME
|
||||
CS_DATEORDER,
|
||||
#define CS_DATEORDER CS_DATEORDER
|
||||
CS_12HOUR,
|
||||
#define CS_12HOUR CS_12HOUR
|
||||
CS_DT_CONVFMT
|
||||
#define CS_DT_CONVFMT CS_DT_CONVFMT
|
||||
};
|
||||
|
||||
/* DT_CONVFMT types */
|
||||
enum
|
||||
{
|
||||
CS_DATES_SHORT = 0,
|
||||
#define CS_DATES_SHORT CS_DATES_SHORT
|
||||
CS_DATES_MDY1,
|
||||
#define CS_DATES_MDY1 CS_DATES_MDY1
|
||||
CS_DATES_YMD1,
|
||||
#define CS_DATES_YMD1 CS_DATES_YMD1
|
||||
CS_DATES_DMY1,
|
||||
#define CS_DATES_DMY1 CS_DATES_DMY1
|
||||
CS_DATES_DMY2,
|
||||
#define CS_DATES_DMY2 CS_DATES_DMY2
|
||||
CS_DATES_DMY3,
|
||||
#define CS_DATES_DMY3 CS_DATES_DMY3
|
||||
CS_DATES_DMY4,
|
||||
#define CS_DATES_DMY4 CS_DATES_DMY4
|
||||
CS_DATES_MDY2,
|
||||
#define CS_DATES_MDY2 CS_DATES_MDY2
|
||||
CS_DATES_HMS,
|
||||
#define CS_DATES_HMS CS_DATES_HMS
|
||||
CS_DATES_LONG,
|
||||
#define CS_DATES_LONG CS_DATES_LONG
|
||||
CS_DATES_MDY3,
|
||||
#define CS_DATES_MDY3 CS_DATES_MDY3
|
||||
CS_DATES_YMD2,
|
||||
#define CS_DATES_YMD2 CS_DATES_YMD2
|
||||
CS_DATES_YMD3,
|
||||
#define CS_DATES_YMD3 CS_DATES_YMD3
|
||||
CS_DATES_YDM1,
|
||||
#define CS_DATES_YDM1 CS_DATES_YDM1
|
||||
CS_DATES_MYD1,
|
||||
#define CS_DATES_MYD1 CS_DATES_MYD1
|
||||
CS_DATES_DYM1,
|
||||
#define CS_DATES_DYM1 CS_DATES_DYM1
|
||||
CS_DATES_MDY1_YYYY = 101,
|
||||
#define CS_DATES_MDY1_YYYY CS_DATES_MDY1_YYYY
|
||||
CS_DATES_YMD1_YYYY,
|
||||
#define CS_DATES_YMD1_YYYY CS_DATES_YMD1_YYYY
|
||||
CS_DATES_DMY1_YYYY,
|
||||
#define CS_DATES_DMY1_YYYY CS_DATES_DMY1_YYYY
|
||||
CS_DATES_DMY2_YYYY,
|
||||
#define CS_DATES_DMY2_YYYY CS_DATES_DMY2_YYYY
|
||||
CS_DATES_DMY3_YYYY,
|
||||
#define CS_DATES_DMY3_YYYY CS_DATES_DMY3_YYYY
|
||||
CS_DATES_DMY4_YYYY,
|
||||
#define CS_DATES_DMY4_YYYY CS_DATES_DMY4_YYYY
|
||||
CS_DATES_MDY2_YYYY,
|
||||
#define CS_DATES_MDY2_YYYY CS_DATES_MDY2_YYYY
|
||||
CS_DATES_MDY3_YYYY = 110,
|
||||
#define CS_DATES_MDY3_YYYY CS_DATES_MDY3_YYYY
|
||||
CS_DATES_YMD2_YYYY,
|
||||
#define CS_DATES_YMD2_YYYY CS_DATES_YMD2_YYYY
|
||||
CS_DATES_YMD3_YYYY
|
||||
#define CS_DATES_YMD3_YYYY CS_DATES_YMD3_YYYY
|
||||
};
|
||||
|
||||
typedef CS_RETCODE(*CS_CONV_FUNC) (CS_CONTEXT * context, CS_DATAFMT * srcfmt, CS_VOID * src, CS_DATAFMT * detsfmt, CS_VOID * dest,
|
||||
CS_INT * destlen);
|
||||
|
||||
typedef struct _cs_objname
|
||||
{
|
||||
CS_BOOL thinkexists;
|
||||
CS_INT object_type;
|
||||
CS_CHAR last_name[CS_MAX_NAME];
|
||||
CS_INT lnlen;
|
||||
CS_CHAR first_name[CS_MAX_NAME];
|
||||
CS_INT fnlen;
|
||||
CS_VOID *scope;
|
||||
CS_INT scopelen;
|
||||
CS_VOID *thread;
|
||||
CS_INT threadlen;
|
||||
} CS_OBJNAME;
|
||||
|
||||
typedef struct _cs_objdata
|
||||
{
|
||||
CS_BOOL actuallyexists;
|
||||
CS_CONNECTION *connection;
|
||||
CS_COMMAND *command;
|
||||
CS_VOID *buffer;
|
||||
CS_INT buflen;
|
||||
} CS_OBJDATA;
|
||||
|
||||
/* Eventually, these should be in terms of TDS values */
|
||||
enum
|
||||
{
|
||||
CS_OPT_MONDAY = 1,
|
||||
CS_OPT_TUESDAY,
|
||||
CS_OPT_WEDNESDAY,
|
||||
CS_OPT_THURSDAY,
|
||||
CS_OPT_FRIDAY,
|
||||
CS_OPT_SATURDAY,
|
||||
CS_OPT_SUNDAY
|
||||
};
|
||||
enum
|
||||
{
|
||||
CS_OPT_FMTMDY = 1,
|
||||
CS_OPT_FMTDMY,
|
||||
CS_OPT_FMTYMD,
|
||||
CS_OPT_FMTYDM,
|
||||
CS_OPT_FMTMYD,
|
||||
CS_OPT_FMTDYM
|
||||
};
|
||||
enum
|
||||
{
|
||||
CS_OPT_LEVEL0 = 0,
|
||||
CS_OPT_LEVEL1,
|
||||
CS_OPT_LEVEL2,
|
||||
CS_OPT_LEVEL3
|
||||
};
|
||||
|
||||
#define CS_FALSE 0
|
||||
#define CS_TRUE 1
|
||||
|
||||
#define SRV_PROC CS_VOID
|
||||
|
||||
/* constants required for ct_diag (not jet implemented) */
|
||||
#define CS_CLIENTMSG_TYPE 4700
|
||||
#define CS_SERVERMSG_TYPE 4701
|
||||
#define CS_ALLMSG_TYPE 4702
|
||||
|
||||
CS_RETCODE cs_convert(CS_CONTEXT * ctx, CS_DATAFMT * srcfmt, CS_VOID * srcdata, CS_DATAFMT * destfmt, CS_VOID * destdata,
|
||||
CS_INT * resultlen);
|
||||
CS_RETCODE cs_ctx_alloc(CS_INT version, CS_CONTEXT ** ctx);
|
||||
CS_RETCODE cs_ctx_global(CS_INT version, CS_CONTEXT ** ctx);
|
||||
CS_RETCODE cs_ctx_drop(CS_CONTEXT * ctx);
|
||||
CS_RETCODE cs_config(CS_CONTEXT * ctx, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
|
||||
CS_RETCODE cs_strbuild(CS_CONTEXT * ctx, CS_CHAR * buffer, CS_INT buflen, CS_INT * resultlen, CS_CHAR * text, CS_INT textlen,
|
||||
CS_CHAR * formats, CS_INT formatlen, ...);
|
||||
#undef cs_dt_crack
|
||||
CS_RETCODE cs_dt_crack(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec);
|
||||
CS_RETCODE cs_dt_crack_v2(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec);
|
||||
#define cs_dt_crack cs_dt_crack_v2
|
||||
CS_RETCODE cs_loc_alloc(CS_CONTEXT * ctx, CS_LOCALE ** locptr);
|
||||
CS_RETCODE cs_loc_drop(CS_CONTEXT * ctx, CS_LOCALE * locale);
|
||||
CS_RETCODE cs_locale(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_VOID * buffer, CS_INT buflen,
|
||||
CS_INT * outlen);
|
||||
CS_RETCODE cs_dt_info(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_INT item, CS_VOID * buffer,
|
||||
CS_INT buflen, CS_INT * outlen);
|
||||
|
||||
CS_RETCODE cs_calc(CS_CONTEXT * ctx, CS_INT op, CS_INT datatype, CS_VOID * var1, CS_VOID * var2, CS_VOID * dest);
|
||||
CS_RETCODE cs_cmp(CS_CONTEXT * ctx, CS_INT datatype, CS_VOID * var1, CS_VOID * var2, CS_INT * result);
|
||||
CS_RETCODE cs_conv_mult(CS_CONTEXT * ctx, CS_LOCALE * srcloc, CS_LOCALE * destloc, CS_INT * conv_multiplier);
|
||||
CS_RETCODE cs_diag(CS_CONTEXT * ctx, CS_INT operation, CS_INT type, CS_INT idx, CS_VOID * buffer);
|
||||
CS_RETCODE cs_manage_convert(CS_CONTEXT * ctx, CS_INT action, CS_INT srctype, CS_CHAR * srcname, CS_INT srcnamelen, CS_INT desttype,
|
||||
CS_CHAR * destname, CS_INT destnamelen, CS_INT * conv_multiplier, CS_CONV_FUNC * func);
|
||||
CS_RETCODE cs_objects(CS_CONTEXT * ctx, CS_INT action, CS_OBJNAME * objname, CS_OBJDATA * objdata);
|
||||
CS_RETCODE cs_set_convert(CS_CONTEXT * ctx, CS_INT action, CS_INT srctype, CS_INT desttype, CS_CONV_FUNC * func);
|
||||
CS_RETCODE cs_setnull(CS_CONTEXT * ctx, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT buflen);
|
||||
CS_RETCODE cs_strcmp(CS_CONTEXT * ctx, CS_LOCALE * locale, CS_INT type, CS_CHAR * str1, CS_INT len1, CS_CHAR * str2, CS_INT len2,
|
||||
CS_INT * result);
|
||||
CS_RETCODE cs_time(CS_CONTEXT * ctx, CS_LOCALE * locale, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen, CS_DATEREC * daterec);
|
||||
CS_RETCODE cs_will_convert(CS_CONTEXT * ctx, CS_INT srctype, CS_INT desttype, CS_BOOL * result);
|
||||
|
||||
const char * cs_prretcode(int retcode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if 0
|
||||
{
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,214 @@
|
|||
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
|
||||
* Copyright (C) 1998-1999 Brian Bruns
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _cstypes_h_
|
||||
#define _cstypes_h_
|
||||
|
||||
#include "tds_sysdep_public.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef int32_t CS_INT;
|
||||
typedef uint32_t CS_UINT;
|
||||
typedef int64_t CS_BIGINT;
|
||||
typedef uint64_t CS_UBIGINT;
|
||||
typedef int16_t CS_SMALLINT;
|
||||
typedef uint16_t CS_USMALLINT;
|
||||
typedef unsigned char CS_TINYINT;
|
||||
typedef char CS_CHAR;
|
||||
typedef unsigned char CS_BYTE;
|
||||
typedef tds_sysdep_real32_type CS_REAL;
|
||||
typedef tds_sysdep_real64_type CS_FLOAT;
|
||||
typedef int32_t CS_BOOL;
|
||||
typedef void CS_VOID;
|
||||
typedef unsigned char CS_IMAGE;
|
||||
typedef unsigned char CS_TEXT;
|
||||
typedef unsigned char CS_LONGBINARY;
|
||||
typedef unsigned char CS_LONGCHAR;
|
||||
typedef long CS_LONG;
|
||||
typedef unsigned char CS_BINARY;
|
||||
typedef uint16_t CS_USHORT;
|
||||
typedef unsigned char CS_BIT;
|
||||
|
||||
typedef CS_INT CS_RETCODE;
|
||||
|
||||
#define CS_MAX_NAME 132
|
||||
#define CS_MAX_SCALE 77
|
||||
#define CS_MAX_PREC 77 /* used by php */
|
||||
#define CS_MAX_NUMLEN 33 /* used by roguewave */
|
||||
#define CS_MAX_MSG 1024
|
||||
#define CS_SQLSTATE_SIZE 8
|
||||
#define CS_OBJ_NAME 400
|
||||
#define CS_TP_SIZE 16 /* text pointer */
|
||||
#define CS_TS_SIZE 8 /* length of timestamp */
|
||||
|
||||
|
||||
typedef struct _cs_numeric
|
||||
{
|
||||
unsigned char precision;
|
||||
unsigned char scale;
|
||||
unsigned char array[CS_MAX_NUMLEN];
|
||||
} CS_NUMERIC;
|
||||
|
||||
typedef CS_NUMERIC CS_DECIMAL;
|
||||
|
||||
typedef struct _cs_varbinary
|
||||
{
|
||||
CS_SMALLINT len;
|
||||
CS_CHAR array[256];
|
||||
} CS_VARBINARY;
|
||||
|
||||
typedef struct _cs_varchar
|
||||
{
|
||||
CS_SMALLINT len; /* length of the string */
|
||||
CS_CHAR str[256]; /* string, no NULL terminator */
|
||||
} CS_VARCHAR;
|
||||
|
||||
typedef struct _cs_config CS_CONFIG;
|
||||
typedef struct _cs_context CS_CONTEXT;
|
||||
typedef struct _cs_connection CS_CONNECTION;
|
||||
typedef struct _cs_locale CS_LOCALE;
|
||||
typedef struct _cs_command CS_COMMAND;
|
||||
typedef struct _cs_blk_row CS_BLK_ROW;
|
||||
|
||||
typedef struct _cs_iodesc
|
||||
{
|
||||
CS_INT iotype;
|
||||
CS_INT datatype;
|
||||
CS_LOCALE *locale;
|
||||
CS_INT usertype;
|
||||
CS_INT total_txtlen;
|
||||
CS_INT offset;
|
||||
CS_BOOL log_on_update;
|
||||
CS_CHAR name[CS_OBJ_NAME];
|
||||
CS_INT namelen;
|
||||
CS_BYTE timestamp[CS_TS_SIZE];
|
||||
CS_INT timestamplen;
|
||||
CS_BYTE textptr[CS_TP_SIZE];
|
||||
CS_INT textptrlen;
|
||||
} CS_IODESC;
|
||||
|
||||
typedef struct _cs_datafmt
|
||||
{
|
||||
CS_CHAR name[CS_MAX_NAME];
|
||||
CS_INT namelen;
|
||||
CS_INT datatype;
|
||||
CS_INT format;
|
||||
CS_INT maxlength;
|
||||
CS_INT scale;
|
||||
CS_INT precision;
|
||||
CS_INT status;
|
||||
CS_INT count;
|
||||
CS_INT usertype;
|
||||
CS_LOCALE *locale;
|
||||
} CS_DATAFMT;
|
||||
|
||||
typedef struct _cs_money
|
||||
{
|
||||
CS_INT mnyhigh;
|
||||
CS_UINT mnylow;
|
||||
} CS_MONEY;
|
||||
|
||||
typedef struct _cs_money4
|
||||
{
|
||||
CS_INT mny4;
|
||||
} CS_MONEY4;
|
||||
|
||||
typedef CS_INT CS_DATE;
|
||||
|
||||
typedef CS_INT CS_TIME;
|
||||
|
||||
typedef CS_UBIGINT CS_BIGDATETIME;
|
||||
typedef CS_UBIGINT CS_BIGTIME;
|
||||
|
||||
typedef struct _cs_datetime
|
||||
{
|
||||
CS_INT dtdays;
|
||||
CS_INT dttime;
|
||||
} CS_DATETIME;
|
||||
|
||||
typedef struct _cs_datetime4
|
||||
{
|
||||
CS_USHORT days;
|
||||
CS_USHORT minutes;
|
||||
} CS_DATETIME4;
|
||||
|
||||
typedef struct _cs_daterec
|
||||
{
|
||||
CS_INT dateyear;
|
||||
CS_INT datemonth;
|
||||
CS_INT datedmonth;
|
||||
CS_INT datedyear;
|
||||
CS_INT datedweek;
|
||||
CS_INT datehour;
|
||||
CS_INT dateminute;
|
||||
CS_INT datesecond;
|
||||
CS_INT datemsecond;
|
||||
CS_INT datetzone;
|
||||
CS_INT datesecfrac;
|
||||
CS_INT datesecprec;
|
||||
} CS_DATEREC;
|
||||
|
||||
typedef CS_INT CS_MSGNUM;
|
||||
|
||||
typedef struct _cs_clientmsg
|
||||
{
|
||||
CS_INT severity;
|
||||
CS_MSGNUM msgnumber;
|
||||
CS_CHAR msgstring[CS_MAX_MSG];
|
||||
CS_INT msgstringlen;
|
||||
CS_INT osnumber;
|
||||
CS_CHAR osstring[CS_MAX_MSG];
|
||||
CS_INT osstringlen;
|
||||
CS_INT status;
|
||||
CS_BYTE sqlstate[CS_SQLSTATE_SIZE];
|
||||
CS_INT sqlstatelen;
|
||||
} CS_CLIENTMSG;
|
||||
|
||||
typedef struct _cs_servermsg
|
||||
{
|
||||
CS_MSGNUM msgnumber;
|
||||
CS_INT state;
|
||||
CS_INT severity;
|
||||
CS_CHAR text[CS_MAX_MSG];
|
||||
CS_INT textlen;
|
||||
CS_CHAR svrname[CS_MAX_NAME];
|
||||
CS_INT svrnlen;
|
||||
CS_CHAR proc[CS_MAX_NAME];
|
||||
CS_INT proclen;
|
||||
CS_INT line;
|
||||
CS_INT status;
|
||||
CS_BYTE sqlstate[CS_SQLSTATE_SIZE];
|
||||
CS_INT sqlstatelen;
|
||||
} CS_SERVERMSG;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if 0
|
||||
{
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,140 @@
|
|||
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
|
||||
* Copyright (C) 1998-1999 Brian Bruns
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _ctpublic_h_
|
||||
#define _ctpublic_h_
|
||||
|
||||
#include <cspublic.h>
|
||||
|
||||
#undef TDS_STATIC_CAST
|
||||
#ifdef __cplusplus
|
||||
#define TDS_STATIC_CAST(type, a) static_cast<type>(a)
|
||||
extern "C"
|
||||
{
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#define TDS_STATIC_CAST(type, a) ((type)(a))
|
||||
#endif
|
||||
|
||||
/*
|
||||
** define for each CT-Lib API
|
||||
*/
|
||||
#define CT_BIND TDS_STATIC_CAST(CS_INT, 0)
|
||||
#define CT_BR_COLUMN TDS_STATIC_CAST(CS_INT, 1)
|
||||
#define CT_BR_TABLE TDS_STATIC_CAST(CS_INT, 2)
|
||||
#define CT_CALLBACK TDS_STATIC_CAST(CS_INT, 3)
|
||||
#define CT_CANCEL TDS_STATIC_CAST(CS_INT, 4)
|
||||
#define CT_CAPABILITY TDS_STATIC_CAST(CS_INT, 5)
|
||||
#define CT_CLOSE TDS_STATIC_CAST(CS_INT, 6)
|
||||
#define CT_CMD_ALLOC TDS_STATIC_CAST(CS_INT, 7)
|
||||
#define CT_CMD_DROP TDS_STATIC_CAST(CS_INT, 8)
|
||||
#define CT_CMD_PROPS TDS_STATIC_CAST(CS_INT, 9)
|
||||
#define CT_COMMAND TDS_STATIC_CAST(CS_INT, 10)
|
||||
#define CT_COMPUTE_INFO TDS_STATIC_CAST(CS_INT, 11)
|
||||
#define CT_CON_ALLOC TDS_STATIC_CAST(CS_INT, 12)
|
||||
#define CT_CON_DROP TDS_STATIC_CAST(CS_INT, 13)
|
||||
#define CT_CON_PROPS TDS_STATIC_CAST(CS_INT, 14)
|
||||
#define CT_CON_XFER TDS_STATIC_CAST(CS_INT, 15)
|
||||
#define CT_CONFIG TDS_STATIC_CAST(CS_INT, 16)
|
||||
#define CT_CONNECT TDS_STATIC_CAST(CS_INT, 17)
|
||||
#define CT_CURSOR TDS_STATIC_CAST(CS_INT, 18)
|
||||
#define CT_DATA_INFO TDS_STATIC_CAST(CS_INT, 19)
|
||||
#define CT_DEBUG TDS_STATIC_CAST(CS_INT, 20)
|
||||
#define CT_DESCRIBE TDS_STATIC_CAST(CS_INT, 21)
|
||||
#define CT_DIAG TDS_STATIC_CAST(CS_INT, 22)
|
||||
#define CT_DYNAMIC TDS_STATIC_CAST(CS_INT, 23)
|
||||
#define CT_DYNDESC TDS_STATIC_CAST(CS_INT, 24)
|
||||
#define CT_EXIT TDS_STATIC_CAST(CS_INT, 25)
|
||||
#define CT_FETCH TDS_STATIC_CAST(CS_INT, 26)
|
||||
#define CT_GET_DATA TDS_STATIC_CAST(CS_INT, 27)
|
||||
#define CT_GETFORMAT TDS_STATIC_CAST(CS_INT, 28)
|
||||
#define CT_GETLOGINFO TDS_STATIC_CAST(CS_INT, 29)
|
||||
#define CT_INIT TDS_STATIC_CAST(CS_INT, 30)
|
||||
#define CT_KEYDATA TDS_STATIC_CAST(CS_INT, 31)
|
||||
#define CT_OPTIONS TDS_STATIC_CAST(CS_INT, 32)
|
||||
#define CT_PARAM TDS_STATIC_CAST(CS_INT, 33)
|
||||
#define CT_POLL TDS_STATIC_CAST(CS_INT, 34)
|
||||
#define CT_RECVPASSTHRU TDS_STATIC_CAST(CS_INT, 35)
|
||||
#define CT_REMOTE_PWD TDS_STATIC_CAST(CS_INT, 36)
|
||||
#define CT_RES_INFO TDS_STATIC_CAST(CS_INT, 37)
|
||||
#define CT_RESULTS TDS_STATIC_CAST(CS_INT, 38)
|
||||
#define CT_SEND TDS_STATIC_CAST(CS_INT, 39)
|
||||
#define CT_SEND_DATA TDS_STATIC_CAST(CS_INT, 40)
|
||||
#define CT_SENDPASSTHRU TDS_STATIC_CAST(CS_INT, 41)
|
||||
#define CT_SETLOGINFO TDS_STATIC_CAST(CS_INT, 42)
|
||||
#define CT_WAKEUP TDS_STATIC_CAST(CS_INT, 43)
|
||||
#define CT_LABELS TDS_STATIC_CAST(CS_INT, 44)
|
||||
#define CT_DS_LOOKUP TDS_STATIC_CAST(CS_INT, 45)
|
||||
#define CT_DS_DROP TDS_STATIC_CAST(CS_INT, 46)
|
||||
#define CT_DS_OBJINFO TDS_STATIC_CAST(CS_INT, 47)
|
||||
#define CT_SETPARAM TDS_STATIC_CAST(CS_INT, 48)
|
||||
#define CT_DYNSQLDA TDS_STATIC_CAST(CS_INT, 49)
|
||||
#define CT_NOTIFICATION TDS_STATIC_CAST(CS_INT, 1000)
|
||||
|
||||
static const char rcsid_ctpublic_h[] = "$Id: ctpublic.h,v 1.14 2005-05-28 10:48:26 freddy77 Exp $";
|
||||
static const void *const no_unused_ctpublic_h_warn[] = { rcsid_ctpublic_h, no_unused_ctpublic_h_warn };
|
||||
|
||||
|
||||
CS_RETCODE ct_init(CS_CONTEXT * ctx, CS_INT version);
|
||||
CS_RETCODE ct_con_alloc(CS_CONTEXT * ctx, CS_CONNECTION ** con);
|
||||
CS_RETCODE ct_con_props(CS_CONNECTION * con, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * out_len);
|
||||
CS_RETCODE ct_connect(CS_CONNECTION * con, CS_CHAR * servername, CS_INT snamelen);
|
||||
CS_RETCODE ct_cmd_alloc(CS_CONNECTION * con, CS_COMMAND ** cmd);
|
||||
CS_RETCODE ct_cancel(CS_CONNECTION * conn, CS_COMMAND * cmd, CS_INT type);
|
||||
CS_RETCODE ct_cmd_drop(CS_COMMAND * cmd);
|
||||
CS_RETCODE ct_close(CS_CONNECTION * con, CS_INT option);
|
||||
CS_RETCODE ct_con_drop(CS_CONNECTION * con);
|
||||
CS_RETCODE ct_exit(CS_CONTEXT * ctx, CS_INT unused);
|
||||
CS_RETCODE ct_command(CS_COMMAND * cmd, CS_INT type, const CS_VOID * buffer, CS_INT buflen, CS_INT option);
|
||||
CS_RETCODE ct_send(CS_COMMAND * cmd);
|
||||
CS_RETCODE ct_results(CS_COMMAND * cmd, CS_INT * result_type);
|
||||
CS_RETCODE ct_bind(CS_COMMAND * cmd, CS_INT item, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT * copied, CS_SMALLINT * indicator);
|
||||
CS_RETCODE ct_fetch(CS_COMMAND * cmd, CS_INT type, CS_INT offset, CS_INT option, CS_INT * rows_read);
|
||||
CS_RETCODE ct_res_info_dyn(CS_COMMAND * cmd, CS_INT type, CS_VOID * buffer, CS_INT buflen, CS_INT * out_len);
|
||||
CS_RETCODE ct_res_info(CS_COMMAND * cmd, CS_INT type, CS_VOID * buffer, CS_INT buflen, CS_INT * out_len);
|
||||
CS_RETCODE ct_describe(CS_COMMAND * cmd, CS_INT item, CS_DATAFMT * datafmt);
|
||||
CS_RETCODE ct_callback(CS_CONTEXT * ctx, CS_CONNECTION * con, CS_INT action, CS_INT type, CS_VOID * func);
|
||||
CS_RETCODE ct_send_dyn(CS_COMMAND * cmd);
|
||||
CS_RETCODE ct_results_dyn(CS_COMMAND * cmd, CS_INT * result_type);
|
||||
CS_RETCODE ct_config(CS_CONTEXT * ctx, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
|
||||
CS_RETCODE ct_cmd_props(CS_COMMAND * cmd, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
|
||||
CS_RETCODE ct_compute_info(CS_COMMAND * cmd, CS_INT type, CS_INT colnum, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
|
||||
CS_RETCODE ct_get_data(CS_COMMAND * cmd, CS_INT item, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
|
||||
CS_RETCODE ct_send_data(CS_COMMAND * cmd, CS_VOID * buffer, CS_INT buflen);
|
||||
CS_RETCODE ct_data_info(CS_COMMAND * cmd, CS_INT action, CS_INT colnum, CS_IODESC * iodesc);
|
||||
CS_RETCODE ct_capability(CS_CONNECTION * con, CS_INT action, CS_INT type, CS_INT capability, CS_VOID * value);
|
||||
CS_RETCODE ct_dynamic(CS_COMMAND * cmd, CS_INT type, CS_CHAR * id, CS_INT idlen, CS_CHAR * buffer, CS_INT buflen);
|
||||
CS_RETCODE ct_param(CS_COMMAND * cmd, CS_DATAFMT * datafmt, CS_VOID * data, CS_INT datalen, CS_SMALLINT indicator);
|
||||
CS_RETCODE ct_setparam(CS_COMMAND * cmd, CS_DATAFMT * datafmt, CS_VOID * data, CS_INT * datalen, CS_SMALLINT * indicator);
|
||||
CS_RETCODE ct_options(CS_CONNECTION * con, CS_INT action, CS_INT option, CS_VOID * param, CS_INT paramlen, CS_INT * outlen);
|
||||
CS_RETCODE ct_poll(CS_CONTEXT * ctx, CS_CONNECTION * connection, CS_INT milliseconds, CS_CONNECTION ** compconn,
|
||||
CS_COMMAND ** compcmd, CS_INT * compid, CS_INT * compstatus);
|
||||
CS_RETCODE ct_cursor(CS_COMMAND * cmd, CS_INT type, CS_CHAR * name, CS_INT namelen, CS_CHAR * text, CS_INT tlen, CS_INT option);
|
||||
CS_RETCODE ct_diag(CS_CONNECTION * conn, CS_INT operation, CS_INT type, CS_INT idx, CS_VOID * buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if 0
|
||||
{
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,373 @@
|
|||
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
|
||||
* Copyright (C) 2008 Frediano Ziglio
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _odbcss_h_
|
||||
#define _odbcss_h_
|
||||
|
||||
#ifdef TDSODBC_BCP
|
||||
#include <sql.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SQL_DIAG_SS_MSGSTATE (-1150)
|
||||
#define SQL_DIAG_SS_LINE (-1154)
|
||||
|
||||
#define SQL_SOPT_SS_QUERYNOTIFICATION_TIMEOUT 1233
|
||||
#define SQL_SOPT_SS_QUERYNOTIFICATION_MSGTEXT 1234
|
||||
#define SQL_SOPT_SS_QUERYNOTIFICATION_OPTIONS 1235
|
||||
|
||||
#ifndef SQL_SS_LENGTH_UNLIMITED
|
||||
#define SQL_SS_LENGTH_UNLIMITED 0
|
||||
#endif
|
||||
|
||||
#ifndef SQL_COPT_SS_BASE
|
||||
#define SQL_COPT_SS_BASE 1200
|
||||
#endif
|
||||
|
||||
#ifndef SQL_COPT_SS_MARS_ENABLED
|
||||
#define SQL_COPT_SS_MARS_ENABLED (SQL_COPT_SS_BASE+24)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_COPT_SS_OLDPWD
|
||||
#define SQL_COPT_SS_OLDPWD (SQL_COPT_SS_BASE+26)
|
||||
#endif
|
||||
|
||||
#define SQL_INFO_FREETDS_TDS_VERSION 1300
|
||||
#define SQL_INFO_FREETDS_SOCKET 1301
|
||||
|
||||
#ifndef SQL_MARS_ENABLED_NO
|
||||
#define SQL_MARS_ENABLED_NO 0
|
||||
#endif
|
||||
|
||||
#ifndef SQL_MARS_ENABLED_YES
|
||||
#define SQL_MARS_ENABLED_YES 1
|
||||
#endif
|
||||
|
||||
#ifndef SQL_SS_VARIANT
|
||||
#define SQL_SS_VARIANT (-150)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_SS_UDT
|
||||
#define SQL_SS_UDT (-151)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_SS_XML
|
||||
#define SQL_SS_XML (-152)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_SS_TABLE
|
||||
#define SQL_SS_TABLE (-153)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_SS_TIME2
|
||||
#define SQL_SS_TIME2 (-154)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_SS_TIMESTAMPOFFSET
|
||||
#define SQL_SS_TIMESTAMPOFFSET (-155)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* these types are used from conversion from client to server
|
||||
*/
|
||||
#ifndef SQL_C_SS_TIME2
|
||||
#define SQL_C_SS_TIME2 (0x4000)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_C_SS_TIMESTAMPOFFSET
|
||||
#define SQL_C_SS_TIMESTAMPOFFSET (0x4001)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_CA_SS_BASE
|
||||
#define SQL_CA_SS_BASE 1200
|
||||
#endif
|
||||
|
||||
#ifndef SQL_CA_SS_UDT_CATALOG_NAME
|
||||
#define SQL_CA_SS_UDT_CATALOG_NAME (SQL_CA_SS_BASE+18)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_CA_SS_UDT_SCHEMA_NAME
|
||||
#define SQL_CA_SS_UDT_SCHEMA_NAME (SQL_CA_SS_BASE+19)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_CA_SS_UDT_TYPE_NAME
|
||||
#define SQL_CA_SS_UDT_TYPE_NAME (SQL_CA_SS_BASE+20)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_CA_SS_UDT_ASSEMBLY_TYPE_NAME
|
||||
#define SQL_CA_SS_UDT_ASSEMBLY_TYPE_NAME (SQL_CA_SS_BASE+21)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_CA_SS_XML_SCHEMACOLLECTION_CATALOG_NAME
|
||||
#define SQL_CA_SS_XML_SCHEMACOLLECTION_CATALOG_NAME (SQL_CA_SS_BASE+22)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_CA_SS_XML_SCHEMACOLLECTION_SCHEMA_NAME
|
||||
#define SQL_CA_SS_XML_SCHEMACOLLECTION_SCHEMA_NAME (SQL_CA_SS_BASE+23)
|
||||
#endif
|
||||
|
||||
#ifndef SQL_CA_SS_XML_SCHEMACOLLECTION_NAME
|
||||
#define SQL_CA_SS_XML_SCHEMACOLLECTION_NAME (SQL_CA_SS_BASE+24)
|
||||
#endif
|
||||
|
||||
typedef struct tagSS_TIME2_STRUCT {
|
||||
SQLUSMALLINT hour;
|
||||
SQLUSMALLINT minute;
|
||||
SQLUSMALLINT second;
|
||||
SQLUINTEGER fraction;
|
||||
} SQL_SS_TIME2_STRUCT;
|
||||
|
||||
typedef struct tagSS_TIMESTAMPOFFSET_STRUCT {
|
||||
SQLSMALLINT year;
|
||||
SQLUSMALLINT month;
|
||||
SQLUSMALLINT day;
|
||||
SQLUSMALLINT hour;
|
||||
SQLUSMALLINT minute;
|
||||
SQLUSMALLINT second;
|
||||
SQLUINTEGER fraction;
|
||||
SQLSMALLINT timezone_hour;
|
||||
SQLSMALLINT timezone_minute;
|
||||
} SQL_SS_TIMESTAMPOFFSET_STRUCT;
|
||||
|
||||
|
||||
#ifdef TDSODBC_BCP
|
||||
|
||||
#ifndef SUCCEED
|
||||
#define SUCCEED 1
|
||||
#endif
|
||||
#ifndef FAIL
|
||||
#define FAIL 0
|
||||
#endif
|
||||
|
||||
#ifndef BCPKEEPIDENTITY
|
||||
#define BCPKEEPIDENTITY 8
|
||||
#endif
|
||||
#ifndef BCPHINTS
|
||||
#define BCPHINTS 6
|
||||
#endif
|
||||
|
||||
#define BCP_DIRECTION_IN 1
|
||||
|
||||
#define SQL_COPT_SS_BCP (SQL_COPT_SS_BASE+19)
|
||||
#define SQL_BCP_OFF 0
|
||||
#define SQL_BCP_ON 1
|
||||
|
||||
#define SQL_COPT_TDSODBC_IMPL_BASE 1500
|
||||
#define SQL_COPT_TDSODBC_IMPL_BCP_INITA (SQL_COPT_TDSODBC_IMPL_BASE)
|
||||
#define SQL_COPT_TDSODBC_IMPL_BCP_CONTROL (SQL_COPT_TDSODBC_IMPL_BASE+1)
|
||||
#define SQL_COPT_TDSODBC_IMPL_BCP_COLPTR (SQL_COPT_TDSODBC_IMPL_BASE+2)
|
||||
#define SQL_COPT_TDSODBC_IMPL_BCP_SENDROW (SQL_COPT_TDSODBC_IMPL_BASE+3)
|
||||
#define SQL_COPT_TDSODBC_IMPL_BCP_BATCH (SQL_COPT_TDSODBC_IMPL_BASE+4)
|
||||
#define SQL_COPT_TDSODBC_IMPL_BCP_DONE (SQL_COPT_TDSODBC_IMPL_BASE+5)
|
||||
#define SQL_COPT_TDSODBC_IMPL_BCP_BIND (SQL_COPT_TDSODBC_IMPL_BASE+6)
|
||||
#define SQL_COPT_TDSODBC_IMPL_BCP_INITW (SQL_COPT_TDSODBC_IMPL_BASE+7)
|
||||
|
||||
#define SQL_VARLEN_DATA -10
|
||||
|
||||
/* copied from sybdb.h which was copied from tds.h */
|
||||
/* TODO find a much better way... */
|
||||
enum
|
||||
{
|
||||
BCP_TYPE_SQLCHAR = 47, /* 0x2F */
|
||||
#define BCP_TYPE_SQLCHAR BCP_TYPE_SQLCHAR
|
||||
BCP_TYPE_SQLVARCHAR = 39, /* 0x27 */
|
||||
#define BCP_TYPE_SQLVARCHAR BCP_TYPE_SQLVARCHAR
|
||||
BCP_TYPE_SQLINTN = 38, /* 0x26 */
|
||||
#define BCP_TYPE_SQLINTN BCP_TYPE_SQLINTN
|
||||
BCP_TYPE_SQLINT1 = 48, /* 0x30 */
|
||||
#define BCP_TYPE_SQLINT1 BCP_TYPE_SQLINT1
|
||||
BCP_TYPE_SQLINT2 = 52, /* 0x34 */
|
||||
#define BCP_TYPE_SQLINT2 BCP_TYPE_SQLINT2
|
||||
BCP_TYPE_SQLINT4 = 56, /* 0x38 */
|
||||
#define BCP_TYPE_SQLINT4 BCP_TYPE_SQLINT4
|
||||
BCP_TYPE_SQLINT8 = 127, /* 0x7F */
|
||||
#define BCP_TYPE_SQLINT8 BCP_TYPE_SQLINT8
|
||||
BCP_TYPE_SQLFLT8 = 62, /* 0x3E */
|
||||
#define BCP_TYPE_SQLFLT8 BCP_TYPE_SQLFLT8
|
||||
BCP_TYPE_SQLDATETIME = 61, /* 0x3D */
|
||||
#define BCP_TYPE_SQLDATETIME BCP_TYPE_SQLDATETIME
|
||||
BCP_TYPE_SQLBIT = 50, /* 0x32 */
|
||||
#define BCP_TYPE_SQLBIT BCP_TYPE_SQLBIT
|
||||
BCP_TYPE_SQLBITN = 104, /* 0x68 */
|
||||
#define BCP_TYPE_SQLBITN BCP_TYPE_SQLBITN
|
||||
BCP_TYPE_SQLTEXT = 35, /* 0x23 */
|
||||
#define BCP_TYPE_SQLTEXT BCP_TYPE_SQLTEXT
|
||||
BCP_TYPE_SQLNTEXT = 99, /* 0x63 */
|
||||
#define BCP_TYPE_SQLNTEXT BCP_TYPE_SQLNTEXT
|
||||
BCP_TYPE_SQLIMAGE = 34, /* 0x22 */
|
||||
#define BCP_TYPE_SQLIMAGE BCP_TYPE_SQLIMAGE
|
||||
BCP_TYPE_SQLMONEY4 = 122, /* 0x7A */
|
||||
#define BCP_TYPE_SQLMONEY4 BCP_TYPE_SQLMONEY4
|
||||
BCP_TYPE_SQLMONEY = 60, /* 0x3C */
|
||||
#define BCP_TYPE_SQLMONEY BCP_TYPE_SQLMONEY
|
||||
BCP_TYPE_SQLDATETIME4 = 58, /* 0x3A */
|
||||
#define BCP_TYPE_SQLDATETIME4 BCP_TYPE_SQLDATETIME4
|
||||
BCP_TYPE_SQLREAL = 59, /* 0x3B */
|
||||
BCP_TYPE_SQLFLT4 = 59, /* 0x3B */
|
||||
#define BCP_TYPE_SQLREAL BCP_TYPE_SQLREAL
|
||||
#define BCP_TYPE_SQLFLT4 BCP_TYPE_SQLFLT4
|
||||
BCP_TYPE_SQLBINARY = 45, /* 0x2D */
|
||||
#define BCP_TYPE_SQLBINARY BCP_TYPE_SQLBINARY
|
||||
BCP_TYPE_SQLVOID = 31, /* 0x1F */
|
||||
#define BCP_TYPE_SQLVOID BCP_TYPE_SQLVOID
|
||||
BCP_TYPE_SQLVARBINARY = 37, /* 0x25 */
|
||||
#define BCP_TYPE_SQLVARBINARY BCP_TYPE_SQLVARBINARY
|
||||
BCP_TYPE_SQLNUMERIC = 108, /* 0x6C */
|
||||
#define BCP_TYPE_SQLNUMERIC BCP_TYPE_SQLNUMERIC
|
||||
BCP_TYPE_SQLDECIMAL = 106, /* 0x6A */
|
||||
#define BCP_TYPE_SQLDECIMAL BCP_TYPE_SQLDECIMAL
|
||||
BCP_TYPE_SQLFLTN = 109, /* 0x6D */
|
||||
#define BCP_TYPE_SQLFLTN BCP_TYPE_SQLFLTN
|
||||
BCP_TYPE_SQLMONEYN = 110, /* 0x6E */
|
||||
#define BCP_TYPE_SQLMONEYN BCP_TYPE_SQLMONEYN
|
||||
BCP_TYPE_SQLDATETIMN = 111, /* 0x6F */
|
||||
#define BCP_TYPE_SQLDATETIMN BCP_TYPE_SQLDATETIMN
|
||||
BCP_TYPE_SQLNVARCHAR = 103, /* 0x67 */
|
||||
#define BCP_TYPE_SQLNVARCHAR BCP_TYPE_SQLNVARCHAR
|
||||
BCP_TYPE_SQLUNIQUEID = 36, /* 0x24 */
|
||||
#define BCP_TYPE_SQLUNIQUEID BCP_TYPE_SQLUNIQUEID
|
||||
BCP_TYPE_SQLDATETIME2 = 42, /* 0x2a */
|
||||
#define BCP_TYPE_SQLDATETIME2 BCP_TYPE_SQLDATETIME2
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int dtdays;
|
||||
int dttime;
|
||||
} DBDATETIME;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define TDSODBC_INLINE __inline
|
||||
#else
|
||||
#define TDSODBC_INLINE __inline__
|
||||
#endif
|
||||
|
||||
struct tdsodbc_impl_bcp_init_params
|
||||
{
|
||||
const void *tblname;
|
||||
const void *hfile;
|
||||
const void *errfile;
|
||||
int direction;
|
||||
};
|
||||
|
||||
static TDSODBC_INLINE RETCODE SQL_API
|
||||
bcp_initA(HDBC hdbc, const char *tblname, const char *hfile, const char *errfile, int direction)
|
||||
{
|
||||
struct tdsodbc_impl_bcp_init_params params = {tblname, hfile, errfile, direction};
|
||||
return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_INITA, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL;
|
||||
}
|
||||
|
||||
static TDSODBC_INLINE RETCODE SQL_API
|
||||
bcp_initW(HDBC hdbc, const SQLWCHAR *tblname, const SQLWCHAR *hfile, const SQLWCHAR *errfile, int direction)
|
||||
{
|
||||
struct tdsodbc_impl_bcp_init_params params = {tblname, hfile, errfile, direction};
|
||||
return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_INITW, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL;
|
||||
}
|
||||
|
||||
struct tdsodbc_impl_bcp_control_params
|
||||
{
|
||||
int field;
|
||||
void *value;
|
||||
};
|
||||
|
||||
static TDSODBC_INLINE RETCODE SQL_API
|
||||
bcp_control(HDBC hdbc, int field, void *value)
|
||||
{
|
||||
struct tdsodbc_impl_bcp_control_params params = {field, value};
|
||||
return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_CONTROL, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL;
|
||||
}
|
||||
|
||||
struct tdsodbc_impl_bcp_colptr_params
|
||||
{
|
||||
const unsigned char * colptr;
|
||||
int table_column;
|
||||
};
|
||||
|
||||
static TDSODBC_INLINE RETCODE SQL_API
|
||||
bcp_colptr(HDBC hdbc, const unsigned char * colptr, int table_column)
|
||||
{
|
||||
struct tdsodbc_impl_bcp_colptr_params params = {colptr, table_column};
|
||||
return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_COLPTR, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL;
|
||||
}
|
||||
|
||||
static TDSODBC_INLINE RETCODE SQL_API
|
||||
bcp_sendrow(HDBC hdbc)
|
||||
{
|
||||
return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_SENDROW, NULL, SQL_IS_POINTER)) ? SUCCEED : FAIL;
|
||||
}
|
||||
|
||||
struct tdsodbc_impl_bcp_batch_params
|
||||
{
|
||||
int rows;
|
||||
};
|
||||
|
||||
static TDSODBC_INLINE int SQL_API
|
||||
bcp_batch(HDBC hdbc)
|
||||
{
|
||||
struct tdsodbc_impl_bcp_batch_params params = {-1};
|
||||
return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_BATCH, ¶ms, SQL_IS_POINTER)) ? params.rows : -1;
|
||||
}
|
||||
|
||||
struct tdsodbc_impl_bcp_done_params
|
||||
{
|
||||
int rows;
|
||||
};
|
||||
|
||||
static TDSODBC_INLINE int SQL_API
|
||||
bcp_done(HDBC hdbc)
|
||||
{
|
||||
struct tdsodbc_impl_bcp_done_params params = {-1};
|
||||
return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_DONE, ¶ms, SQL_IS_POINTER)) ? params.rows : -1;
|
||||
}
|
||||
|
||||
struct tdsodbc_impl_bcp_bind_params
|
||||
{
|
||||
const unsigned char * varaddr;
|
||||
int prefixlen;
|
||||
int varlen;
|
||||
const unsigned char * terminator;
|
||||
int termlen;
|
||||
int vartype;
|
||||
int table_column;
|
||||
};
|
||||
|
||||
static TDSODBC_INLINE RETCODE SQL_API
|
||||
bcp_bind(HDBC hdbc, const unsigned char * varaddr, int prefixlen, int varlen,
|
||||
const unsigned char * terminator, int termlen, int vartype, int table_column)
|
||||
{
|
||||
struct tdsodbc_impl_bcp_bind_params params = {varaddr, prefixlen, varlen, terminator, termlen, vartype, table_column};
|
||||
return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_BIND, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL;
|
||||
}
|
||||
|
||||
#ifdef UNICODE
|
||||
#define bcp_init bcp_initW
|
||||
#else
|
||||
#define bcp_init bcp_initA
|
||||
#endif
|
||||
|
||||
#endif /* TDSODBC_BCP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _odbcss_h_ */
|
|
@ -0,0 +1,180 @@
|
|||
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
|
||||
* Copyright (C) 1998-1999 Brian Bruns
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef SQLDB_h
|
||||
#define SQLDB_h
|
||||
|
||||
#include "./sybdb.h"
|
||||
|
||||
#define SQLCHAR SYBCHAR
|
||||
#define SQLVARCHAR SYBVARCHAR
|
||||
#define SQLINTN SYBINTN
|
||||
#define SQLINT1 SYBINT1
|
||||
#define SQLINT2 SYBINT2
|
||||
#define SQLINT4 SYBINT4
|
||||
#define SQLINT8 SYBINT8
|
||||
#define SQLFLT8 SYBFLT8
|
||||
#define SQLDATETIME SYBDATETIME
|
||||
#define SQLBIT SYBBIT
|
||||
#define SQLTEXT SYBTEXT
|
||||
#define SQLIMAGE SYBIMAGE
|
||||
#define SQLMONEY4 SYBMONEY4
|
||||
#define SQLMONEY SYBMONEY
|
||||
#define SQLDATETIM4 SYBDATETIME4
|
||||
#define SQLFLT4 SYBREAL
|
||||
#define SQLBINARY SYBBINARY
|
||||
#define SQLVARBINARY SYBVARBINARY
|
||||
#define SQLNUMERIC SYBNUMERIC
|
||||
#define SQLDECIMAL SYBDECIMAL
|
||||
#define SQLFLTN SYBFLTN
|
||||
#define SQLMONEYN SYBMONEYN
|
||||
#define SQLDATETIMN SYBDATETIMN
|
||||
#define SQLVOID SYBVOID
|
||||
|
||||
#define SMALLDATETIBIND SMALLDATETIMEBIND
|
||||
|
||||
#define DBERRHANDLE_PROC EHANDLEFUNC
|
||||
#define DBMSGHANDLE_PROC MHANDLEFUNC
|
||||
|
||||
/* DB-Library errors as defined by Microsoft */
|
||||
#define SQLEMEM SYBEMEM
|
||||
#define SQLENULL SYBENULL
|
||||
#define SQLENLOG SYBENLOG
|
||||
#define SQLEPWD SYBEPWD
|
||||
#define SQLECONN SYBECONN
|
||||
#define SQLEDDNE SYBEDDNE
|
||||
#define SQLENULLO SYBENULLO
|
||||
#define SQLESMSG SYBESMSG
|
||||
#define SQLEBTOK SYBEBTOK
|
||||
#define SQLENSPE SYBENSPE
|
||||
#define SQLEREAD SYBEREAD
|
||||
#define SQLECNOR SYBECNOR
|
||||
#define SQLETSIT SYBETSIT
|
||||
#define SQLEPARM SYBEPARM
|
||||
#define SQLEAUTN SYBEAUTN
|
||||
#define SQLECOFL SYBECOFL
|
||||
#define SQLERDCN SYBERDCN
|
||||
#define SQLEICN SYBEICN
|
||||
#define SQLECLOS SYBECLOS
|
||||
#define SQLENTXT SYBENTXT
|
||||
#define SQLEDNTI SYBEDNTI
|
||||
#define SQLETMTD SYBETMTD
|
||||
#define SQLEASEC SYBEASEC
|
||||
#define SQLENTLL SYBENTLL
|
||||
#define SQLETIME SYBETIME
|
||||
#define SQLEWRIT SYBEWRIT
|
||||
#define SQLEMODE SYBEMODE
|
||||
#define SQLEOOB SYBEOOB
|
||||
#define SQLEITIM SYBEITIM
|
||||
#define SQLEDBPS SYBEDBPS
|
||||
#define SQLEIOPT SYBEIOPT
|
||||
#define SQLEASNL SYBEASNL
|
||||
#define SQLEASUL SYBEASUL
|
||||
#define SQLENPRM SYBENPRM
|
||||
#define SQLEDBOP SYBEDBOP
|
||||
#define SQLENSIP SYBENSIP
|
||||
#define SQLECNULL SYBECNULL
|
||||
#define SQLESEOF SYBESEOF
|
||||
#define SQLERPND SYBERPND
|
||||
#define SQLECSYN SYBECSYN
|
||||
#define SQLENONET SYBENONET
|
||||
#define SQLEBTYP SYBEBTYP
|
||||
#define SQLEABNC SYBEABNC
|
||||
#define SQLEABMT SYBEABMT
|
||||
#define SQLEABNP SYBEABNP
|
||||
#define SQLEBNCR SYBEBNCR
|
||||
#define SQLEAAMT SYBEAAMT
|
||||
#define SQLENXID SYBENXID
|
||||
#define SQLEIFNB SYBEIFNB
|
||||
#define SQLEKBCO SYBEKBCO
|
||||
#define SQLEBBCI SYBEBBCI
|
||||
#define SQLEKBCI SYBEKBCI
|
||||
#define SQLEBCWE SYBEBCWE
|
||||
#define SQLEBCNN SYBEBCNN
|
||||
#define SQLEBCOR SYBEBCOR
|
||||
#define SQLEBCPI SYBEBCPI
|
||||
#define SQLEBCPN SYBEBCPN
|
||||
#define SQLEBCPB SYBEBCPB
|
||||
#define SQLEVDPT SYBEVDPT
|
||||
#define SQLEBIVI SYBEBIVI
|
||||
#define SQLEBCBC SYBEBCBC
|
||||
#define SQLEBCFO SYBEBCFO
|
||||
#define SQLEBCVH SYBEBCVH
|
||||
#define SQLEBCUO SYBEBCUO
|
||||
#define SQLEBUOE SYBEBUOE
|
||||
#define SQLEBWEF SYBEBWEF
|
||||
#define SQLEBTMT SYBEBTMT
|
||||
#define SQLEBEOF SYBEBEOF
|
||||
#define SQLEBCSI SYBEBCSI
|
||||
#define SQLEPNUL SYBEPNUL
|
||||
#define SQLEBSKERR SYBEBSKERR
|
||||
#define SQLEBDIO SYBEBDIO
|
||||
#define SQLEBCNT SYBEBCNT
|
||||
#define SQLEMDBP SYBEMDBP
|
||||
#define SQLINIT SYBINIT
|
||||
#define SQLCRSINV SYBCRSINV
|
||||
#define SQLCRSCMD SYBCRSCMD
|
||||
#define SQLCRSNOIND SYBCRSNOIND
|
||||
#define SQLCRSDIS SYBCRSDIS
|
||||
#define SQLCRSAGR SYBCRSAGR
|
||||
#define SQLCRSORD SYBCRSORD
|
||||
#define SQLCRSMEM SYBCRSMEM
|
||||
#define SQLCRSBSKEY SYBCRSBSKEY
|
||||
#define SQLCRSNORES SYBCRSNORES
|
||||
#define SQLCRSVIEW SYBCRSVIEW
|
||||
#define SQLCRSBUFR SYBCRSBUFR
|
||||
#define SQLCRSFROWN SYBCRSFROWN
|
||||
#define SQLCRSBROL SYBCRSBROL
|
||||
#define SQLCRSFRAND SYBCRSFRAND
|
||||
#define SQLCRSFLAST SYBCRSFLAST
|
||||
#define SQLCRSRO SYBCRSRO
|
||||
#define SQLCRSTAB SYBCRSTAB
|
||||
#define SQLCRSUPDTAB SYBCRSUPDTAB
|
||||
#define SQLCRSUPDNB SYBCRSUPDNB
|
||||
#define SQLCRSVIIND SYBCRSVIIND
|
||||
#define SQLCRSNOUPD SYBCRSNOUPD
|
||||
#define SQLCRSOS SYBCRSOS
|
||||
#define SQLEBCSA SYBEBCSA
|
||||
#define SQLEBCRO SYBEBCRO
|
||||
#define SQLEBCNE SYBEBCNE
|
||||
#define SQLEBCSK SYBEBCSK
|
||||
#define SQLEUVBF SYBEUVBF
|
||||
#define SQLEBIHC SYBEBIHC
|
||||
#define SQLEBWFF SYBEBWFF
|
||||
#define SQLNUMVAL SYBNUMVAL
|
||||
#define SQLEOLDVR SYBEOLDVR
|
||||
#define SQLEBCPS SYBEBCPS
|
||||
#define SQLEDTC SYBEDTC
|
||||
#define SQLENOTIMPL SYBENOTIMPL
|
||||
#define SQLENONFLOAT SYBENONFLOAT
|
||||
#define SQLECONNFB SYBECONNFB
|
||||
|
||||
|
||||
#define dbfreelogin(x) dbloginfree((x))
|
||||
|
||||
#define dbprocerrhandle(p, h) dberrhandle((h))
|
||||
#define dbprocmsghandle(p, h) dbmsghandle((h))
|
||||
|
||||
#define dbwinexit()
|
||||
|
||||
static const char rcsid_sqldb_h[] = "$Id: sqldb.h,v 1.6 2009-12-02 22:35:18 jklowden Exp $";
|
||||
static const void *const no_unused_sqldb_h_warn[] = { rcsid_sqldb_h, no_unused_sqldb_h_warn };
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,57 @@
|
|||
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
|
||||
* Copyright (C) 1998-1999 Brian Bruns
|
||||
* Copyright (C) 2011 Frediano Ziglio
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef SQLFRONT_h
|
||||
#define SQLFRONT_h
|
||||
|
||||
#include "./sybfront.h"
|
||||
|
||||
static const char rcsid_sqlfront_h[] = "$Id: sqlfront.h,v 1.10 2011-07-13 11:06:31 freddy77 Exp $";
|
||||
static const void *const no_unused_sqlfront_h_warn[] = { rcsid_sqlfront_h, no_unused_sqlfront_h_warn };
|
||||
|
||||
typedef DBPROCESS * PDBPROCESS;
|
||||
typedef LOGINREC * PLOGINREC;
|
||||
typedef DBCURSOR * PDBCURSOR;
|
||||
|
||||
typedef int * LPINT;
|
||||
typedef char * LPSTR;
|
||||
#if !defined(PHP_MSSQL_H) || !defined(PHP_MSSQL_API)
|
||||
typedef BYTE * LPBYTE;
|
||||
#endif
|
||||
typedef void * LPVOID;
|
||||
typedef const char * LPCSTR;
|
||||
|
||||
typedef const LPINT LPCINT;
|
||||
#ifndef _LPCBYTE_DEFINED
|
||||
#define _LPCBYTE_DEFINED
|
||||
typedef const BYTE * LPCBYTE;
|
||||
#endif
|
||||
typedef USHORT * LPUSHORT;
|
||||
typedef const LPUSHORT LPCUSHORT;
|
||||
typedef DBINT * LPDBINT;
|
||||
typedef const LPDBINT LPCDBINT;
|
||||
typedef DBBINARY * LPDBBINARY;
|
||||
typedef const LPDBBINARY LPCDBBINARY;
|
||||
typedef DBDATEREC * LPDBDATEREC;
|
||||
typedef const LPDBDATEREC LPCDBDATEREC;
|
||||
typedef DBDATETIME * LPDBDATETIME;
|
||||
typedef const LPDBDATETIME LPCDBDATETIME;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
|
||||
* Copyright (C) 1998-1999 Brian Bruns
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _syberror_h_
|
||||
#define _syberror_h_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static const char rcsid_syberror_h[] = "$Id: syberror.h,v 1.4 2004-10-28 12:42:12 freddy77 Exp $";
|
||||
static const void *const no_unused_syberror_h_warn[] = { rcsid_syberror_h, no_unused_syberror_h_warn };
|
||||
|
||||
/* severity levels, gleaned from google */
|
||||
#define EXINFO 1
|
||||
#define EXUSER 2
|
||||
#define EXNONFATAL 3
|
||||
#define EXCONVERSION 4
|
||||
#define EXSERVER 5
|
||||
#define EXTIME 6
|
||||
#define EXPROGRAM 7
|
||||
#define EXRESOURCE 8
|
||||
#define EXCOMM 9
|
||||
#define EXFATAL 10
|
||||
#define EXCONSISTENCY 11
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if 0
|
||||
{
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,46 @@
|
|||
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
|
||||
* Copyright (C) 1998-1999 Brian Bruns
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef SYBFRONT_h
|
||||
#define SYBFRONT_h
|
||||
|
||||
#include "sybdb.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static const char rcsid_sybfront_h[] = "$Id: sybfront.h,v 1.3 2004-10-28 12:42:12 freddy77 Exp $";
|
||||
static const void *const no_unused_sybfront_h_warn[] = { rcsid_sybfront_h, no_unused_sybfront_h_warn };
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if 0
|
||||
{
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,121 @@
|
|||
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
|
||||
* Copyright (C) 1998-2011 Brian Bruns
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _tds_sysdep_public_h_
|
||||
#define _tds_sysdep_public_h_
|
||||
|
||||
/*
|
||||
* This file is publicly installed.
|
||||
* MUST not include config.h
|
||||
*/
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
# include <stdint.h>
|
||||
#elif defined(__sun) && defined(__SVR4)
|
||||
# include <inttypes.h>
|
||||
#else
|
||||
typedef signed char int8_t; /* 8-bit int */
|
||||
typedef unsigned char uint8_t; /* 8-bit int */
|
||||
/*
|
||||
* This is where platform-specific changes need to be made.
|
||||
*/
|
||||
# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h>
|
||||
# include <windows.h>
|
||||
typedef signed short int16_t; /* 16-bit int */
|
||||
typedef unsigned short uint16_t; /* 16-bit int */
|
||||
typedef signed int int32_t; /* 32-bit int */
|
||||
typedef unsigned int uint32_t; /* 32-bit int */
|
||||
typedef signed __int64 int64_t; /* 64-bit int */
|
||||
typedef unsigned __int64 uint64_t; /* 64-bit int */
|
||||
# if !defined(WIN64) && !defined(_WIN64)
|
||||
typedef signed int intptr_t; /* 32-bit int */
|
||||
typedef unsigned int uintptr_t; /* 32-bit int */
|
||||
# else
|
||||
typedef signed __int64 intptr_t; /* 64-bit int */
|
||||
typedef unsigned __int64 uintptr_t; /* 64-bit int */
|
||||
# endif
|
||||
# else /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) */
|
||||
typedef signed short int16_t; /* 16-bit int */
|
||||
typedef unsigned short uint16_t; /* 16-bit int */
|
||||
typedef signed int int32_t; /* 32-bit int */
|
||||
typedef unsigned int uint32_t; /* 32-bit int */
|
||||
typedef signed long int64_t; /* 64-bit int */
|
||||
typedef unsigned long uint64_t; /* 64-bit int */
|
||||
typedef signed long intptr_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
|
||||
/* try to understand float sizes using float.h constants */
|
||||
#if FLT_RADIX == 2
|
||||
# if FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128
|
||||
# define tds_sysdep_real32_type float /* 32-bit real */
|
||||
# elif DBL_MANT_DIG == 24 && DBL_MAX_EXP == 128
|
||||
# define tds_sysdep_real32_type double /* 32-bit real */
|
||||
# elif LDBL_MANT_DIG == 24 && LDBL_MAX_EXP == 128
|
||||
# define tds_sysdep_real32_type long double /* 32-bit real */
|
||||
# endif
|
||||
# if FLT_MANT_DIG == 53 && FLT_MAX_EXP == 1024
|
||||
# define tds_sysdep_real64_type float /* 64-bit real */
|
||||
# elif DBL_MANT_DIG == 53 && DBL_MAX_EXP == 1024
|
||||
# define tds_sysdep_real64_type double /* 64-bit real */
|
||||
# elif LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
|
||||
# define tds_sysdep_real64_type long double /* 64-bit real */
|
||||
# endif
|
||||
# if !defined(tds_sysdep_real32_type) || !defined(tds_sysdep_real64_type)
|
||||
# error Some float type was not found!
|
||||
# endif
|
||||
#else
|
||||
# if FLT_DIG == 6 && FLT_MAX_10_EXP == 38
|
||||
# define tds_sysdep_real32_type float /* 32-bit real */
|
||||
# elif DBL_DIG == 6 && DBL_MAX_10_EXP == 38
|
||||
# define tds_sysdep_real32_type double /* 32-bit real */
|
||||
# elif LDBL_DIG == 6 && LDBL_MAX_10_EXP == 38
|
||||
# define tds_sysdep_real32_type long double /* 32-bit real */
|
||||
# endif
|
||||
# if FLT_DIG == 15 && FLT_MAX_10_EXP == 308
|
||||
# define tds_sysdep_real64_type float /* 64-bit real */
|
||||
# elif DBL_DIG == 15 && DBL_MAX_10_EXP == 308
|
||||
# define tds_sysdep_real64_type double /* 64-bit real */
|
||||
# elif LDBL_DIG == 15 && LDBL_MAX_10_EXP == 308
|
||||
# define tds_sysdep_real64_type long double /* 64-bit real */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* fall back to configure.ac types */
|
||||
#ifndef tds_sysdep_real32_type
|
||||
#define tds_sysdep_real32_type float /* 32-bit real */
|
||||
#endif /* !tds_sysdep_real32_type */
|
||||
|
||||
#ifndef tds_sysdep_real64_type
|
||||
#define tds_sysdep_real64_type double /* 64-bit real */
|
||||
#endif /* !tds_sysdep_real64_type */
|
||||
|
||||
#if !defined(MSDBLIB) && !defined(SYBDBLIB)
|
||||
#define SYBDBLIB 1
|
||||
#endif
|
||||
#if defined(MSDBLIB) && defined(SYBDBLIB)
|
||||
#error MSDBLIB and SYBDBLIB cannot both be defined
|
||||
#endif
|
||||
|
||||
#endif /* _tds_sysdep_public_h_ */
|
|
@ -0,0 +1,41 @@
|
|||
# libct.la - a libtool library file
|
||||
# Generated by libtool (GNU libtool) 2.4.6
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname='libct.so.4'
|
||||
|
||||
# Names of this library.
|
||||
library_names='libct.so.4.0.0 libct.so.4 libct.so'
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libct.a'
|
||||
|
||||
# Linker flags that cannot go in dependency_libs.
|
||||
inherited_linker_flags=' -pthread'
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -lssl -lcrypto -lpthread'
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libct.
|
||||
current=4
|
||||
age=0
|
||||
revision=0
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/home/rulingcom/orbit_sites/test_client/sync_personal_data_task_for_nccu/freetds-1.1.24/build/lib'
|
|
@ -0,0 +1 @@
|
|||
libct.so.4.0.0
|
|
@ -0,0 +1 @@
|
|||
libct.so.4.0.0
|
|
@ -0,0 +1,41 @@
|
|||
# libsybdb.la - a libtool library file
|
||||
# Generated by libtool (GNU libtool) 2.4.6
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname='libsybdb.so.5'
|
||||
|
||||
# Names of this library.
|
||||
library_names='libsybdb.so.5.1.0 libsybdb.so.5 libsybdb.so'
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libsybdb.a'
|
||||
|
||||
# Linker flags that cannot go in dependency_libs.
|
||||
inherited_linker_flags=' -pthread'
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=' -lssl -lcrypto -lpthread'
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libsybdb.
|
||||
current=6
|
||||
age=1
|
||||
revision=0
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/home/rulingcom/orbit_sites/test_client/sync_personal_data_task_for_nccu/freetds-1.1.24/build/lib'
|
|
@ -0,0 +1 @@
|
|||
libsybdb.so.5.1.0
|
|
@ -0,0 +1 @@
|
|||
libsybdb.so.5.1.0
|
After Width: | Height: | Size: 898 B |
After Width: | Height: | Size: 934 B |
After Width: | Height: | Size: 915 B |
After Width: | Height: | Size: 922 B |
After Width: | Height: | Size: 915 B |
After Width: | Height: | Size: 919 B |
After Width: | Height: | Size: 925 B |
After Width: | Height: | Size: 910 B |
After Width: | Height: | Size: 923 B |
After Width: | Height: | Size: 927 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
|
@ -0,0 +1 @@
|
|||
<html> <P>at <a HREF="http://www.freetds.org/reference/">www.freetds.org</a> </html>
|
|
@ -0,0 +1 @@
|
|||
<html> <P>at <a HREF="http://www.freetds.org/userguide/">www.freetds.org</a> </html>
|
|
@ -0,0 +1,131 @@
|
|||
.\" cf. groff_mdoc
|
||||
.Dd March 26, 2015
|
||||
.Dt BSQLDB 1
|
||||
.Os FreeTDS 1.1.24
|
||||
.Sh NAME
|
||||
.Nm bsqldb
|
||||
.Nd batch SQL script processor using DB-Library
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl hqv
|
||||
.Op Fl S Ar servername
|
||||
.Op Fl D Ar database
|
||||
.Op Fl U Ar username
|
||||
.Op Fl P Ar password
|
||||
.Op Fl i Ar input_file
|
||||
.Op Fl o Ar output_file
|
||||
.Op Fl e Ar error_file
|
||||
.Op Fl H Ar hostname
|
||||
.Op Fl t Ar field_term
|
||||
.Op Fl R Ar pivot_description
|
||||
.\"
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is a utility program distributed with FreeTDS.
|
||||
.Nm
|
||||
is a non-interactive equivalent of the "isql" utility programs
|
||||
distributed by Sybase and Microsoft. Like them,
|
||||
.Nm
|
||||
uses the command "go" on a line by itself as a separator between
|
||||
batches. The last batch need not be followed by "go".
|
||||
.Nm
|
||||
makes use of the DB-Library API provided by FreeTDS. This API is of
|
||||
course also available to application developers.
|
||||
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width indent
|
||||
.It Fl D Ar database
|
||||
Database to use.
|
||||
.It Fl H Ar hostname
|
||||
hostname Override name of client sent to server.
|
||||
.It Fl P Ar password
|
||||
Database server password.
|
||||
.It Fl S Ar servername
|
||||
Database server to which to connect.
|
||||
.It Fl U Ar username
|
||||
Database server login name. If username is not provided, a domain
|
||||
login is attempted for TDS 7+ connections.
|
||||
.It Fl e Ar error_file
|
||||
Name of file for errors.
|
||||
.It Fl h
|
||||
Print column headers with the data to the same file.
|
||||
.It Fl i Ar input_file
|
||||
Name of script file, containing SQL.
|
||||
.It Fl o Ar output_file
|
||||
Name of output file, holding result data.
|
||||
.It Fl q
|
||||
Do not print column metadata, return status, or rowcount. Overrides
|
||||
.Fl h Ns .
|
||||
.It Fl t Ar field_term
|
||||
Specifies the field terminator. Default is two spaces (' ').
|
||||
Recognized escape sequences are tab ('\\t'), carriage return ('\\r'),
|
||||
newline ('\\n'), and backslash ('\\\\').
|
||||
.It Fl v
|
||||
Verbose mode, for more information about the DB-Library interaction.
|
||||
This also reports the result set metadata, including and return code. All
|
||||
verbose data are written to standard error (or
|
||||
.Fl e Ns ), so as not to interfere with the data stream.
|
||||
.It Fl R Ar pivot_description
|
||||
Specify pivot trasformation. The format is
|
||||
.Ao Ar down\ columns Ac
|
||||
.Ao Ar across\ columns Ac
|
||||
.Ao Ar function Ac
|
||||
.Ao Ar value Ac .
|
||||
Columns are specified but numbers.
|
||||
The format of
|
||||
.Ar down columns
|
||||
and
|
||||
.Ar across columns
|
||||
is a comma separated list of columns.
|
||||
.Ar function
|
||||
is either count, sum, min or max.
|
||||
.El
|
||||
.\"
|
||||
.Sh ENVIRONMENT
|
||||
.Ev DSQUERY
|
||||
default
|
||||
.Ar servername
|
||||
.\"
|
||||
.Sh NOTES
|
||||
.Nm
|
||||
is a filter; it reads from standard input, writes to standard output,
|
||||
and writes errors to standard error. The
|
||||
.Fl i Ns , Fl o Ns , and Fl e
|
||||
options override these defaults.
|
||||
.Pp
|
||||
The source code for
|
||||
.Nm
|
||||
is intended as a model for DB-Library users. DB-Library has a rich set
|
||||
of functions, and it can be hard sometimes to understand how to use
|
||||
them, particularly the first time. If you find something about the
|
||||
source code unclear, you are encouraged to email the author your
|
||||
comments.
|
||||
.\"
|
||||
.Sh EXIT STATUS
|
||||
.Nm
|
||||
exits 0 on success, and >0 if the server cannot process the query.
|
||||
.Pp
|
||||
For messages with severity > 10,
|
||||
.Nm
|
||||
calls exit(3) with the severity level. For example, if the severity
|
||||
level is 16,
|
||||
.Nm
|
||||
will return an exit status of 16 to the shell.
|
||||
.\"
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
first appeared in FreeTDS 0.63.
|
||||
.\"
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An "James K. Lowden" Aq jklowden@freetds.org .
|
||||
.\"
|
||||
.Sh BUGS
|
||||
Microsoft servers as of SQL Server 7.0 SP 3 do not return output
|
||||
parameters unless the RPC functions are used. This means
|
||||
.Nm
|
||||
cannot return output parameters for stored procedures with these
|
||||
servers.
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
.\" cf. groff_mdoc
|
||||
.Dd March 25, 2015
|
||||
.Os FreeTDS 1.1.24
|
||||
.Dt BSQLODBC FreeTDS "FreeTDS Reference Manual"
|
||||
.\"
|
||||
.Sh NAME
|
||||
.Nm bsqlodbc
|
||||
.Nd batch SQL script processor using ODBC
|
||||
.\"
|
||||
.Sh SYNOPSIS
|
||||
.Pp
|
||||
.Nm
|
||||
.Op Fl hqv
|
||||
.Op Fl U Ar username
|
||||
.Op Fl P Ar password
|
||||
.Op Fl S Ar server
|
||||
.Op Fl D Ar database
|
||||
.Op Fl i Ar input_file
|
||||
.Op Fl o Ar output_file
|
||||
.Op Fl e Ar error_file
|
||||
.Op Fl t Ar field_term
|
||||
.Op Fl V Ar odbc_version
|
||||
.\"
|
||||
.Sh DESCRIPTION
|
||||
.Pp
|
||||
.Nm
|
||||
is a utility program distributed with FreeTDS.
|
||||
.Pp
|
||||
.Nm
|
||||
is a non-interactive equivalent of the
|
||||
.Ql isql
|
||||
utility programs distributed by Sybase and Microsoft. Like them,
|
||||
.Nm
|
||||
uses the command
|
||||
.Ql go
|
||||
on a line by itself as a separator between batches. The last
|
||||
batch need not be followed by
|
||||
.Ql go .
|
||||
.Pp
|
||||
.Nm
|
||||
makes use of the ODBC API provided by FreeTDS. This
|
||||
API is of course also available to application developers.
|
||||
.\"
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width indent
|
||||
.It Fl U Ar username
|
||||
Database server login name.
|
||||
.It Fl P Ar password
|
||||
Database server password.
|
||||
.It Fl S Ar server
|
||||
Database server to which to connect.
|
||||
.It Fl D Ar database
|
||||
Database to use.
|
||||
.It Fl i Ar input_file
|
||||
Name of script file, containing SQL.
|
||||
.It Fl o Ar output_file
|
||||
Name of output file, holding result data.
|
||||
.It Fl e Ar error_file
|
||||
Name of file for errors.
|
||||
.It Fl t Ar field_term
|
||||
Specifies the field terminator. Default is two spaces (
|
||||
.Ql \ \
|
||||
.Ns ).
|
||||
Recognized escape sequences are tab (
|
||||
.Ql \et
|
||||
.Ns ),
|
||||
carriage return (
|
||||
.Ql \er
|
||||
.Ns ),
|
||||
newline (
|
||||
.Ql \en
|
||||
.Ns ),
|
||||
and backslash (
|
||||
.Ql \e\e
|
||||
.Ns ).
|
||||
.It Fl h
|
||||
Print column headers with the data to the same file.
|
||||
.It Fl q
|
||||
Do not print column metadata, return status, or rowcount. Overrides
|
||||
.Fl h .
|
||||
.It Fl v
|
||||
Verbose mode, for more information about the ODBC interaction.
|
||||
This also reports the result set metadata, including and return code. All
|
||||
verbose data are written to standard error (or
|
||||
.Fl e Ns ),
|
||||
so as not to interfere with the data stream.
|
||||
.It Fl V Ar odbc_version
|
||||
Specify ODBC version (2 or 3).
|
||||
.El
|
||||
.\"
|
||||
.Sh NOTES
|
||||
.Pp
|
||||
.Nm
|
||||
is a filter; it reads from standard input, writes to standard output,
|
||||
and writes errors to standard error. The
|
||||
.Fl i ,
|
||||
.Fl o ,
|
||||
and
|
||||
.Fl e
|
||||
options override these defaults.
|
||||
.Sh EXIT STATUS
|
||||
.Nm
|
||||
exits 0 on success, and >0 if the server cannot process the query.
|
||||
.\"
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
first appeared in FreeTDS 0.65.
|
||||
.\"
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An James K. Lowden Aq jklowden@freetds.org .
|
|
@ -0,0 +1,97 @@
|
|||
.\" cf. groff_mdoc
|
||||
.Dd March 25, 2015
|
||||
.Os FreeTDS 1.1.24
|
||||
.Dt DATACOPY FreeTDS "FreeTDS Reference Manual"
|
||||
.\"
|
||||
.Sh NAME
|
||||
.Nm datacopy
|
||||
.Nd move table data between two servers
|
||||
.\"
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl vdE
|
||||
.Bro
|
||||
.Fl t
|
||||
|
|
||||
.Fl a
|
||||
|
|
||||
.Fl c
|
||||
.Ar owner
|
||||
.Brc
|
||||
.Op Fl b Ar batchsize
|
||||
.Op Fl p Ar packetsize
|
||||
.Op Fl S Ar server/username/password/database/table_or_view
|
||||
.Op Fl D Ar server/username/password/database/table
|
||||
.Op Fl T Ar textsize
|
||||
.\"
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is a utility distributed with FreeTDS.
|
||||
.Nm
|
||||
will move table data from one server to another without the need for
|
||||
intermediate files.
|
||||
.Nm
|
||||
is much faster and more efficient than is freebcp out/in.
|
||||
.Pp
|
||||
.Nm
|
||||
makes use of the db-lib bcp API built into FreeTDS. This API is also
|
||||
available to application developers.
|
||||
.Pp
|
||||
.Nm
|
||||
can be used to migrate data between Sybase ASE and SQL Server or vice
|
||||
versa.
|
||||
.\"
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width indent
|
||||
.It Fl t
|
||||
Truncate target table before loading data.
|
||||
.It Fl a
|
||||
Append data to target table.
|
||||
.It Fl c Ar owner
|
||||
Create the target table with the same schema as the source table.
|
||||
.Nm
|
||||
will submit a
|
||||
.Ql CREATE TABLE
|
||||
command on the target server using the specified owner in
|
||||
the command, e.g.
|
||||
.Ql CREATE TABLE owner.table (.\|.\|.\&).
|
||||
.It Fl b Ar batchsize
|
||||
The number of rows per batch of data copied. Each batch of data is
|
||||
effectively 'committed' to the database. The default is 1000.
|
||||
.It Fl p Ar packetsize
|
||||
The number of bytes, per network packet, sent to and from the
|
||||
servers. Increased packet size can enhance performance.
|
||||
.It Fl T Ar textsize
|
||||
Specify size of TEXT/IMAGE column from network.
|
||||
.It Fl v
|
||||
Produce verbose output, including diagnostic timings.
|
||||
.It Fl d
|
||||
Produce freetds TDSDUMP output. (Serious debug only!)
|
||||
.It Fl S Ar server/username/password/database/table_or_view
|
||||
The connection information for the source server
|
||||
and the location/name of the table (or view) to be copied.
|
||||
If not specified,
|
||||
.Nm
|
||||
prompts the user for the information.
|
||||
.It Fl D Ar server/username/password/database/table
|
||||
The connection information for the destination server and the
|
||||
location/name of the target table.
|
||||
If not specified,
|
||||
.Nm
|
||||
prompts the user for the information.
|
||||
.It Fl E
|
||||
Keep identity values.
|
||||
.Sh SEE ALSO
|
||||
.Xr freebcp 1 , Xr defncopy 1 , Xr bsqldb 1 , Xr tsql 1 ,
|
||||
.%B FreeTDS User Guide.
|
||||
.\"
|
||||
.Sh HISTORY
|
||||
.Pp
|
||||
.Nm
|
||||
first appeared in FreeTDS 0.64.
|
||||
.\"
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An Bill Thompson Aq thompbil@exchange.uk.ml.com .
|
|
@ -0,0 +1,110 @@
|
|||
.\" cf. groff_mdoc
|
||||
.Dd April 26, 2012
|
||||
.Os FreeTDS 1.1.24
|
||||
.Dt DEFNCOPY FreeTDS "FreeTDS Reference Manual"
|
||||
.\"
|
||||
.Sh NAME
|
||||
.Nm defncopy
|
||||
.Nd extract procedures and views from a Microsoft server.
|
||||
.\"
|
||||
.Sh SYNOPSIS
|
||||
.Pp
|
||||
.Nm
|
||||
.Op Fl v
|
||||
.Op Fl U Ar username
|
||||
.Op Fl P Ar password
|
||||
.Op Fl S Ar server
|
||||
.Op Fl D Ar database
|
||||
.Op Fl i Ar input_file
|
||||
.Op Fl o Ar output_file
|
||||
.Bo
|
||||
.Ar owner.object_name
|
||||
.\" Elipsis according to Werner Lemberg:
|
||||
.\" http://www.mail-archive.com/groff@gnu.org/msg03122.html
|
||||
.Op Ar owner.object_name .\|.\|.\&
|
||||
.Bc
|
||||
.\"
|
||||
.Sh DESCRIPTION
|
||||
.Pp
|
||||
.Nm
|
||||
is a utility program distributed with FreeTDS. It replaces
|
||||
a similar program of the same name distributed by Sybase.
|
||||
.Pp
|
||||
.Nm
|
||||
reads the text of a stored procedure or view, and writes a script
|
||||
suitable for recreating the procedure or view. For tables, it reads
|
||||
the output of sp_help and constructs a
|
||||
.Ql CREATE TABLE
|
||||
statement, complete
|
||||
with
|
||||
.Ql CREATE INDEX Ns ,
|
||||
too.
|
||||
.\"
|
||||
.Ar owner
|
||||
is optional if you or the database owner is the owner
|
||||
of the procedure/view being copied.
|
||||
.Ar object_name
|
||||
is the name of the system object you wish to extract.
|
||||
.\"
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width indent
|
||||
.It Fl U Ar username
|
||||
database server login name.
|
||||
.It Fl P Ar password
|
||||
database server password.
|
||||
.It Fl S Ar server
|
||||
database server to which to connect.
|
||||
.It Fl D Ar database
|
||||
database to use. Optional if the procedure/view being extracted is in your
|
||||
default database.
|
||||
.It Fl i Ar input_file
|
||||
a script to apply to the database. Not currently implemented.
|
||||
.It Fl o Ar output_file
|
||||
a file to hold the script, defaults to standard output.
|
||||
.It Fl v
|
||||
Show version information and copyright notice.
|
||||
.El
|
||||
.\"
|
||||
.Sh NOTES
|
||||
.Nm
|
||||
is a filter; it reads from standard input, writes to standard output,
|
||||
and writes errors to standard error. The
|
||||
.Fl i ,
|
||||
.Fl o ,
|
||||
and
|
||||
.Fl e
|
||||
options override these defaults.
|
||||
.Pp
|
||||
.Nm
|
||||
makes use of the db-lib API provided by FreeTDS. This
|
||||
API is of course also available to application developers.
|
||||
.Sh EXIT STATUS
|
||||
.Pp
|
||||
.Nm
|
||||
exits 0 on success, and >0 if the server cannot process the query.
|
||||
.Pp
|
||||
.Nm
|
||||
will report any errors returned by the server, but will continue
|
||||
processing.
|
||||
.\"
|
||||
.Sh HISTORY
|
||||
.Pp
|
||||
.Nm
|
||||
first appeared in FreeTDS 0.63.
|
||||
.\"
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An James K. Lowden Aq jklowden@schemamania.org.
|
||||
.\"
|
||||
.Sh BUGS
|
||||
Works only with Microsoft servers and ancient Sybase servers.
|
||||
Does not create primary keys.
|
||||
Many options are defined by Sybase that this version does not implement. Feel
|
||||
free to correct this situation.
|
||||
In theory,
|
||||
.Nm
|
||||
could apply/produce DDL for any system object,
|
||||
but at present only tables, procedures and views are supported,
|
||||
and only for extraction.
|
|
@ -0,0 +1,172 @@
|
|||
.\" cf. groff_mdoc
|
||||
.Dd March 25, 2015
|
||||
.Os FreeTDS 1.1.24
|
||||
.Dt FISQL FreeTDS "FreeTDS Reference Manual"
|
||||
.\"
|
||||
.Sh NAME
|
||||
.Nm fisql
|
||||
.Nd interactive SQL shell
|
||||
.\"
|
||||
.Sh SYNOPSIS
|
||||
.Pp
|
||||
.Nm
|
||||
.Op Fl eFgpnvXY
|
||||
.Op Fl a Ar display_charset
|
||||
.Op Fl A Ar packet_size
|
||||
.Op Fl c Ar cmdend
|
||||
.Op Fl D Ar database
|
||||
.Op Fl E Ar editor
|
||||
.Op Fl h Ar headers
|
||||
.Op Fl H Ar hostname
|
||||
.Op Fl i Ar inputfile
|
||||
.Op Fl I Ar interfaces_file
|
||||
.Op Fl J Ar client_charset
|
||||
.Op Fl l Ar login_timeout
|
||||
.Op Fl m Ar errorlevel
|
||||
.Op Fl o Ar outputfile
|
||||
.Op Fl P Ar password
|
||||
.Op Fl s Ar colseparator
|
||||
.Op Fl S Ar server
|
||||
.Op Fl t Ar timeout
|
||||
.Op Fl U Ar username
|
||||
.Op Fl w Ar width
|
||||
.Op Fl y Ar sybase_dir
|
||||
.Op Fl z Ar language
|
||||
.\"
|
||||
.Sh DESCRIPTION
|
||||
.Pp
|
||||
.Nm
|
||||
is very similar to the
|
||||
.Ql isql
|
||||
utility programs distributed by Sybase and Microsoft. Like them,
|
||||
.Nm
|
||||
uses the command
|
||||
.Ql go
|
||||
on a line by itself as a separator between batches.
|
||||
.\"
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width indent
|
||||
.It Fl a Ar display_charset
|
||||
The client charset name. Not implemented.
|
||||
.It Fl A Ar packet_size
|
||||
Set protocol packet size. You should not need to set this parameter.
|
||||
.It Fl c Ar cmdend
|
||||
Command terminator, defaults to
|
||||
.Ql go Ns .
|
||||
.It Fl D
|
||||
Database name on the server to use.
|
||||
.It Fl e
|
||||
Echo SQL input (usually in outputfile)
|
||||
.It Fl E Ar editor
|
||||
Specify
|
||||
an editor to invoke. Defaults to vi.
|
||||
.It Fl F
|
||||
FIPS mode ON. Server returns a message (but processes the query anyway)
|
||||
when it encounters a non-standard SQL command.
|
||||
.It Fl g
|
||||
Display a brief help message
|
||||
.It Fl h Ar headers
|
||||
Number
|
||||
of rows after which to repeat the column headers. Default is once per resultset.
|
||||
.It Fl H Ar hostname
|
||||
Hostname
|
||||
of the client machine as it will be told to the server.
|
||||
.It Fl I Ar interfaces_file
|
||||
Name
|
||||
of the interfaces or freetds.conf file to use.
|
||||
.It Fl i Ar inputfile
|
||||
Name
|
||||
of script file, containing SQL.
|
||||
.It Fl J Ar client_charset
|
||||
Not
|
||||
implemented.
|
||||
.It Fl l Ar login_timeout
|
||||
How
|
||||
long to wait for the server to acknowledge a login attempt.
|
||||
.It Fl m Ar errorlevel
|
||||
For
|
||||
errors of the severity level specified or higher,
|
||||
print only the message number, state, and error level.
|
||||
Below that level, print nothing.
|
||||
.It Fl n
|
||||
Suppress line numbers in echoed output.
|
||||
.It Fl o Ar outputfile
|
||||
Name
|
||||
of output file, holding result data.
|
||||
.It Fl p
|
||||
Prints performance statistics. Not implemented.
|
||||
.It Fl P Ar password
|
||||
Database
|
||||
server password.
|
||||
.It Fl s Ar colseparator
|
||||
The
|
||||
column separator. Default is space. Shell metacharacters require quoting.
|
||||
.It Fl S Ar server
|
||||
Database
|
||||
server to which to connect.
|
||||
.It Fl t Ar timeout
|
||||
The
|
||||
query timeout, in seconds. How long to wait for a query to be processed.
|
||||
The default is indefinitely, or as determined by freetds.conf.
|
||||
.It Fl U Ar username
|
||||
Database
|
||||
server login name.
|
||||
.It Fl v
|
||||
Display version and copyright.
|
||||
.It Fl w Ar width
|
||||
How
|
||||
many characters wide to print the output. Defaults to 80.
|
||||
.It Fl X
|
||||
Use encrypted login. Not implemented in FreeTDS.
|
||||
.It Fl y Pa sybase_dir
|
||||
Sets
|
||||
the
|
||||
.Ev SYBASE
|
||||
environment variable. Not used by FreeTDS.
|
||||
.It Fl Y
|
||||
Use chained transactions.
|
||||
.It Fl z Ar language
|
||||
Name
|
||||
of a language for fisql's prompts and messages.
|
||||
Cf. DBSETLNATLANG.
|
||||
.El
|
||||
.\"
|
||||
.Sh NOTES
|
||||
.Nm
|
||||
is a filter; it reads from standard input, writes to standard output,
|
||||
and writes errors to standard error. The
|
||||
.Fl i Ns ,
|
||||
.FL o Ns ,
|
||||
and
|
||||
.Fl e
|
||||
options override these defaults.
|
||||
.Pp
|
||||
.Nm
|
||||
uses the DB-Library API provided by FreeTDS. It was first implemented using
|
||||
Sybase's own library and continues to work with it. Before (and after) modifying
|
||||
it, it would be well to test it with Sybase's library to assure compatibility
|
||||
between it and FreeTDS.
|
||||
EXIT STATUS
|
||||
.Pp
|
||||
.Nm
|
||||
exits 0 on success, and >0 if the server cannot process the query.
|
||||
.Pp
|
||||
.Nm
|
||||
will report any errors returned by the server, but will continue
|
||||
processing. In a production environment, this behavior may be insufficiently
|
||||
stringent. To make it extremely intolerant of errors, change the message and
|
||||
error handlers to call exit(3).
|
||||
.\"
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
first appeared in FreeTDS 0.65.
|
||||
.\"
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An Nicholas S. Castellano Aq entropy@freetds.org Ns ,
|
||||
who contributed it to the FreeTDS project under the terms of the GPL.
|
||||
.\"
|
||||
.Sh BUGS
|
||||
Requires the GNU readline library.
|
|
@ -0,0 +1,227 @@
|
|||
.\" cf. groff_mdoc
|
||||
.Dd March 25, 2015
|
||||
.Os FreeTDS 1.1.24
|
||||
.Dt FREEBCP 1
|
||||
.Sh NAME
|
||||
.Nm freebcp
|
||||
.Nd bulk loading utility for Sybase and Microsoft databases
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Bo Bo Ao Ar database Ac Ns . Bc Ns Ao Ar owner Ac Ns . Bc Ns Aq Ar object_name
|
||||
.Bro
|
||||
.Ar in
|
||||
|
|
||||
.Ar [query] Ns Ar out
|
||||
.Brc
|
||||
.Ar datafile
|
||||
.Bro
|
||||
.Fl c
|
||||
|
|
||||
.Fl n
|
||||
|
|
||||
.Fl f Ar formatfile
|
||||
.Brc
|
||||
.Op Fl S Ar servername
|
||||
.Op Fl D Ar dbname
|
||||
.Op Fl U Ar username
|
||||
.Op Fl P Ar password
|
||||
.Op Fl b Ar batchsize
|
||||
.Op Fl F Ar firstrow
|
||||
.Op Fl L Ar lastrow
|
||||
.Op Fl e Ar errfile
|
||||
.Op Fl I Ar interfaces
|
||||
.Op Fl m Ar maxerror
|
||||
.Op Fl t Ar field_term
|
||||
.Op Fl r Ar row_term
|
||||
.Op Fl h Ar hints
|
||||
.Op Fl T Ar textsize
|
||||
.Op Fl A Ar packet_size
|
||||
.Op Fl O Ar options
|
||||
.Op Fl i Ar inputfile
|
||||
.Op Fl o Ar outputfile
|
||||
.Op Fl C Ar charset
|
||||
.Op Fl EdVv
|
||||
.\"
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is a utility program distributed with FreeTDS.
|
||||
.Nm
|
||||
replicates (in part at least) the functionality
|
||||
of the bcp utility programs distributed by Sybase and Microsoft.
|
||||
.Nm
|
||||
makes use of the DB-Library bcp API provided by FreeTDS. This
|
||||
API is also available to application developers.
|
||||
.Pp
|
||||
The manual pages or online help for Sybase or SQL Server can be
|
||||
referenced for more detailed information on bcp functionality.
|
||||
.\"
|
||||
.Sh TABLES\ AND\ FILES
|
||||
.Bl -tag -width indent
|
||||
.It Ar database
|
||||
The name of the database containing object to be copied. Optional if
|
||||
the table/view is in the default database for
|
||||
.Ar username .
|
||||
.It Ar schema
|
||||
The schema of the object being copied. If not provided, the default schema
|
||||
for
|
||||
.Ar username
|
||||
is used.
|
||||
.It Ar object
|
||||
The name of the database object you wish to access, typically a
|
||||
table. It can also be a view. All views can be read; some can be
|
||||
written, subject to constraints. With
|
||||
.Ar queryout Ns , Ar object
|
||||
can also be an SQL query.
|
||||
.It Ar in
|
||||
Copy data from a host file to a database table.
|
||||
.It Ar out
|
||||
Copy data from a database table to a host file.
|
||||
.It Ar queryout
|
||||
indicates that
|
||||
.Ar table_name
|
||||
is in fact SQL, rather than a database object.
|
||||
.Nm
|
||||
will execute the query and write the results to a file. (It is a good
|
||||
idea to have the query return one and only one result set.)
|
||||
.It Ar datafile
|
||||
The name of an operating system file.
|
||||
.El
|
||||
.\"
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width indent
|
||||
.It Fl A Ar packet_size
|
||||
Set the size of a TDS packet to packet_size. Not sure why you would
|
||||
want to do this, except as an experiment.
|
||||
.It Fl D Ar dbname
|
||||
The name of the default database to use. Overrides default database associated with the login account. Causes
|
||||
.Nm
|
||||
to issue a
|
||||
.Ic USE Ar dbname
|
||||
command immediately after logging in, before commencing BCP operations.
|
||||
.It Fl E
|
||||
Write the data in datafile to the table's IDENTITY column. Without
|
||||
this flag, the identity data present in the datafile will be ignored,
|
||||
and new IDENTITY values will be generated for the imported rows.
|
||||
.It Fl F Ar firstrow
|
||||
The first row to copy from the input file or database table. The
|
||||
default is the first row, row 1.
|
||||
.It Fl I Ar interfaces
|
||||
The name and location of the
|
||||
.Pa interfaces
|
||||
file to search when connecting to servername. Overrides
|
||||
.Pa freetds.conf.
|
||||
.It Fl L Ar lastrow
|
||||
The last row to copy from an input file or
|
||||
database table. The default is the last row.
|
||||
.It Fl O Ar options
|
||||
SQL text to set connection options prior to the bcp operation. If
|
||||
.Ar options
|
||||
is a valid filename, the SQL is read from the file
|
||||
instead. Sometimes needed for
|
||||
.Ar queryout .
|
||||
Example:
|
||||
.Li -O `SET QUOTED_IDENTIFIER ON' Ns .
|
||||
.It Fl P Ar password
|
||||
The password associated with
|
||||
.Ar username .
|
||||
.It Fl S Ar servername
|
||||
The name of the Database Server to which to connect.
|
||||
.It Fl T Ar textsize
|
||||
For text or image columns, set the maximum number of characters to
|
||||
request from the server. Defaults to the setting in
|
||||
.Pa freetds.conf .
|
||||
If
|
||||
not specified anywhere, defaults to the full size of the data.
|
||||
.It Fl U Ar username
|
||||
A database login name. For TDS\ 7+ connections, a domain login is attempted
|
||||
if
|
||||
.Ar username
|
||||
is not provided.
|
||||
.It Fl b Ar batchsize
|
||||
The number of rows per batch of data copied. Batching applies only
|
||||
when you are bulk copying into the database. Each batch of data is
|
||||
effectively
|
||||
.Dq committed
|
||||
into the database. The default value for
|
||||
.Ar batchsize
|
||||
is 1000.
|
||||
.It Fl c
|
||||
The host data file is (or will be) in "character" format, i.e., a text
|
||||
file. Encoding is determined by the client charset attribute in
|
||||
.Pa freetds.conf .
|
||||
.It Fl d
|
||||
Turn off any logging. (Unintuitive, perhaps.)
|
||||
.It Fl e Ar errfile
|
||||
Write errors to
|
||||
.Ar errfile .
|
||||
For uploads. Includes line and column
|
||||
information, and the row data.
|
||||
.It Fl f Ar formatfile
|
||||
The format of the host data file is described by
|
||||
.Ar formatfile .
|
||||
The layout of
|
||||
.Ar formatfile
|
||||
is identical to that understood by the Sybase and
|
||||
Microsoft bcp utilities, but is too complicated to describe here.
|
||||
.It Fl h Ar hints
|
||||
Set bcp hints. For valid values, cf.
|
||||
.Fn bcp_options
|
||||
in the FreeTDS Reference Manual.
|
||||
.It Fl m Ar maxerror
|
||||
Stop after encountering
|
||||
.Ar maxerror
|
||||
errors. Default 10.
|
||||
.It Fl n
|
||||
The host data file is in
|
||||
.Dq native
|
||||
format. This is a format that
|
||||
.Nm
|
||||
will be able to process, but is not portable or readable.
|
||||
.It Fl r Ar row_term
|
||||
The row terminator for a character file. May be more than one
|
||||
character. Default is newline ('\\n'). Cf\&.
|
||||
.Fl c Ns ,
|
||||
above.
|
||||
.It Fl t Ar field_term
|
||||
The field terminator for character file. Also known as a column
|
||||
delimiter. May be more than one character. Default is tab
|
||||
('\\t'). Cf\&.
|
||||
.Fl c Ns
|
||||
, above.
|
||||
.It Fl v
|
||||
.It Fl V
|
||||
Print the version information and exit.
|
||||
.It Fl i Ar inputfile
|
||||
Read input data from file specified.
|
||||
.It Fl o Ar outputfile
|
||||
Write output data to file specified.
|
||||
.It Fl C Ar charset
|
||||
Specify character set to use to talk to server.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
.Ev DSQUERY
|
||||
default
|
||||
.Ar servername
|
||||
.\"
|
||||
.Sh NOTES
|
||||
When connecting to a Sybase database server, it is required that the
|
||||
TDS 5.0 protocol be used. When connecting to a Microsoft SQL Server
|
||||
2000 database server, the TDS\ 7 (or later) protocol is required.
|
||||
.Pp
|
||||
Sybase and Microsoft define different versions of the bcp portion of TDS 4.2.
|
||||
Because FreeTDS has no way of knowing which type of server it's connected to,
|
||||
.Nm
|
||||
does not support version 4.2 of the TDS protocol.
|
||||
.\"
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
first appeared in FreeTDS 0.60
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An Bill Thompson Aq thompbil@exchange.uk.ml.com
|
||||
.Sh BUGS
|
||||
Currently, there is no support for text data types in
|
||||
.Nm Ns , when
|
||||
SQL Server 2000 is the target server.
|
|
@ -0,0 +1,103 @@
|
|||
.\" cf. groff_mdoc
|
||||
.Dd April 26, 2012
|
||||
.Os FreeTDS 1.1.24
|
||||
.Dt OSQL FreeTDS "FreeTDS Reference Manual"
|
||||
.\"
|
||||
.Sh NAME
|
||||
.Nm osql
|
||||
.Nd utility to test FreeTDS connections and queries
|
||||
.\"
|
||||
.Sh SYNOPSIS
|
||||
.Pp
|
||||
.Nm
|
||||
.Fl S Ar dsn
|
||||
.Fl U Ar username
|
||||
.Fl P Ar password
|
||||
.Op Fl I Pa ini_directory
|
||||
.\"
|
||||
.Sh DESCRIPTION
|
||||
.Pp
|
||||
.Nm
|
||||
is a diagnostic tool provided as part of FreeTDS. It is a
|
||||
Bourne shell script that checks and reports on your configuration
|
||||
files. If everything checks out OK, it invokes isql.
|
||||
.Pp
|
||||
.Nm
|
||||
works only with the isql that comes with unixODBC.
|
||||
.\"
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width indent
|
||||
.It Fl S Ar dsn
|
||||
the Data Source Name to which to connect, as known to
|
||||
.Pa odbc.ini Ns .
|
||||
.It Fl U Ar username
|
||||
database
|
||||
login name.
|
||||
.It Fl P Ar password
|
||||
database password.
|
||||
.It Fl I Ar ini_dir
|
||||
override
|
||||
.Pa odbc.ini
|
||||
file location.
|
||||
.El
|
||||
.\"
|
||||
.Sh EXAMPLE
|
||||
If you have an
|
||||
.Pa odbc.ini
|
||||
with a section like this:
|
||||
.Bd -literal -offset indent
|
||||
.Bq myDSN
|
||||
servername = myserver
|
||||
TDS_Version = 5.0
|
||||
.Ed
|
||||
.Pp
|
||||
You would invoke
|
||||
.Nm
|
||||
as:
|
||||
.Pp
|
||||
.Li osql -S myDSN
|
||||
.Op .\|.\|.\&
|
||||
.\"
|
||||
.Sh FILES
|
||||
.Pa odbc.ini
|
||||
.Pa freetds.conf
|
||||
.\"
|
||||
.Sh NOTES
|
||||
If you can connect with
|
||||
.Ql osql -S servername -U user -P passwd Ns ,
|
||||
your FreeTDS ODBC installation is working.
|
||||
.Pp
|
||||
.Nm
|
||||
guesses where unixODBC might look for its
|
||||
.Pa odbc.ini
|
||||
by examining the binary. This is not always an effective approach. If
|
||||
it doesn't work, you'll receive a report of candidate strings. Kindly
|
||||
pass along the output to help improve the guessing.
|
||||
.Pp
|
||||
If
|
||||
.Nm
|
||||
cannot intuit your
|
||||
.Pa odbc.ini
|
||||
directory, you can force the issue with
|
||||
the
|
||||
.Fl I
|
||||
option. However, you're then instructing
|
||||
.Nm
|
||||
what to test, not where unixODBC will eventually look. Your override
|
||||
is therefore only as good as you are. Look carefully at the error
|
||||
output before overriding.
|
||||
.Pp
|
||||
If you have suggestions for ways to make
|
||||
.Nm
|
||||
more useful as a diagnostic tool, please post them to the FreeTDS
|
||||
mailing list.
|
||||
.\"
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
first appeared in FreeTDS 0.65.
|
||||
.\"
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An James K. Lowden Ns .
|
|
@ -0,0 +1,160 @@
|
|||
.\" cf. groff_mdoc
|
||||
.Dd March 25, 2015
|
||||
.Os FreeTDS 1.1.24
|
||||
.Dt TSQL FreeTDS "FreeTDS Reference Manual"
|
||||
.Sh NAME
|
||||
.Nm tsql
|
||||
.Nd utility to test FreeTDS connections and queries
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Bro
|
||||
.Fl S Ar servername
|
||||
.Op Fl I Ar interface
|
||||
|
|
||||
.Fl H Ar hostname
|
||||
.Op Fl L
|
||||
.Op Fl p Ar port
|
||||
.Brc
|
||||
.Op Fl D Ar dbname
|
||||
.Op Fl U Ar username
|
||||
.Op Fl P Ar password
|
||||
.Op Fl o Ar options
|
||||
.Nm
|
||||
.Fl C
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is a FreeTDS diagnostic tool. It uses the TDS protocol to connect to a
|
||||
Sybase or Microsoft SQL Server, and lets the user issue queries.
|
||||
.Nm
|
||||
does
|
||||
not use the FreeTDS client libraries. Instead, it uses only the lowest level
|
||||
library, libtds, to test the protocol implementation.
|
||||
.Pp
|
||||
.Nm
|
||||
can be run in two ways, one which uses the freetds.conf and one which
|
||||
connects directly using the server's hostname and port.
|
||||
The
|
||||
.Fl H
|
||||
and
|
||||
.Fl p
|
||||
parameters are provided to let the user verify a server is listening on
|
||||
the named host and port. These parameters override any configuration files
|
||||
and environment variables.
|
||||
.Pl
|
||||
The
|
||||
.Fl S
|
||||
parameter can be used to test the local configuration. FreeTDS will use
|
||||
freetds.conf (or equivalent) and environment variables in the normal way to
|
||||
determine the server's IP address and port. You can use
|
||||
.Fl I
|
||||
to specify a filename, overriding FreeTDS's configuration file search
|
||||
algorithm.
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width indent
|
||||
.It Fl S Ar servername
|
||||
database server to which to connect.
|
||||
.It Fl D Ar dbname
|
||||
database to use.
|
||||
.It Fl I Ar interface
|
||||
freetds.conf or interfaces file describing servername.
|
||||
.It Fl H Ar hostname
|
||||
DNS hostname of the server.
|
||||
.It Fl p Ar port
|
||||
port at which SQL Server is listening.
|
||||
.It Fl U Ar username
|
||||
database login name. If username is not provided, a domain
|
||||
login is attempted for TDS 7+ connections.
|
||||
.It Fl P Ar password
|
||||
database password.
|
||||
.It Fl L
|
||||
list Microsoft server instances (with
|
||||
.Fl H Ns ).
|
||||
.It Fl C
|
||||
print some of the compile-time configuration parameters.
|
||||
.It Fl o Ar options
|
||||
apply the options specified to every command.
|
||||
.Bl -tag -width indent
|
||||
.It Fl f
|
||||
No footer
|
||||
.Bq result count
|
||||
.It Fl h
|
||||
No header
|
||||
.Bq titles
|
||||
.It Fl t
|
||||
Print time
|
||||
.It Fl v
|
||||
Print version
|
||||
.It Fl q
|
||||
Quiet
|
||||
.El
|
||||
.It Fl a Ar appname
|
||||
application name.
|
||||
.It Fl t Ar colterm
|
||||
column terminator.
|
||||
.It Fl r Ar rowterm
|
||||
row terminator.
|
||||
.It Fl r Ar rowterm
|
||||
row terminator.
|
||||
.It Fl J Ar charset
|
||||
character set.
|
||||
.It Fl v
|
||||
verbose mode.
|
||||
.El
|
||||
.\"
|
||||
.Sh NOTES
|
||||
If you can connect with
|
||||
.Ql tsql -S servername Ns ,
|
||||
your basic FreeTDS installation is working.
|
||||
.Pp
|
||||
Typing
|
||||
.Ql exit Ns ,
|
||||
.Ql quit Ns ,
|
||||
or
|
||||
.Ql bye
|
||||
(or
|
||||
.Li ^D Ns )
|
||||
exits
|
||||
.Nm Ns .
|
||||
.Pp
|
||||
Typing
|
||||
.Ql version
|
||||
displays the TDS protocol version.
|
||||
.Pp
|
||||
Command batches may be separated with
|
||||
.Ql go
|
||||
or
|
||||
.Ql GO Ns .
|
||||
If
|
||||
.Ql GO
|
||||
the version string is reported before executing the batch.
|
||||
.Pp
|
||||
After prompting for the password (if not provided with
|
||||
.Fl P Ns ),
|
||||
.Nm
|
||||
will attempt to connect to the remote server.
|
||||
.Nm
|
||||
displays a counter indicating the number
|
||||
of seconds elapsed during the connection attempt. Typically,
|
||||
.Nm
|
||||
immediately responds with a
|
||||
.Ql 1>
|
||||
prompt. If you see the counter (1, 2, 3, ...), most likely
|
||||
.Nm
|
||||
is unable to connect to the indicated server.
|
||||
.Pp
|
||||
.Nm
|
||||
is not a replacement for a complete isql such as sqsh (www.sqsh.org).
|
||||
If you have suggestions for ways to make
|
||||
.Nm
|
||||
more useful as a diagnostic tool, please post them to the FreeTDS
|
||||
mailing list for consideration.
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
first appeared in FreeTDS 0.60.
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
utility was written by
|
||||
.An Brian Bruns Ns .
|
||||
.Sh BUGS
|
||||
Several, to be sure, now that it's documented. :)
|
|
@ -0,0 +1,290 @@
|
|||
.Dd May 2, 2017
|
||||
.Os FreeTDS 1.1.24
|
||||
.Dt FREETDS.CONF "FreeTDS 5" "FreeTDS Reference Manual"
|
||||
.
|
||||
.Sh NAME
|
||||
.Nm freetds.conf
|
||||
.Nd configuration file for FreeTDS
|
||||
.
|
||||
.Sh SYNOPSIS
|
||||
The
|
||||
.Pa freetds.conf
|
||||
file describes Sybase and Microsoft database servers to the FreeTDS
|
||||
library. It comprises sections headed by a servername, followed by a
|
||||
list of connection properties denoted as name-value pairs. Defaults
|
||||
are defined via a
|
||||
.Bq global
|
||||
section. This file supersedes the
|
||||
.Pa interfaces
|
||||
file that
|
||||
Sybase defines for the same purpose, although the latter is still supported.
|
||||
.
|
||||
.Sh DESCRIPTION
|
||||
A section begins with a servername \(em the name of the server \(em in
|
||||
square brackets. The servername is chosen at the client's descretion.
|
||||
(One exception: with Sybase ASA the servername must match the database
|
||||
name to be used.)
|
||||
.Pp
|
||||
Sections contain properties, one per line, in the form
|
||||
.Pp
|
||||
.Dl name = value
|
||||
.Pp
|
||||
where
|
||||
.Ar name
|
||||
is the connection property to be described. Servernames and properties
|
||||
are not case sensitive. Values are case-preserving i.e., copied literally.
|
||||
Comments begin with either a semicolon
|
||||
.Pq So ; Sc
|
||||
or pound sign
|
||||
.Pq So # Sc
|
||||
and continue to end of line. Blank lines are ignored. Whitespace surrounding the
|
||||
.So = Sc is ignored.
|
||||
.
|
||||
.Sh PROPERTIES
|
||||
.Bl -tag -width "emulate little endian" -compact
|
||||
.
|
||||
.It client charset
|
||||
encoding of client data; overrides locale(1) settings
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
iconv character set names
|
||||
.It Default:
|
||||
ISO-8859-1
|
||||
.El
|
||||
.
|
||||
.It connect timeout
|
||||
seconds to wait for response from connect request
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
0 to MAX_INT
|
||||
.It Default:
|
||||
none
|
||||
.El
|
||||
.
|
||||
.It debug flags
|
||||
logging granularity
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
32-bit integer
|
||||
.It Default:
|
||||
0x4fff
|
||||
.El
|
||||
.
|
||||
.It dump file
|
||||
specifies location of a logfile and turns on logging
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
valid file name
|
||||
.It Default:
|
||||
none
|
||||
.El
|
||||
.
|
||||
.It dump file append
|
||||
log data appended to file instead of re-writing for each connection
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
yes/no
|
||||
.It Default:
|
||||
no
|
||||
.El
|
||||
.
|
||||
.It emulate little endian
|
||||
forces big endian machines to act as little endian to communicate with
|
||||
Microsoft Servers
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
yes/no
|
||||
.It Default:
|
||||
no
|
||||
.El
|
||||
.
|
||||
.It encryption
|
||||
.Bl -tag -compact
|
||||
.It Em off
|
||||
disables encryption
|
||||
.It Em request
|
||||
use if available (default when tds version greater than 7.0)
|
||||
.It Em required
|
||||
allow encrypted connections only
|
||||
.El
|
||||
.
|
||||
.It host
|
||||
Name of the host the server is running on.
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
host name or IP address
|
||||
.It Default:
|
||||
SYBASE
|
||||
.El
|
||||
.
|
||||
.It initial block size
|
||||
maximum size of a protocol block
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
multiple of 512
|
||||
.It Default:
|
||||
512
|
||||
.El
|
||||
.
|
||||
.It instance
|
||||
name of Microsoft SQL Server instance to connect to (supersedes
|
||||
.Em port )
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
instance name
|
||||
.It Default:
|
||||
none
|
||||
.El
|
||||
.
|
||||
.It port
|
||||
port number that the server is listening to
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
any valid port
|
||||
.It Default:
|
||||
TDS 5.0, 5000; TDS 7.0 and up, 1433
|
||||
.El
|
||||
.
|
||||
.It tds version
|
||||
TDS protocol version to use
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
4.2, 5.0, 7.0, 7.1, 7.2
|
||||
.It Default:
|
||||
.Fl -with-tdsver
|
||||
value (5.0 if unspecified)
|
||||
.El
|
||||
.
|
||||
.It text size
|
||||
default value of TEXTSIZE, in bytes
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
0 to 4,294,967,295
|
||||
.It Default:
|
||||
4,294,967,295
|
||||
.El
|
||||
.
|
||||
.It timeout
|
||||
seconds to wait for response to a query
|
||||
.Bl -tag -width "default:" -compact
|
||||
.It Domain:
|
||||
0 to MAX_INT
|
||||
.It Default:
|
||||
none (wait forever)
|
||||
.El
|
||||
.
|
||||
.El
|
||||
.Pp
|
||||
Do not define both
|
||||
.Fa port
|
||||
and
|
||||
.Fa instance Ns
|
||||
\&. One implies the other.
|
||||
|
||||
|
||||
.Pp
|
||||
Boolean property values may be denoted as on/off, true/false, or 1/0.
|
||||
.
|
||||
.Ss DEBUG FLAGS
|
||||
The log's granularity can be controlled with the
|
||||
.Em debug flags
|
||||
property.
|
||||
.Bl -column -offset indent ".Sy 0x8000" ".Sy show source level info (source file and line)"
|
||||
.It Sy Value Ta Sy Meaning
|
||||
.It Li \ \ 0x02 severe error
|
||||
.It Li \ \ 0x04 error
|
||||
.It Li \ \ 0x08 warning
|
||||
.It Li \ \ 0x10 network
|
||||
.It Li \ \ 0x20 information level 1
|
||||
.It Li \ \ 0x40 information level 2
|
||||
.It Li \ \ 0x80 function trace and info
|
||||
.It Li 0x1000 show pid
|
||||
.It Li 0x2000 show time
|
||||
.It Li 0x4000 show source level info (source file and line)
|
||||
.It Li 0x8000 thread id (not implemented).
|
||||
.El
|
||||
.
|
||||
.Sh NAMES AND LOCATIONS
|
||||
The file is normally named
|
||||
.Pa /etc/freetds.conf
|
||||
or
|
||||
.Pa ${HOME}/.freetds.conf .
|
||||
That name can be overridden with the FREETDSCONF environment variable.
|
||||
.Pp
|
||||
FreeTDS will search conf files for a servername in the following order:
|
||||
.Bl -enum -offset indent -compact
|
||||
.It
|
||||
a filename set programatically via dbsetifile() that is in .conf format
|
||||
.It
|
||||
a filename in the environment variable FREETDSCONF that is in .conf format
|
||||
.It
|
||||
.Pa ${HOME}/.freetds.conf
|
||||
if extant
|
||||
.It
|
||||
.Pa ${prefix}/etc/freetds.conf
|
||||
.El
|
||||
.Pp
|
||||
The search stops with the first file containing the servername.
|
||||
.Pp
|
||||
If no conf file is found, FreeTDS searches for
|
||||
an
|
||||
.Pa interfaces
|
||||
file in the following order:
|
||||
.Bl -enum -offset indent -compact
|
||||
.It
|
||||
a filename set programatically via dbsetifile() that is in
|
||||
.Pa interfaces
|
||||
format
|
||||
.It
|
||||
.Pa ${HOME}/.interfaces
|
||||
.It
|
||||
.Pa $SYBASE/interfaces
|
||||
(where
|
||||
.Ev $SYBASE is an environment variable)
|
||||
.El
|
||||
.Pp
|
||||
If the requested servername is not found in any configuration file, the fallback
|
||||
mechanism is:
|
||||
.Bl -enum -offset indent -compact
|
||||
.It
|
||||
attempt to convert the name to an IP address with inet_addr(3), else
|
||||
.It
|
||||
attempt to convert the name to an IP address with gethostbyname(3), else
|
||||
.It
|
||||
attempt to look up the literal name
|
||||
.Dq SYBASE
|
||||
.El
|
||||
.
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width "TDSDUMPCONFIG" -compact
|
||||
.It Ev FREETDSCONF
|
||||
overrides name and location of the system-wide conf file
|
||||
.It Ev TDSDUMP
|
||||
overrides the name and location of the FreeTDS log file
|
||||
.It Ev TDSDUMPCONFIG
|
||||
specifies a name and location of a file that logs the search of
|
||||
configuration files
|
||||
.It Ev TDSHOST
|
||||
overrides the host property
|
||||
.It Ev TDSPORT
|
||||
overrides the port property
|
||||
.It Ev TDSQUERY
|
||||
synonym for DSQUERY, the default servername
|
||||
.It Ev TDSVER
|
||||
overrides the version specified in the freetds.conf
|
||||
.El
|
||||
.Pp
|
||||
The environment variables
|
||||
.Ev TDSVER, Ev TDSDUMP, Ev TDSPORT, Ev TDSQUERY, and Ev TDSHOST
|
||||
override values set by a .conf or
|
||||
.Pa interfaces
|
||||
file.
|
||||
.
|
||||
.Sh FILES
|
||||
.Pa ${prefix}/etc/freetds.conf , ${HOME}/.freetds.conf
|
||||
.
|
||||
.Sh SEE ALSO
|
||||
.%B FreeTDS User Guide
|
||||
.
|
||||
.Sh HISTORY
|
||||
\.conf files first appeared with version 0.53 of FreeTDS.
|
|
@ -0,0 +1,5 @@
|
|||
require "sync_nccu_personal_data/engine"
|
||||
|
||||
module SyncNccuPersonalData
|
||||
# Your code goes here...
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
module SyncNccuPersonalData
|
||||
class Engine < ::Rails::Engine
|
||||
end
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
module SyncNccuPersonalData
|
||||
VERSION = '0.1.1'
|
||||
end
|
|
@ -0,0 +1,755 @@
|
|||
require "uri"
|
||||
require "net/http"
|
||||
module NccuSyncPlugin
|
||||
def self.init
|
||||
@client = TinyTds::Client.new username: 'nccurss', password: 'R33rssn@@up@ss', host: '140.119.221.30'
|
||||
@client.execute("USE [RUMISDB]").to_a
|
||||
@default_order_fields = {}
|
||||
@default_order = 'ASC' # 原本同步庫是 'DESC'
|
||||
self.get_country_mapping
|
||||
self.get_degree_mapping
|
||||
self.get_dept_mapping
|
||||
self.get_dept_mapping_for_experience
|
||||
self.get_school_mapping
|
||||
self.get_position_mapping
|
||||
self.get_sta_num_to_nccu_id_mapping
|
||||
@debug_mode = false # true will print rss_id if it is new record
|
||||
@test_mode = false
|
||||
end
|
||||
def self.close
|
||||
@client.close
|
||||
end
|
||||
def self.sync_journal_papers(staff_id,mp)
|
||||
data = self.get_journal_papers(staff_id)
|
||||
puts "Starting Jounral Paper for staff #{staff_id}."
|
||||
if !data.nil?
|
||||
journals = data
|
||||
total = journals.count rescue 0
|
||||
return if total == 0
|
||||
JournalPaper.where(:rss2_id.nin => ([nil,''] + journals.map{|journal| journal["rss_id"]}),member_profile_id: mp.id).destroy
|
||||
journals.each_with_index do |journal,index|
|
||||
if !journal.blank?
|
||||
jp = JournalPaper.where(:rss2_id => journal["rss_id"]).first rescue nil
|
||||
if jp.nil?
|
||||
jp = JournalPaper.new(rss2_id: journal["rss_id"])
|
||||
puts "Syncing new : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
puts "rss2_id: #{journal["rss_id"]}" if @debug_mode
|
||||
else
|
||||
puts "Updating old : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
end
|
||||
jp.vol_no = journal["number"]
|
||||
jp.publication_date = "#{journal["publication_year"]}/#{journal["publication_month"]}/01"
|
||||
jp.year = "#{journal["publication_year"]}"
|
||||
jp.url = journal["url"]
|
||||
jp.paper_title_translations = journal["title"]
|
||||
jp.member_profile = mp
|
||||
jp.save
|
||||
sleep 0.5
|
||||
end
|
||||
end
|
||||
end
|
||||
puts "Jounral Paper for staff #{staff_id} completed."
|
||||
end
|
||||
|
||||
def self.sync_conference_papers(staff_id,mp)
|
||||
data = self.get_conference_papers(staff_id)
|
||||
puts "Starting Conference Paper for staff #{staff_id}."
|
||||
if !data.nil?
|
||||
conferences = data
|
||||
total = conferences.count rescue 0
|
||||
return if total == 0
|
||||
WritingConference.where(:rss2_id.nin => ([nil,''] + conferences.map{|conference| conference["rss_id"]}),member_profile_id: mp.id).destroy
|
||||
conferences.each_with_index do |conference,index|
|
||||
if !conference.blank?
|
||||
wc = WritingConference.where(:rss2_id => conference["rss_id"]).first rescue nil
|
||||
if wc.nil?
|
||||
wc = WritingConference.new(rss2_id: conference["rss_id"])
|
||||
puts "Syncing new : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
puts "rss2_id: #{conference["rss_id"]}" if @debug_mode
|
||||
else
|
||||
puts "Updating old : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
end
|
||||
wc.isi_number = conference["number"]
|
||||
wc.publication_date = "#{conference["publication_year"]}/#{conference["publication_month"]}/01"
|
||||
wc.year = "#{conference["publication_year"]}"
|
||||
wc.url = conference["url"]
|
||||
wc.paper_title_translations = conference["title"]
|
||||
wc.member_profile = mp
|
||||
wc.save
|
||||
sleep 0.5
|
||||
end
|
||||
end
|
||||
end
|
||||
puts "Conference Paper for staff #{staff_id} completed."
|
||||
end
|
||||
|
||||
def self.sync_research_papers(staff_id,mp)
|
||||
data = self.get_research_papers(staff_id)
|
||||
puts "Starting Research Paper for staff #{staff_id}."
|
||||
if !data.nil?
|
||||
researches = data
|
||||
total = researches.count rescue 0
|
||||
return if total == 0
|
||||
Research.where(:rss2_id.nin => ([nil,''] + researches.map{|research| research["rss_id"]}),member_profile_id: mp.id).destroy
|
||||
researches.each_with_index do |research,index|
|
||||
if !research.blank?
|
||||
res = Research.where(:rss2_id => research["rss_id"]).first rescue nil
|
||||
if res.nil?
|
||||
res = Research.new(rss2_id: research["rss_id"])
|
||||
puts "Syncing new : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
puts "rss2_id: #{research["rss_id"]}" if @debug_mode
|
||||
else
|
||||
puts "Updating old : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
end
|
||||
res.publish_date = "#{research["publication_year"]}/#{research["publication_month"]}/01"
|
||||
res.url = research["url"]
|
||||
res.year = research["publication_year"]
|
||||
res.research_title_translations = research["title"]
|
||||
res.member_profile = mp
|
||||
res.save
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
end
|
||||
puts "Research Paper for staff #{staff_id} completed."
|
||||
end
|
||||
|
||||
def self.sync_books(staff_id,mp)
|
||||
data = self.get_books(staff_id)
|
||||
puts "Starting Books for staff #{staff_id}."
|
||||
if !data.nil?
|
||||
books = data
|
||||
total = books.count rescue 0
|
||||
return if total == 0
|
||||
Book.where(:rss2_id.nin => ([nil,''] + books.map{|book| book["rss_id"]}),member_profile_id: mp.id).destroy
|
||||
books.each_with_index do |book,index|
|
||||
if !book.blank?
|
||||
boo = Book.where(:rss2_id => book["rss_id"]).first rescue nil
|
||||
if boo.nil?
|
||||
boo = Book.new(rss2_id: book["rss_id"])
|
||||
puts "Syncing new : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
puts "rss2_id: #{book["rss_id"]}" if @debug_mode
|
||||
else
|
||||
puts "Updating old : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
end
|
||||
boo.publish_date = "#{book["publication_year"]}/#{book["publication_month"]}/01"
|
||||
boo.url = book["url"]
|
||||
boo.year = book["publication_year"]
|
||||
boo.book_title_translations = book["title"]
|
||||
boo.member_profile = mp
|
||||
boo.isbn = book["number"]
|
||||
boo.save
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
end
|
||||
puts "Books for staff #{staff_id} completed."
|
||||
end
|
||||
|
||||
def self.sync_projects(staff_id,mp)
|
||||
data = self.get_projects(staff_id)
|
||||
puts "Starting Projects for staff #{staff_id}."
|
||||
if !data.nil?
|
||||
projects = data
|
||||
total = projects.count rescue 0
|
||||
return if total == 0
|
||||
Project.where(:rss2_id.nin => ([nil,''] + projects.map{|project| project["rss_id"]}),member_profile_id: mp.id).destroy
|
||||
projects.each_with_index do |project,index|
|
||||
next if project.blank?
|
||||
proj = Project.where(:rss2_id => project["rss_id"]).first rescue nil
|
||||
pt_title = [project["category"]["zh_tw"],project["category"]["en"]].compact rescue []
|
||||
pt = ProjectType.where(:title.in => pt_title).first rescue nil
|
||||
if pt.nil? && pt_title.count > 0
|
||||
pt = ProjectType.new
|
||||
pt.title_translations = project["category"]
|
||||
pt.save
|
||||
end
|
||||
if proj.nil?
|
||||
proj = Project.new(rss2_id: project["rss_id"])
|
||||
puts "Syncing new : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
puts "rss2_id: #{project["rss_id"]}" if @debug_mode
|
||||
else
|
||||
puts "Updating old : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
end
|
||||
proj.period_start_date = project["start_date"]
|
||||
proj.period_end_date = project["end_date"]
|
||||
proj.url = project["url"]
|
||||
proj.year = project["year"]
|
||||
proj.project_title_translations = project["title"]
|
||||
proj.job_title_translations = project["job"]
|
||||
proj.participator_translations = project["participator"]
|
||||
proj.unit_translations = project["unit"]
|
||||
proj.member_profile = mp
|
||||
proj.project_type = pt
|
||||
proj.save
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
puts "Projects for staff #{staff_id} completed."
|
||||
end
|
||||
|
||||
def self.sync_honors(staff_id,mp)
|
||||
data = self.get_honors(staff_id)
|
||||
puts "Starting Honors for staff #{staff_id}."
|
||||
if !data.nil?
|
||||
honors = data
|
||||
total = honors.count rescue 0
|
||||
return if total == 0
|
||||
Honor.where(:rss2_id.nin => ([nil,''] + honors.map{|honor| honor["rss_id"]}),member_profile_id: mp.id).destroy
|
||||
honors.each_with_index do |honor,index|
|
||||
next if honor.blank?
|
||||
hon = Honor.where(:rss2_id => honor["rss_id"]).first rescue nil
|
||||
ht_title = [honor["category"]["zh_tw"],honor["category"]["en"]].compact rescue []
|
||||
ht = HonorType.where(:title.in => ht_title).first rescue nil
|
||||
if ht.nil? && ht_title.count > 0
|
||||
ht = HonorType.new
|
||||
ht.title_translations = honor["category"]
|
||||
ht.save
|
||||
end
|
||||
if hon.nil?
|
||||
hon = Honor.new(rss2_id: honor["rss_id"])
|
||||
puts "Syncing new : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
puts "rss2_id: #{honor["rss_id"]}" if @debug_mode
|
||||
else
|
||||
puts "Updating old : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
end
|
||||
hon.award_name_translations = honor["title"]
|
||||
hon.awarding_unit_translations = honor["unit"]
|
||||
hon.year = honor["year"]
|
||||
hon.honor_type = ht
|
||||
hon.member_profile = mp
|
||||
hon.save
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
puts "Honors for staff #{staff_id} completed."
|
||||
end
|
||||
|
||||
def self.sync_diplomas(staff_id,mp)
|
||||
data = self.get_diplomas(staff_id)
|
||||
puts "Starting Diplomas for staff #{staff_id}."
|
||||
if !data.nil?
|
||||
diplomas = data
|
||||
total = diplomas.count rescue 0
|
||||
return if total == 0
|
||||
Diploma.where(:rss2_id.nin => ([nil,''] + diplomas.map{|diploma| diploma["rss_id"]}),member_profile_id: mp.id).destroy
|
||||
diplomas.each_with_index do |diploma,index|
|
||||
next if diploma.blank?
|
||||
dip = Diploma.where(:rss2_id => diploma["rss_id"]).first rescue nil
|
||||
if dip.nil?
|
||||
dip = Diploma.new(rss2_id: diploma["rss_id"])
|
||||
puts "Syncing new : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
puts "rss2_id: #{diploma["rss_id"]}" if @debug_mode
|
||||
else
|
||||
puts "Updating old : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
end
|
||||
dip.country_translations = diploma["country"]
|
||||
dip.degree_translations = diploma["degree"]
|
||||
dip.department_translations = diploma["dept"]
|
||||
dip.start_date = diploma["start_date"]
|
||||
dip.end_date = diploma["end_date"]
|
||||
dip.school_name_translations = diploma["school"]
|
||||
dip.member_profile = mp
|
||||
dip.save
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
puts "Diplomas for staff #{staff_id} completed."
|
||||
end
|
||||
|
||||
def self.sync_experiences(staff_id,mp)
|
||||
data = self.get_experiences(staff_id)
|
||||
puts "Starting Experiences for staff #{staff_id}."
|
||||
if !data.nil?
|
||||
experiences = data
|
||||
total = experiences.count rescue 0
|
||||
return if total == 0
|
||||
Experience.where(:rss2_id.nin => ([nil,''] + experiences.map{|experience| experience["rss_id"]}),member_profile_id: mp.id).destroy
|
||||
experiences.each_with_index do |experience,index|
|
||||
next if experience.blank?
|
||||
exp = Experience.where(:rss2_id => experience["rss_id"]).first rescue nil
|
||||
et_title = [experience["type"]["zh_tw"],experience["type"]["en"]].compact rescue []
|
||||
et = ExperienceType.where(:title.in => et_title).first rescue nil
|
||||
if et.nil? && et_title.count > 0
|
||||
et = ExperienceType.new
|
||||
et.title_translations = experience["type"]
|
||||
et.save
|
||||
end
|
||||
if exp.nil?
|
||||
exp = Experience.new(rss2_id: experience["rss_id"])
|
||||
puts "Syncing new : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
puts "rss2_id: #{experience["rss_id"]}" if @debug_mode
|
||||
else
|
||||
puts "Updating old : " + ((100 * (index +1)) / total).to_s + "%"
|
||||
end
|
||||
exp.department_translations = experience["dept"]
|
||||
exp.organizationt_title_translations = experience["unit"]
|
||||
exp.job_title_translations = experience["title"]
|
||||
exp.start_date = experience["start_date"]
|
||||
exp.end_date = experience["end_date"]
|
||||
exp.experience_type = et
|
||||
exp.member_profile = mp
|
||||
exp.save
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
puts "Experiences for staff #{staff_id} completed."
|
||||
end
|
||||
|
||||
def self.get_sql(table_name, filter_params={}, order_fields=nil)
|
||||
if order_fields.nil?
|
||||
sql = "SELECT * FROM [#{table_name}]"
|
||||
field_prefix = ""
|
||||
else # rss_id is the row index
|
||||
if order_fields === false
|
||||
sql = "SELECT * from (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) "
|
||||
else
|
||||
sql = "SELECT * from (SELECT ROW_NUMBER() OVER(ORDER BY "
|
||||
sql += order_fields.map{|k,v| "#{k} #{v}"}.join(', ')
|
||||
sql += ") "
|
||||
end
|
||||
sql += "AS rss_id,* FROM [#{table_name}]) r"
|
||||
field_prefix = "r."
|
||||
end
|
||||
if filter_params.present?
|
||||
sql += " WHERE "
|
||||
filter_params.each_with_index do |(k,v), i|
|
||||
if i != 0
|
||||
sql += " AND "
|
||||
end
|
||||
if v.class == Array
|
||||
if v.count > 0
|
||||
sql += "("
|
||||
v.each_with_index do |vv, i|
|
||||
if i != 0
|
||||
sql += " OR "
|
||||
end
|
||||
if vv.class == String
|
||||
sql += "#{field_prefix}#{k} = \"#{vv}\""
|
||||
else
|
||||
sql += "#{field_prefix}#{k} = #{vv}"
|
||||
end
|
||||
end
|
||||
sql += ")"
|
||||
end
|
||||
else
|
||||
if v.class == String
|
||||
sql += "#{field_prefix}#{k} = \"#{v}\""
|
||||
else
|
||||
sql += "#{field_prefix}#{k} = #{v}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if @debug_mode
|
||||
puts sql
|
||||
end
|
||||
sql
|
||||
end
|
||||
|
||||
def self.query_db(table_name, filter_params={})
|
||||
order_fields = {
|
||||
'rsspublish' => {'publ_num'=> 'ASC'}, #著作編號
|
||||
'rssproject' => {'number'=> 'ASC'}, #編號(流水號)
|
||||
'rssreward' => {'sta_num'=> 'ASC', 'wrd_yy'=> 'ASC'}, #員工編號, 得獎年度
|
||||
'rssworkexp' => {'sta_num'=> 'ASC', 'bgn_dt'=> 'ASC'}, #經歷一覽
|
||||
'rss_pastapos_a' => {'pastapos_a_num' => 'ASC'}, #校內本職
|
||||
'rss_pastapos_b' => {'pastapos_b_num' => 'ASC'}, #校內兼職
|
||||
'rss_paedu_vw' => {'paedu_num' => 'ASC'}, #學歷資料編號
|
||||
} # true => order by first column with desc order
|
||||
rss_id_offsets = {}
|
||||
# rss_id_offsets = {
|
||||
# 'rsspublish' => 1073443
|
||||
# }
|
||||
extra_condition = {
|
||||
'rss_pastapos_a' => {
|
||||
'dsp_flg' => 1,
|
||||
'inst_cod' => ['309210000Q','A09520000Q']
|
||||
},
|
||||
'rss_pastapos_b' => {
|
||||
'dsp_flg' => 1
|
||||
}
|
||||
}
|
||||
order_field = order_fields[table_name]
|
||||
if order_field === true
|
||||
order_field = @default_order_fields[table_name]
|
||||
if order_field.nil?
|
||||
order_field = {@client.execute("SELECT name FROM sys.columns WHERE object_id = OBJECT_ID('#{table_name}')").to_a.map{|h| h['name']}.first => @default_order}
|
||||
@default_order_fields[table_name] = order_field
|
||||
end
|
||||
end
|
||||
if @test_mode
|
||||
filter_params = {}
|
||||
end
|
||||
sql = get_sql(table_name, filter_params.merge(extra_condition[table_name].to_h), order_field)
|
||||
#'origin field name' => 'new field name'
|
||||
key_mapping = {
|
||||
'rsspublish' => { # journal, conference, research, book
|
||||
'publ_num' => 'number',
|
||||
'writing_chi' => 'title.zh_tw',
|
||||
'writing_eng' => 'title.en',
|
||||
'publ_yy' => 'publication_year',
|
||||
'publ_mon' => 'publication_month',
|
||||
'url_addr' => 'url'
|
||||
},
|
||||
'rssproject' => { # 計畫 project
|
||||
'plan_fg' => 'category',
|
||||
'prj_nam_chi' => 'title.zh_tw',
|
||||
'prj_nam_eng' => 'title.en',
|
||||
'bgn_dt' => 'start_date',
|
||||
'end_dt' => 'end_date',
|
||||
'prj_yy' => 'year',
|
||||
'job_title_chi' => 'job.zh_tw',
|
||||
'job_title_eng' => 'job.en',
|
||||
'part_list_chi' => 'participator.zh_tw',
|
||||
'part_list_eng' => 'participator.en',
|
||||
'cmt_nam_chi' => 'unit.zh_tw',
|
||||
'cmt_nam_eng' => 'unit.en'
|
||||
},
|
||||
'rssreward' => { # 榮譽 honor
|
||||
'wrd_tpe' => 'category',
|
||||
'wrd_yy' => 'year',
|
||||
'wrd_nam_chi' => 'title.zh_tw',
|
||||
'wrd_nam_eng' => 'title.en',
|
||||
'unit_nam_chi' => 'unit.zh_tw',
|
||||
'unit_nam_eng' => 'unit.en'
|
||||
},
|
||||
'rssworkexp' => { # 經歷一覽 experience
|
||||
'pos_nam_chi' => 'title.zh_tw',
|
||||
'pos_nam_eng' => 'title.en',
|
||||
'job_dtl_chi' => 'job.zh_tw',
|
||||
'job_dtl_eng' => 'job.en',
|
||||
'inst_nam_chi' => 'unit.zh_tw',
|
||||
'inst_nam_eng' => 'unit.en',
|
||||
'ut_nam_chi' => 'dept.zh_tw',
|
||||
'ut_nam_eng' => 'dept.en',
|
||||
'bgn_dt' => 'start_date',
|
||||
'end_dt' => 'end_date'
|
||||
},
|
||||
'rss_pastapos_a' => { # 校內本職 experience
|
||||
'pos_cod' => 'title',
|
||||
{
|
||||
'zh_tw' => '',
|
||||
'en' => ''
|
||||
} => 'job',
|
||||
'ut_cod' => 'dept',
|
||||
{
|
||||
'zh_tw' => '政治大學',
|
||||
'en' => 'NATIONAL CHENGCHI UNIVERSITY'
|
||||
} => 'unit',
|
||||
'emp_dt' => 'start_date',
|
||||
'reli_dt' => 'end_date'
|
||||
},
|
||||
'rss_pastapos_b' => { # 校內兼職 experience
|
||||
'pos_cod' => 'title',
|
||||
{
|
||||
'zh_tw' => '',
|
||||
'en' => ''
|
||||
} => 'job',
|
||||
'ut_cod' => 'dept',
|
||||
{
|
||||
'zh_tw' => '政治大學',
|
||||
'en' => 'NATIONAL CHENGCHI UNIVERSITY'
|
||||
} => 'unit',
|
||||
'start_date' => 'emp_dt',
|
||||
'end_date' => 'reli_dt'
|
||||
},
|
||||
'rss_paedu_vw' => { # 學歷 diploma
|
||||
'nat_cod' => 'country',
|
||||
'edulvl_cod' => 'degree',
|
||||
'edudep_cod' => 'dept',
|
||||
'bgn_dt' => 'start_date',
|
||||
'end_dt' => 'end_date',
|
||||
'sch_cod' => 'school'
|
||||
},
|
||||
'zz_nat' => { # 國家對照表
|
||||
'nat_chi' => 'zh_tw',
|
||||
'nat_eng' => 'en'
|
||||
},
|
||||
'pa_edulvl' => { # 教育程度對照表
|
||||
'edulvl_chi' => ['zh_tw', 'en']
|
||||
},
|
||||
'pa_edudep' => { # 系所對照表, 給學歷用的
|
||||
'edudep_chi' => ['zh_tw', 'en']
|
||||
},
|
||||
'rss_sch_view' => { # 學校對照表
|
||||
'sch_chi' => ['zh_tw', 'en']
|
||||
},
|
||||
'pa_pos' => { # 職位對照表
|
||||
'pos_chi' => ['zh_tw', 'en']
|
||||
},
|
||||
'paunit_h' => { # 系所對照表 - 2, 給經歷用的
|
||||
'ut_chi_f' => 'zh_tw',
|
||||
'ut_eng_f' => 'en'
|
||||
},
|
||||
'rss_pautlst_view' => { # 教師資料
|
||||
|
||||
}
|
||||
}
|
||||
result = @client.execute(sql).to_a
|
||||
if key_mapping.has_key?(table_name) && key_mapping[table_name].present?
|
||||
tmp = key_mapping[table_name]
|
||||
rss_id_offset = rss_id_offsets[table_name]
|
||||
result.each do |h|
|
||||
if rss_id_offset && h['rss_id']
|
||||
h['rss_id'] = h['rss_id'] + rss_id_offset
|
||||
end
|
||||
h.each do |k,v|
|
||||
if v.class == String
|
||||
h[k] = v.strip
|
||||
end
|
||||
end
|
||||
tmp.each do |k,v|
|
||||
if k.class != String
|
||||
tmp_value = k
|
||||
else
|
||||
tmp_value = h[k]
|
||||
end
|
||||
if v.class == Array
|
||||
include_key = false
|
||||
v.each do |vv|
|
||||
if vv.include?('.')
|
||||
vv_k, locale = vv.split('.')
|
||||
include_key = true if vv_k == k
|
||||
unless h.has_key?(vv_k)
|
||||
h[vv_k] = {}
|
||||
end
|
||||
h[vv_k][locale] = tmp_value
|
||||
else
|
||||
include_key = true if vv == k
|
||||
h[vv] = tmp_value
|
||||
end
|
||||
end
|
||||
unless include_key
|
||||
h.delete(k)
|
||||
end
|
||||
else
|
||||
if v.include?('.')
|
||||
v_k, locale = v.split('.')
|
||||
unless h.has_key?(v_k)
|
||||
h[v_k] = {}
|
||||
end
|
||||
h[v_k][locale] = tmp_value
|
||||
else
|
||||
if v.ends_with?('_date') && tmp_value.present? && tmp_value.scan(/\d/).count == 6
|
||||
if tmp_value.length == 6 #年月,ex: 202005
|
||||
tmp_value += "01"
|
||||
else #有分隔符號
|
||||
tmp_value = "#{tmp_value.gsub(/\/|-|,/, '-')}-01"
|
||||
end
|
||||
end
|
||||
h[v] = tmp_value
|
||||
end
|
||||
h.delete(k)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
result.each do |h|
|
||||
if rss_id_offset && h['rss_id']
|
||||
h['rss_id'] = h['rss_id'] + rss_id_offset
|
||||
end
|
||||
h.each do |k,v|
|
||||
if v.class == String
|
||||
h[k] = v.strip
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if @test_mode && table_name.start_with?('rss')
|
||||
print result[0]
|
||||
puts nil
|
||||
raise 'error'
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def self.get_country_mapping #country,nat_cod為對照值, nat_chi, nat_eng欄位為中、英文翻譯
|
||||
@country_mapping = query_db('zz_nat').map{|h| [h['nat_cod'], h.slice('zh_tw', 'en')]}.to_h
|
||||
end
|
||||
|
||||
def self.get_degree_mapping #degree,edulvl_cod為對照值, edulvl_chi欄位為中、英文翻譯
|
||||
@degree_mapping = query_db('pa_edulvl').map{|h| [h['edulvl_cod'], h.slice('zh_tw', 'en')]}.to_h
|
||||
end
|
||||
|
||||
def self.get_dept_mapping #dept,edudep_cod為對照值, edudep_chi欄位為中、英文翻譯
|
||||
@dept_mapping = query_db('pa_edudep').map{|h| [h['edudep_cod'], h.slice('zh_tw', 'en')]}.to_h
|
||||
end
|
||||
|
||||
def self.get_dept_mapping_for_experience #dept,ut_cod為對照值, ut_chi_f, ut_eng_f欄位為中、英文翻譯
|
||||
@dept_mapping_for_experience = query_db('paunit_h').map{|h| [h['ut_cod'], h.slice('zh_tw', 'en')]}.to_h
|
||||
end
|
||||
|
||||
def self.get_school_mapping #school,sch_cod為對照值, sch_chi欄位為中、英文翻譯
|
||||
@school_mapping = query_db('rss_sch_view').map{|h| [h['sch_cod'], h.slice('zh_tw', 'en')]}.to_h
|
||||
end
|
||||
|
||||
def self.get_position_mapping #title,pos_cod為對照值, pos_chi欄位為中、英文翻譯
|
||||
@position_mapping = query_db('pa_pos').map{|h| [h['pos_cod'], h.slice('zh_tw', 'en')]}.to_h
|
||||
end
|
||||
|
||||
def self.get_sta_num_to_nccu_id_mapping #sta_num 與 nccu_id 的對照表, 可透過 rss_aaldap_view 與 rss_pautlst_view 這兩個table查詢
|
||||
@sta_num_to_nccu_id_mapping = query_db('rss_aaldap_view').map{|h| [h['sta_num'], h['nccu_id']]}.to_h # psn_nam 教師完整姓名
|
||||
end
|
||||
|
||||
def self.get_journal_papers(staff_id)
|
||||
result = query_db('rsspublish', {:sta_num=>staff_id, :publ_tpe=>'03'})
|
||||
end
|
||||
|
||||
def self.get_conference_papers(staff_id)
|
||||
result = query_db('rsspublish', {:sta_num=>staff_id, :publ_tpe=>'04'})
|
||||
end
|
||||
|
||||
def self.get_research_papers(staff_id)
|
||||
result = query_db('rsspublish', {:sta_num=>staff_id, :publ_tpe=>'05'})
|
||||
end
|
||||
|
||||
def self.get_books(staff_id)
|
||||
result = query_db('rsspublish', {:sta_num=>staff_id, :publ_tpe=>['01', '02']})
|
||||
end
|
||||
|
||||
def self.get_projects(staff_id)
|
||||
# url field not exist in original nccu database
|
||||
result = query_db('rssproject', {:sta_num=>staff_id})
|
||||
category_mapping = {
|
||||
'Y' => {
|
||||
'zh_tw' => '科技部',
|
||||
'en' => 'MOST Projects'
|
||||
},
|
||||
'N' => {
|
||||
'zh_tw' => '非科技部',
|
||||
'en' => 'Other Projects'
|
||||
}
|
||||
}
|
||||
result.each do |h|
|
||||
h['category'] = category_mapping[h['category']]
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def self.get_honors(staff_id)
|
||||
result = query_db('rssreward', {:sta_num=>staff_id})
|
||||
category_mapping = {
|
||||
'1' => {
|
||||
'zh_tw' => '校內',
|
||||
'en' => 'Inside School'
|
||||
},
|
||||
'2' => {
|
||||
'zh_tw' => '校外',
|
||||
'en' => 'Outside School'
|
||||
},
|
||||
'3' => {
|
||||
'zh_tw' => '事蹟',
|
||||
'en' => 'Deeds'
|
||||
}
|
||||
}
|
||||
result.each do |h|
|
||||
h['category'] = category_mapping[h['category']]
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def self.get_diplomas(staff_id)
|
||||
nccu_id = @sta_num_to_nccu_id_mapping[staff_id]
|
||||
if nccu_id.nil?
|
||||
puts "No nccu_id for staff: #{staff_id}"
|
||||
return []
|
||||
end
|
||||
result = query_db('rss_paedu_vw', {:nccu_id=>nccu_id})
|
||||
result.each do |h|
|
||||
h['country'] = @country_mapping[h['country']]
|
||||
h['degree'] = @degree_mapping[h['degree']]
|
||||
h['dept'] = @dept_mapping[h['dept']]
|
||||
h['school'] = @school_mapping[h['school']]
|
||||
if h['school'].blank?
|
||||
school_chi = h['sch_nam']
|
||||
school_eng = h['sch_nam_en']
|
||||
if school_eng.blank?
|
||||
school_eng = school_chi
|
||||
elsif school_chi.blank?
|
||||
school_chi = school_eng
|
||||
end
|
||||
h['school'] = {
|
||||
'zh_tw' => school_chi,
|
||||
'en' => school_eng
|
||||
}
|
||||
end
|
||||
if h['dept'].blank?
|
||||
dept_chi = h['dep_nam']
|
||||
dept_eng = h['edudep_nam_en']
|
||||
if dept_eng.blank?
|
||||
dept_eng = dept_chi
|
||||
elsif school_chi.blank?
|
||||
dept_chi = dept_eng
|
||||
end
|
||||
h['dept'] = {
|
||||
'zh_tw' => dept_chi,
|
||||
'en' => dept_eng
|
||||
}
|
||||
end
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def self.get_experiences(staff_id)
|
||||
table_names = ['rssworkexp', 'rss_pastapos_a', 'rss_pastapos_b']
|
||||
need_mapping = [false, true, true] #use @position_mapping, @dept_mapping_for_experience
|
||||
type_trans = [
|
||||
{
|
||||
'zh_tw' => '經歷一覽',
|
||||
'en' => 'Experience'
|
||||
},
|
||||
{
|
||||
'zh_tw' => '校內本職',
|
||||
'en' => 'Experience'
|
||||
},
|
||||
{
|
||||
'zh_tw' => '校內本職',
|
||||
'en' => 'Part Time'
|
||||
}
|
||||
]
|
||||
result = []
|
||||
table_names.each_with_index do |table_name, i|
|
||||
tmp = query_db(table_name, {:sta_num=>staff_id})
|
||||
if need_mapping[i]
|
||||
tmp.each do |h|
|
||||
h['type'] = type_trans[i]
|
||||
h['title'] = @position_mapping[h['title']]
|
||||
h['dept'] = @dept_mapping_for_experience[h['dept']]
|
||||
end
|
||||
else
|
||||
tmp.each do |h|
|
||||
h['type'] = type_trans[i]
|
||||
end
|
||||
end
|
||||
result += tmp
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
end
|
||||
namespace :sync_nccu_personal_plugins do
|
||||
task :sync,[:uid] => :environment do |task,args|
|
||||
#require "#{ENV['PWD']}/app/models/member_profile" #it will cause circular dependency
|
||||
NccuSyncPlugin.init
|
||||
if args.uid.present?
|
||||
mps = MemberProfile.where(:uid=>args.uid).to_a
|
||||
else
|
||||
mps = MemberProfile.all.to_a
|
||||
end
|
||||
mps.each do |mp|
|
||||
staff_id = mp.sid rescue nil
|
||||
if (!staff_id.blank? rescue false)
|
||||
NccuSyncPlugin.sync_journal_papers(staff_id,mp)
|
||||
NccuSyncPlugin.sync_conference_papers(staff_id,mp)
|
||||
NccuSyncPlugin.sync_research_papers(staff_id,mp)
|
||||
NccuSyncPlugin.sync_books(staff_id,mp)
|
||||
NccuSyncPlugin.sync_projects(staff_id,mp)
|
||||
NccuSyncPlugin.sync_honors(staff_id,mp)
|
||||
NccuSyncPlugin.sync_diplomas(staff_id,mp)
|
||||
NccuSyncPlugin.sync_experiences(staff_id,mp)
|
||||
end
|
||||
end
|
||||
NccuSyncPlugin.close
|
||||
end
|
||||
end
|
|
@ -0,0 +1,83 @@
|
|||
$:.push File.expand_path("lib", __dir__)
|
||||
|
||||
# Maintain your gem's version:
|
||||
require "sync_nccu_personal_data/version"
|
||||
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
|
||||
if bundle_update_flag
|
||||
env_pwd = ENV['PWD']
|
||||
begin
|
||||
require ::File.expand_path('app/helpers/bundler_helper.rb', env_pwd)
|
||||
extend BundlerHelper
|
||||
rescue LoadError
|
||||
def bundler_with_clean_env(&block)
|
||||
if block_given?
|
||||
if Bundler.respond_to?(:with_unbundled_env)
|
||||
Bundler.with_unbundled_env(&block)
|
||||
else
|
||||
Bundler.with_clean_env(&block)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
home_path = ENV['HOME']
|
||||
if Dir.glob("#{ENV["GEM_HOME"]}/gems/tiny_tds-*").count == 0
|
||||
app_path = File.expand_path(__dir__)
|
||||
if home_path.nil? || home_path == ""
|
||||
home_path = app_path
|
||||
else
|
||||
require "fileutils"
|
||||
FileUtils.rm_r("#{home_path}/freetds-1.1.24_build", :force => true)
|
||||
FileUtils.cp_r("#{app_path}/freetds-1.1.24_build/", "#{home_path}/.")
|
||||
end
|
||||
FileUtils.chmod_R( 0755, Dir.glob("#{home_path}/freetds-1.1.24_build/bin/*"))
|
||||
puts "Installing tiny_tds gem ..."
|
||||
bundler_with_clean_env{ system("gem install tiny_tds -- '--with-freetds-dir=#{home_path}/freetds-1.1.24_build'") }
|
||||
end
|
||||
crontab_sync = `crontab -l|grep 'bundle exec rake sync_nccu_personal_plugins:sync'|grep #{ENV['PWD']}`
|
||||
sync_cron="0 0 * * * /bin/bash -l -c 'cd #{ENV['PWD']} && bundle exec rake sync_nccu_personal_plugins:sync > /dev/null'"
|
||||
crontab_sync_jobs = crontab_sync.split("\n")
|
||||
if crontab_sync_jobs.count == 0
|
||||
%x(CRON="#{sync_cron}" && (crontab -l; echo "$CRON" ) | crontab -)
|
||||
elsif crontab_sync_jobs.count > 1
|
||||
crontab_jobs = `crontab -l`
|
||||
crontab_sync_jobs[1..-1].each do |s|
|
||||
crontab_jobs = crontab_jobs.sub(s,"")
|
||||
end
|
||||
%x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -)
|
||||
elsif crontab_sync_jobs[0][0...3] == "0 5" #replace old cronjob settings
|
||||
crontab_jobs = `crontab -l`
|
||||
crontab_jobs = crontab_jobs.sub(crontab_sync_jobs[0],sync_cron)
|
||||
%x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -)
|
||||
elsif crontab_sync_jobs[0].include?("-23/12") #replace 12 hours to 24 hours
|
||||
crontab_jobs = `crontab -l`
|
||||
crontab_jobs = crontab_jobs.sub(crontab_sync_jobs[0],crontab_sync_jobs[0].sub("-23/12",""))
|
||||
%x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -)
|
||||
elsif crontab_sync_jobs[0].include?("*/12") #replace 12 hours to 24 hours
|
||||
crontab_jobs = `crontab -l`
|
||||
crontab_jobs = crontab_jobs.sub(crontab_sync_jobs[0],crontab_sync_jobs[0].sub("*/12","0"))
|
||||
%x(CRON="#{crontab_jobs}" && (echo "$CRON" ) | crontab -)
|
||||
end
|
||||
end
|
||||
# Describe your gem and declare its dependencies:
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = "sync_nccu_personal_data"
|
||||
spec.version = SyncNccuPersonalData::VERSION
|
||||
spec.authors = ["Bohung Chiu"]
|
||||
spec.email = ["bohung@rulingcom.com"]
|
||||
spec.homepage = "https://w3.rulingcom.com/"
|
||||
spec.summary = "Sync Asia University's personal data for teachers"
|
||||
spec.description = "Sync Asia University's personal data for teachers"
|
||||
spec.license = "MIT"
|
||||
|
||||
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
||||
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
||||
if spec.respond_to?(:metadata)
|
||||
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
||||
else
|
||||
raise "RubyGems 2.0 or newer is required to protect against " \
|
||||
"public gem pushes."
|
||||
end
|
||||
|
||||
spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
|
||||
spec.add_dependency "tiny_tds"
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
2.5.4
|
|
@ -0,0 +1,6 @@
|
|||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||
|
||||
require_relative 'config/application'
|
||||
|
||||
Rails.application.load_tasks
|
|
@ -0,0 +1,2 @@
|
|||
//= link_tree ../images
|
||||
//= link_directory ../stylesheets .css
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||
* listed below.
|
||||
*
|
||||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
||||
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
||||
*
|
||||
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
||||
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
||||
* files in this directory. Styles in this file should be added after the last require_* statement.
|
||||
* It is generally better to create a new file per style scope.
|
||||
*
|
||||
*= require_tree .
|
||||
*= require_self
|
||||
*/
|
|
@ -0,0 +1,4 @@
|
|||
module ApplicationCable
|
||||
class Channel < ActionCable::Channel::Base
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
module ApplicationCable
|
||||
class Connection < ActionCable::Connection::Base
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module ApplicationHelper
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||
// listed below.
|
||||
//
|
||||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
||||
//
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
||||
//
|
||||
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
||||
// about supported directives.
|
||||
//
|
||||
//= require rails-ujs
|
||||
//= require activestorage
|
||||
//= require_tree .
|
|
@ -0,0 +1,7 @@
|
|||
class ApplicationJob < ActiveJob::Base
|
||||
# Automatically retry jobs that encountered a deadlock
|
||||
# retry_on ActiveRecord::Deadlocked
|
||||
|
||||
# Most jobs are safe to ignore if the underlying records are no longer available
|
||||
# discard_on ActiveJob::DeserializationError
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: 'from@example.com'
|
||||
layout 'mailer'
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Dummy</title>
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
|
||||
<%= stylesheet_link_tag 'application', media: 'all' %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
/* Email styles need to be inline */
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1 @@
|
|||
<%= yield %>
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env ruby
|
||||
APP_PATH = File.expand_path('../config/application', __dir__)
|
||||
require_relative '../config/boot'
|
||||
require 'rails/commands'
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env ruby
|
||||
require_relative '../config/boot'
|
||||
require 'rake'
|
||||
Rake.application.run
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'fileutils'
|
||||
|
||||
# path to your application root.
|
||||
APP_ROOT = File.expand_path('..', __dir__)
|
||||
|
||||
def system!(*args)
|
||||
system(*args) || abort("\n== Command #{args} failed ==")
|
||||
end
|
||||
|
||||
FileUtils.chdir APP_ROOT do
|
||||
# This script is a way to setup or update your development environment automatically.
|
||||
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
|
||||
# Add necessary setup steps to this file.
|
||||
|
||||
puts '== Installing dependencies =='
|
||||
system! 'gem install bundler --conservative'
|
||||
system('bundle check') || system!('bundle install')
|
||||
|
||||
# puts "\n== Copying sample files =="
|
||||
# unless File.exist?('config/database.yml')
|
||||
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
|
||||
# end
|
||||
|
||||
puts "\n== Preparing database =="
|
||||
system! 'bin/rails db:prepare'
|
||||
|
||||
puts "\n== Removing old logs and tempfiles =="
|
||||
system! 'bin/rails log:clear tmp:clear'
|
||||
|
||||
puts "\n== Restarting application server =="
|
||||
system! 'bin/rails restart'
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
# This file is used by Rack-based servers to start the application.
|
||||
|
||||
require_relative 'config/environment'
|
||||
|
||||
run Rails.application
|