advantage 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README +126 -0
- data/Rakefile +11 -0
- data/advantage.gemspec +53 -0
- data/ext/advantage/ace.h +5079 -0
- data/ext/advantage/adscapidll.c +164 -0
- data/ext/advantage/adscapidll.h +245 -0
- data/ext/advantage/advantage.c +1836 -0
- data/ext/advantage/dbcapi.cpp +1735 -0
- data/ext/advantage/dbcapi.h +245 -0
- data/ext/advantage/extconf.rb +30 -0
- data/test/advantage/advantage_test.rb +332 -0
- data/test/advantage/test.sql +64 -0
- data/test/mytest.rb +63 -0
- data/test/mytest2.rb +67 -0
- data/test/mytest3.rb +84 -0
- metadata +122 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
// *****************************************************
|
2
|
+
// Copyright (c) 2008-2010 iAnywhere Solutions, Inc.
|
3
|
+
// Portions copyright (c) 1988-2010 Sybase, Inc.
|
4
|
+
// All rights reserved. All unpublished rights reserved.
|
5
|
+
// *****************************************************
|
6
|
+
IF EXISTS( SELECT * FROM SYSTEM.TABLES WHERE "name" = 'test') THEN
|
7
|
+
DROP TABLE "test";
|
8
|
+
END IF;
|
9
|
+
|
10
|
+
IF EXISTS( SELECT * FROM SYSTEM.TABLES WHERE "name" = 'types') THEN
|
11
|
+
DROP TABLE "types";
|
12
|
+
END IF;
|
13
|
+
|
14
|
+
CREATE TABLE "test" (
|
15
|
+
"id" AUTOINC CONSTRAINT NOT NULL,
|
16
|
+
PRIMARY KEY("id")
|
17
|
+
);
|
18
|
+
|
19
|
+
CREATE TABLE "types" (
|
20
|
+
"id" INTEGER PRIMARY KEY,
|
21
|
+
"_blob_" blob,
|
22
|
+
"_numeric_" NUMERIC(5,2),
|
23
|
+
"_char_" CHAR(255),
|
24
|
+
"_memo_" MEMO,
|
25
|
+
"_int_" INTEGER,
|
26
|
+
"_short_" SHORT,
|
27
|
+
"_logical_" LOGICAL,
|
28
|
+
"_date_" DATE,
|
29
|
+
"_timestamp_" TIMESTAMP,
|
30
|
+
"_double_" DOUBLE,
|
31
|
+
"_money_" MONEY
|
32
|
+
);
|
33
|
+
|
34
|
+
INSERT INTO types VALUES
|
35
|
+
( 0,
|
36
|
+
CHAR2HEX ( '78' ),
|
37
|
+
1.1,
|
38
|
+
'Bounded String Test',
|
39
|
+
'Unbounded String Test',
|
40
|
+
1,
|
41
|
+
1,
|
42
|
+
TRUE,
|
43
|
+
'1999-01-02',
|
44
|
+
'1999-01-02 21:20:53',
|
45
|
+
3.402823e+38,
|
46
|
+
1
|
47
|
+
);
|
48
|
+
|
49
|
+
INSERT INTO types VALUES
|
50
|
+
( 1,
|
51
|
+
CHAR2HEX ( 'FF'),
|
52
|
+
-1.1,
|
53
|
+
'',
|
54
|
+
'',
|
55
|
+
0,
|
56
|
+
0,
|
57
|
+
FALSE,
|
58
|
+
NULL,
|
59
|
+
NULL,
|
60
|
+
-3.402823e+38,
|
61
|
+
-7.77
|
62
|
+
);
|
63
|
+
|
64
|
+
|
data/test/mytest.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
begin
|
2
|
+
require "rubygems"
|
3
|
+
require "advantage"
|
4
|
+
unless defined? Advantage
|
5
|
+
# require 'advantage'
|
6
|
+
if RUBY_VERSION >= "1.9"
|
7
|
+
require_relative "../lib/advantage/advantage.so"
|
8
|
+
else
|
9
|
+
require File.join(File.dirname(__FILE__), "../lib/advantage/advantage.so")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# create an interface
|
15
|
+
api = Advantage::AdvantageInterface.new()
|
16
|
+
#
|
17
|
+
# initialize the interface (loads the DLL/SO)
|
18
|
+
Advantage::API.ads_initialize_interface(api)
|
19
|
+
#
|
20
|
+
# initialize our api object
|
21
|
+
api.ads_init()
|
22
|
+
|
23
|
+
# create a connection
|
24
|
+
conn = api.ads_new_connection()
|
25
|
+
|
26
|
+
# establish a connection
|
27
|
+
conn_str = "data source=//172.27.144.1:6262/c\$/ads/db/mydb.add;user id=adssys;DateFormat=YYYY-MM-DD;CommType=TCP_IP;Compression=INTERNET"
|
28
|
+
# conn_str = "data source=//10.0.0.4:6262/aislims/db/;user id=adssys;DateFormat=YYYY-MM-DD;CommType=TCP_IP;"
|
29
|
+
val = api.ads_connect(conn, conn_str)
|
30
|
+
puts "VAL: #{val.inspect}"
|
31
|
+
|
32
|
+
# execute a query without a result set
|
33
|
+
# puts api.ads_execute_immediate(conn, "select 'Successful Ruby Connection' from system.iota;").inspect
|
34
|
+
# sql = "select 'Successful Ruby Connection' from system.iota;"
|
35
|
+
# sql = "select * from discount;"
|
36
|
+
sql = "EXECUTE PROCEDURE sp_GetTables( NULL, NULL, NULL, 'TABLE' );"
|
37
|
+
rs = api.ads_execute_direct(conn, sql)
|
38
|
+
puts "RS: #{rs.inspect}"
|
39
|
+
loop do
|
40
|
+
fetch = api.ads_fetch_next(rs)
|
41
|
+
break if fetch == 0
|
42
|
+
puts "FETCH: #{fetch.inspect}"
|
43
|
+
res, ret_id = api.ads_get_column(rs, 0)
|
44
|
+
puts "RES: #{res.inspect}, id: #{ret_id.inspect}"
|
45
|
+
end
|
46
|
+
|
47
|
+
puts "RS: #{rs.inspect}"
|
48
|
+
puts "fetch: #{fetch.inspect}"
|
49
|
+
puts "RES: #{res.inspect}, id: #{id.inspect}"
|
50
|
+
|
51
|
+
# disconnect from the database
|
52
|
+
puts api.ads_disconnect(conn).inspect
|
53
|
+
|
54
|
+
# free the connection resources
|
55
|
+
api.ads_free_connection(conn)
|
56
|
+
|
57
|
+
# free resources the api object uses
|
58
|
+
api.ads_fini()
|
59
|
+
|
60
|
+
# close the interface
|
61
|
+
Advantage::API.ads_finalize_interface(api)
|
62
|
+
|
63
|
+
puts "finished"
|
data/test/mytest2.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
begin
|
2
|
+
require "rubygems"
|
3
|
+
require "advantage"
|
4
|
+
unless defined? Advantage
|
5
|
+
# require 'advantage'
|
6
|
+
if RUBY_VERSION >= "1.9"
|
7
|
+
require_relative "../lib/advantage/advantage.so"
|
8
|
+
else
|
9
|
+
require File.join(File.dirname(__FILE__), "../lib/advantage/advantage.so")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# create an interface
|
15
|
+
api = Advantage::AdvantageInterface.new()
|
16
|
+
#
|
17
|
+
# initialize the interface (loads the DLL/SO)
|
18
|
+
Advantage::API.ads_initialize_interface(api)
|
19
|
+
#
|
20
|
+
# initialize our api object
|
21
|
+
api.ads_init()
|
22
|
+
|
23
|
+
# create a connection
|
24
|
+
conn = api.ads_new_connection()
|
25
|
+
|
26
|
+
# establish a connection
|
27
|
+
conn_str = "data source=//172.27.144.1:6262/c\$/ads/db/mydb.add;user id=adssys;DateFormat=YYYY-MM-DD;CommType=TCP_IP;Compression=INTERNET"
|
28
|
+
# conn_str = "data source=//10.0.0.4:6262/aislims/db/;user id=adssys;DateFormat=YYYY-MM-DD;CommType=TCP_IP;"
|
29
|
+
val = api.ads_connect(conn, conn_str)
|
30
|
+
puts "VAL: #{val.inspect}"
|
31
|
+
|
32
|
+
# execute a query without a result set
|
33
|
+
# puts api.ads_execute_immediate(conn, "select 'Successful Ruby Connection' from system.iota;").inspect
|
34
|
+
#sql = "select 'Successful Ruby Connection' from system.iota;"
|
35
|
+
sql = "select * from discount;"
|
36
|
+
rs = api.ads_execute_direct(conn, sql)
|
37
|
+
puts "RS: #{rs.inspect}"
|
38
|
+
|
39
|
+
record = []
|
40
|
+
if (api.ads_num_cols(rs) > 0)
|
41
|
+
while api.ads_fetch_next(rs) == 1
|
42
|
+
max_cols = api.ads_num_cols(rs)
|
43
|
+
result = Hash.new()
|
44
|
+
max_cols.times do |cols|
|
45
|
+
result[api.ads_get_column_info(rs, cols)[2]] = api.ads_get_column(rs, cols)[1]
|
46
|
+
end
|
47
|
+
record << result
|
48
|
+
end
|
49
|
+
@affected_rows = 0
|
50
|
+
else
|
51
|
+
@affected_rows = api.ads_affected_rows(rs)
|
52
|
+
end
|
53
|
+
puts "RECORD: #{record.inspect}"
|
54
|
+
|
55
|
+
# disconnect from the database
|
56
|
+
puts api.ads_disconnect(conn).inspect
|
57
|
+
|
58
|
+
# free the connection resources
|
59
|
+
api.ads_free_connection(conn)
|
60
|
+
|
61
|
+
# free resources the api object uses
|
62
|
+
api.ads_fini()
|
63
|
+
|
64
|
+
# close the interface
|
65
|
+
Advantage::API.ads_finalize_interface(api)
|
66
|
+
|
67
|
+
puts "finished"
|
data/test/mytest3.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
begin
|
2
|
+
require "rubygems"
|
3
|
+
require "advantage"
|
4
|
+
unless defined? Advantage
|
5
|
+
# require 'advantage'
|
6
|
+
if RUBY_VERSION >= "1.9"
|
7
|
+
require_relative "../lib/advantage/advantage.so"
|
8
|
+
else
|
9
|
+
require File.join(File.dirname(__FILE__), "../lib/advantage/advantage.so")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# create an interface
|
15
|
+
api = Advantage::AdvantageInterface.new()
|
16
|
+
#
|
17
|
+
# initialize the interface (loads the DLL/SO)
|
18
|
+
Advantage::API.ads_initialize_interface(api)
|
19
|
+
#
|
20
|
+
# initialize our api object
|
21
|
+
api.ads_init()
|
22
|
+
|
23
|
+
# create a connection
|
24
|
+
conn = api.ads_new_connection()
|
25
|
+
|
26
|
+
# establish a connection
|
27
|
+
conn_str = "data source=//172.27.144.1:6262/c\$/ads/db/;user id=adssys;DateFormat=YYYY-MM-DD;CommType=TCP_IP;Compression=INTERNET"
|
28
|
+
# conn_str = "data source=//10.0.0.4:6262/aislims/db/;user id=adssys;DateFormat=YYYY-MM-DD;CommType=TCP_IP;"
|
29
|
+
val = api.ads_connect(conn, conn_str)
|
30
|
+
puts "VAL: #{val.inspect}"
|
31
|
+
|
32
|
+
# execute a query without a result set
|
33
|
+
# puts api.ads_execute_immediate(conn, "select 'Successful Ruby Connection' from system.iota;").inspect
|
34
|
+
#sql = "select 'Successful Ruby Connection' from system.iota;"
|
35
|
+
#sql = "EXECUTE PROCEDURE sp_GetTables( NULL, NULL, NULL, 'TABLE' );"
|
36
|
+
sql = 'SELECT COUNT(*) FROM "DISCOUNT";'
|
37
|
+
rs = api.ads_execute_direct(conn, sql)
|
38
|
+
puts "RS: #{rs.inspect}"
|
39
|
+
|
40
|
+
row_record = []
|
41
|
+
cols = []
|
42
|
+
acols = api.ads_num_cols(rs)
|
43
|
+
puts "ACOLS: #{acols.inspect}"
|
44
|
+
|
45
|
+
#if( api.ads_num_cols(rs) > 0)
|
46
|
+
puts "HOORAY!"
|
47
|
+
loop do
|
48
|
+
fetch = api.ads_fetch_next(rs)
|
49
|
+
puts "FETCH: #{fetch.inspect}"
|
50
|
+
break if fetch == 0
|
51
|
+
max_cols = api.ads_num_cols(rs)
|
52
|
+
puts "MAX_COLS: #{max_cols.inspect}"
|
53
|
+
max_cols = api.ads_num_cols(rs)
|
54
|
+
row = []
|
55
|
+
max_cols.times do |cols|
|
56
|
+
# result[api.ads_get_column_info(rs, cols)[2]] = api.ads_get_column(rs, cols)[1]
|
57
|
+
cinfo = api.ads_get_column_info(rs, cols)
|
58
|
+
cols << cinfo[2].to_s
|
59
|
+
cvalue = api.ads_get_column(rs, cols)[1]
|
60
|
+
cvalue = "0.0" if cinfo[3] == 13 and cvalue.rstrip == ""
|
61
|
+
cvalue.rstrip! if cinfo[3] == 2 and cvalue
|
62
|
+
row << cvalue
|
63
|
+
end
|
64
|
+
row_record << row
|
65
|
+
#end
|
66
|
+
#else
|
67
|
+
#puts "BOO!"
|
68
|
+
end
|
69
|
+
api.ads_free_stmt(rs)
|
70
|
+
puts "RECORD: #{record.inspect}"
|
71
|
+
|
72
|
+
# disconnect from the database
|
73
|
+
puts api.ads_disconnect(conn).inspect
|
74
|
+
|
75
|
+
# free the connection resources
|
76
|
+
api.ads_free_connection(conn)
|
77
|
+
|
78
|
+
# free resources the api object uses
|
79
|
+
api.ads_fini()
|
80
|
+
|
81
|
+
# close the interface
|
82
|
+
Advantage::API.ads_finalize_interface(api)
|
83
|
+
|
84
|
+
puts "finished"
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: advantage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Edgar Sherman
|
8
|
+
- Jon Adams
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-11-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.17'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.17'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake-compiler
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.1'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.1'
|
70
|
+
description: Advantage Database Driver for Ruby
|
71
|
+
email:
|
72
|
+
- advantage@sybase.com
|
73
|
+
- t12nslookup@googlemail.com
|
74
|
+
executables: []
|
75
|
+
extensions:
|
76
|
+
- ext/advantage/extconf.rb
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- LICENSE
|
80
|
+
- README
|
81
|
+
- Rakefile
|
82
|
+
- advantage.gemspec
|
83
|
+
- ext/advantage/ace.h
|
84
|
+
- ext/advantage/adscapidll.c
|
85
|
+
- ext/advantage/adscapidll.h
|
86
|
+
- ext/advantage/advantage.c
|
87
|
+
- ext/advantage/dbcapi.cpp
|
88
|
+
- ext/advantage/dbcapi.h
|
89
|
+
- ext/advantage/extconf.rb
|
90
|
+
- test/advantage/advantage_test.rb
|
91
|
+
- test/advantage/test.sql
|
92
|
+
- test/mytest.rb
|
93
|
+
- test/mytest2.rb
|
94
|
+
- test/mytest3.rb
|
95
|
+
homepage: http://devzone.advantagedatabase.com
|
96
|
+
licenses:
|
97
|
+
- Apache-2.0
|
98
|
+
metadata:
|
99
|
+
allowed_push_host: https://rubygems.org
|
100
|
+
homepage_uri: http://devzone.advantagedatabase.com
|
101
|
+
source_code_uri: https://github.com/t12nslookup/advantage/
|
102
|
+
changelog_uri: https://github.com/t12nslookup/advantage/blob/master/CHANGELOG.md
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubygems_version: 3.1.2
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: Advantage Database library for Ruby
|
122
|
+
test_files: []
|