Database Administrators
Q&A for database professionals who wish to improve their database skills
Latest Questions
0
votes
1
answers
600
views
Connecting to SAP ASE fails
ALL, igor@IgorReinCloud ~ $ cat /etc/unixODBC/odbc.ini [Sybase16] Driver=Sybase Description=Sybase 16 Native Driver Trace=Yes Server=REINCLOUD Database=draft TraceLog=/tmp/sql.log Port=5000 UserID=sa igor@IgorReinCloud ~ $ cat /etc/unixODBC/odbcinst.ini [ODBC] Trace=yes TraceFile=/tmp/sql.log [Sybas...
ALL,
igor@IgorReinCloud ~ $ cat /etc/unixODBC/odbc.ini
[Sybase16]
Driver=Sybase
Description=Sybase 16 Native Driver
Trace=Yes
Server=REINCLOUD
Database=draft
TraceLog=/tmp/sql.log
Port=5000
UserID=sa
igor@IgorReinCloud ~ $ cat /etc/unixODBC/odbcinst.ini
[ODBC]
Trace=yes
TraceFile=/tmp/sql.log
[Sybase]
Description=Native Sybase Driver
Driver=/opt/sap/DataAccess/ODBC/lib/libsybdrvodb.so
FileUsage=1
igor@IgorReinCloud ~ $ ls -la /opt/sap/DataAccess/ODBC/lib/
total 8388
drwxrwxr-x 3 root root 4096 Nov 15 17:46 .
drwxrwxr-x 6 root root 4096 Nov 15 17:46 ..
-rwxr-xr-x 1 root root 4691399 Aug 28 2017 libsapcrypto.so
-rwxr-xr-x 1 root root 416329 Aug 28 2017 libslcryptokernel.so
-rwxr-xr-x 1 root root 166 Aug 28 2017 libslcryptokernel.so.sha256
-rwxr-xr-x 1 root root 3459940 Aug 28 2017 libsybdrvodb.so
drwxrwxr-x 5 root root 4096 Nov 15 17:46 locales
igor@IgorReinCloud ~ $ isql Sybase16 sa
[ISQL]ERROR: Could not SQLConnect
igor@IgorReinCloud ~ $ cat /tmp/sql.log
[ODBC][1609181009.277918][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/__handles.c]
Exit:[SQL_SUCCESS]
Environment = 0x55eac5c98a00
[ODBC][1609181009.278029][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLAllocHandle.c]
Entry:
Handle Type = 2
Input Handle = 0x55eac5c98a00
[ODBC][1609181009.278075][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLAllocHandle.c]
Exit:[SQL_SUCCESS]
Output Handle = 0x55eac5c99b90
[ODBC][1609181009.278132][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLConnect.c]
Entry:
Connection = 0x55eac5c99b90
Server Name = [Sybase16][length = 8 (SQL_NTS)]
User Name = [sa][length = 2 (SQL_NTS)]
Authentication = [******][length = 6 (SQL_NTS)]
UNICODE Using encoding ASCII 'UTF8' and UNICODE 'UTF16LE'
[ODBC][1609181009.281022][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLConnect.c]Can't open lib '/opt/sap/DataAccess/ODBC/lib/libsybdrvodb.so' : file not found
[ODBC][1609181009.281164][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLFreeHandle.c]
Entry:
Handle Type = 2
Input Handle = 0x55eac5c99b90
[ODBC][1609181009.281215][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLFreeHandle.c]
Exit:[SQL_SUCCESS]
[ODBC][1609181009.281259][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLFreeHandle.c]
Entry:
Handle Type = 1
Input Handle = 0x55eac5c98a00
I don't understand this error.
File does exist, it has
read/execute
permissions and AFAIU, I don't need to set sybase environment to get an ODBC connection from unixODBC isql.
Connecting with SAP DBISQL
works fine.
Could someone please help?
Thank you.
EDIT:
After fixing couple of bugs in my code, here is the odbc log file after running my code.
I'm trying to connect to SAP ASE 16 instance.
[ODBC][1612492650.771991][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/__handles.c]
Exit:[SQL_SUCCESS]
Environment = 0x564ee933ab90
[ODBC][1612492650.772100][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLSetEnvAttr.c]
Entry:
Environment = 0x564ee933ab90
Attribute = SQL_ATTR_ODBC_VERSION
Value = 0x3
StrLen = 0
[ODBC][1612492650.772141][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLSetEnvAttr.c]
Exit:[SQL_SUCCESS]
[ODBC][1612492650.772187][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLDataSourcesW.c]
Entry:
Environment = 0x564ee933ab90
[ODBC][1612492650.782200][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLDataSourcesW.c]
Exit:[SQL_SUCCESS]
[ODBC][1612492650.782328][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLDataSourcesW.c]
Entry:
Environment = 0x564ee933ab90
[ODBC][1612492650.782809][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLDataSourcesW.c]
Exit:[SQL_SUCCESS]
[ODBC][1612492650.782879][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLDataSourcesW.c]
Entry:
Environment = 0x564ee933ab90
[ODBC][1612492650.783125][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLDataSourcesW.c]
Exit:[SQL_SUCCESS]
[ODBC][1612492650.783171][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLFreeHandle.c]
Entry:
Handle Type = 1
Input Handle = 0x564ee933ab90
[ODBC][1612492666.505105][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/__handles.c]
Exit:[SQL_SUCCESS]
Environment = 0x564ee9426000
[ODBC][1612492666.505220][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLSetEnvAttr.c]
Entry:
Environment = 0x564ee9426000
Attribute = SQL_ATTR_ODBC_VERSION
Value = 0x3
StrLen = -6
[ODBC][1612492666.505261][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLSetEnvAttr.c]
Exit:[SQL_SUCCESS]
[ODBC][1612492666.505302][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLAllocHandle.c]
Entry:
Handle Type = 2
Input Handle = 0x564ee9426000
[ODBC][1612492666.505348][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLAllocHandle.c]
Exit:[SQL_SUCCESS]
Output Handle = 0x564ee9236e00
[ODBC][1612492666.505390][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLDataSourcesW.c]
Entry:
Environment = 0x564ee9426000
[ODBC][1612492666.505718][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLDataSourcesW.c]
Exit:[SQL_SUCCESS]
[ODBC][1612492666.505785][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLSetConnectAttrW.c]
Entry:
Connection = 0x564ee9236e00
Attribute = SQL_ATTR_LOGIN_TIMEOUT
Value = 0x5
StrLen = 0
[ODBC][1612492666.505828][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLSetConnectAttrW.c]
Exit:[SQL_SUCCESS]
[ODBC][1612492666.505875][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLDriverConnectW.c]
Entry:
Connection = 0x564ee9236e00
Window Hdl = 0x564ee9268260
Str In = [DSN=Sybase16;Driver=Sybase;UID=sa;PWD=*redacted*][length = 44 (SQL_NTS)]
Str Out = 0x564ee947d5a0
Str Out Max = 1024
Str Out Ptr = 0x7fffced2eb98
Completion = 0
UNICODE Using encoding ASCII 'UTF8' and UNICODE 'UTF16LE'
[ODBC][1612492666.522916][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLDriverConnectW.c]
Exit:[SQL_ERROR]
[ODBC][1612492666.523100][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLGetDiagRecW.c]
Entry:
Connection = 0x564ee9236e00
Rec Number = 1
SQLState = 0x7fffced2e710
Native = 0x7fffced2e6c4
Message Text = 0x7fffced2e740
Buffer Length = 1024
Text Len Ptr = 0x7fffced2e6bc
[ODBC][1612492666.523238][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLGetDiagRecW.c]
Exit:[SQL_SUCCESS]
SQLState = [01S00]
Native = 0x7fffced2e6c4 -> 30011
Message Text = [[SAP][ASE ODBC Driver]Invalid port number]
[ODBC][1612492666.523381][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLGetDiagRecW.c]
Entry:
Connection = 0x564ee9236e00
Rec Number = 2
SQLState = 0x7fffced2e710
Native = 0x7fffced2e6c4
Message Text = 0x7fffced2e740
Buffer Length = 1024
Text Len Ptr = 0x7fffced2e6bc
[ODBC][1612492666.523429][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLGetDiagRecW.c]
Exit:[SQL_NO_DATA]
[ODBC][1612492670.055754][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLGetConnectAttrW.c]
Entry:
Connection = 0x564ee9236e00
Attribute = 1209
Value = 0x7fffced310f8
Buffer Length = 0
StrLen = 0x7fffced310f0
[ODBC][1612492670.055861][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLGetConnectAttrW.c]Error: 08003
[ODBC][1612492670.055930][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLGetDiagRecW.c]
Entry:
Connection = 0x564ee9236e00
Rec Number = 1
SQLState = 0x7fffced30c70
Native = 0x7fffced30c24
Message Text = 0x7fffced30ca0
Buffer Length = 1024
Text Len Ptr = 0x7fffced30c1c
[ODBC][1612492670.055998][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLGetDiagRecW.c]
Exit:[SQL_SUCCESS]
SQLState =
Native = 0x7fffced30c24 -> 0
Message Text = [[unixODBC][Driver Manager]Connection not open]
[ODBC][1612492670.056064][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLGetDiagRecW.c]
Entry:
Connection = 0x564ee9236e00
Rec Number = 2
SQLState = 0x7fffced30c70
Native = 0x7fffced30c24
Message Text = 0x7fffced30ca0
Buffer Length = 1024
Text Len Ptr = 0x7fffced30c1c
[ODBC][1612492670.056107][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLGetDiagRecW.c]
Exit:[SQL_NO_DATA]
[ODBC][1612492670.056158][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLFreeHandle.c]
Entry:
Handle Type = 2
Input Handle = 0x564ee9236e00
[ODBC][1612492670.056209][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLFreeHandle.c]
Exit:[SQL_SUCCESS]
[ODBC][1612492670.056253][/var/tmp/portage/dev-db/unixODBC-2.3.5-r1/work/unixODBC-2.3.5/DriverManager/SQLFreeHandle.c]
Entry:
Handle Type = 1
Input Handle = 0x564ee9426000
Asking around I've been told that I need to modify the interfaces
file so that the clients will not be using it but instead will be using ODBC interface.
This is my interfaces file:
REINCLOUD
master tcp ether localhost 5000
query tcp ether localhost 5000
REINCLOUD_BS
master tcp ether localhost 5001
query tcp ether localhost 5001
REINCLOUD_XP
master tcp ether localhost 5002
query tcp ether localhost 5002
REINCLOUD_JSAGENT
master tcp ether localhost 4900
query tcp ether localhost 4900
Sorry for such a huge post.
Could anyone explain what is going on and why I can't connect neither with isql, nor with my program?
Igor
(247 rep)
Dec 28, 2020, 06:47 PM
• Last activity: May 6, 2025, 03:04 AM
-2
votes
1
answers
311
views
SQL: Running total with group by
I have a dataset that has two date columns for each transaction. An invoice date and a charge date. I am trying to do a cumulative or running total of the table in sql. Data table looks like this: InvoiceDate ChargeDate TransactionID ----------- ---------- ------------- jan/1/2021 jan/1/2021 11111 j...
I have a dataset that has two date columns for each transaction. An invoice date and a charge date. I am trying to do a cumulative or running total of the table in sql.
Data table looks like this:
InvoiceDate ChargeDate TransactionID
----------- ---------- -------------
jan/1/2021 jan/1/2021 11111
jan/1/2021 jan/1/2021 55555
jan/1/2021 Feb/1/2021 11111
jan/1/2021 Feb/1/2021 22222
jan/1/2021 Feb/1/2021 33333
jan/1/2021 Feb/1/2021 44444
Feb/1/2021 jan/1/2021 11111
Feb/1/2021 jan/1/2021 22222
Feb/1/2021 jan/1/2021 33333
Feb/1/2021 jan/1/2021 44444
Feb/1/2021 Feb/1/2021 55555
I want the output in this format:
InvoiceDate ChargeDate cumulativeCount
----------- ---------- ---------------
jan/1/2021 jan/1/2021 2
jan/1/2021 Feb/1/2021 5
Feb/1/2021 jan/1/2021 4
Feb/1/2021 Feb/1/2021 5
I tried the following code but it doesn't give me a running total. it gives me total of each of the two columns
select
chargeDate,
InvoiceDate,
Count(Distinct TransactionID) as CountofIDs
from mytable1
where InvoiceDate<=InvoiceDate
group by ChargeDate, InvoiceDate
Rishtin
(1 rep)
Jul 26, 2021, 04:42 PM
• Last activity: Jul 27, 2021, 10:02 PM
0
votes
1
answers
173
views
BDBID in DBCC PAGE command output in SQL Server
There is a famous undocumented DBCC PAGE command in SQL Server (as well as in SAP ASE) which if successful sends output to errorlog. Noticed that it has 4 main sections: Buffer, Page Header, Data, and Offset Table. The question is we notice dbid in the Page Header section. Similarly, there is a bdbi...
There is a famous undocumented DBCC PAGE command in SQL Server (as well as in SAP ASE) which if successful sends output to errorlog.
Noticed that it has 4 main sections: Buffer, Page Header, Data, and Offset Table.
The question is we notice dbid in the Page Header section.
Similarly, there is a bdbid in the buffer section.
Can we unquestionably say that both these ids will be the same? If anyone has experience around these.
For reference: https://techcommunity.microsoft.com/t5/sql-server/how-to-use-dbcc-page/ba-p/383094 https://www.itprotoday.com/sql-server/using-dbcc-page
Sonali Gupta
(99 rep)
Feb 25, 2021, 09:45 AM
• Last activity: Feb 25, 2021, 10:28 AM
0
votes
1
answers
1689
views
Map login to user in restored database in SYBASE ASE 16
After restoring a database from other environment is there a way to map a user in the database to a login in the server. I can drop and recreate or alias but in **MS SQL Server** there is a way: `EXEC sp_change_users_login 'Auto_Fix', 'user'` I was looking for something similar in **SYBASE ASE 16**
After restoring a database from other environment is there a way to map a user in the database to a login in the server. I can drop and recreate or alias but in **MS SQL Server** there is a way:
EXEC sp_change_users_login 'Auto_Fix', 'user'
I was looking for something similar in **SYBASE ASE 16**
PeterJL
(95 rep)
Jan 8, 2021, 05:01 PM
• Last activity: Jan 9, 2021, 12:56 AM
1
votes
1
answers
1690
views
Equivalent of varchar(max) in ASE
What is the equivalent of SQL Server's `varchar(max)` data type in ASE? By ASE I mean what used to be known as Sybase ASE, which is now owned by SAP. I'm attempting to execute a piece of dynamically constructed T-SQL that is longer than 8,000 chars. If I declare a variable with `varchar(max)`, ASE c...
What is the equivalent of SQL Server's
varchar(max)
data type in ASE?
By ASE I mean what used to be known as Sybase ASE, which is now owned by SAP.
I'm attempting to execute a piece of dynamically constructed T-SQL that is longer than 8,000 chars.
If I declare a variable with varchar(max)
, ASE chokes with:
Incorrect syntax near the keyword 'max'.My next thought was to try the
text
datatype. But alas:
You specified an incorrect datatype for the variable containing the 'execute immediate' command string.A minimal, complete, and verifiable example:
DECLARE @cmd varchar(max) --change this to varchar(4000) and it works
SET @cmd = 'SELECT 1;'
EXEC (@cmd);
GO
Changing the variable declaration to text
or whatever will suit your purposes. I need to execute a dynamic command that is probably 50,000 characters long.
Alternately, I could use a cursor, but I am unfamiliar with how cursors work on ASE.
Note that in SQL Anywhere, you can define an equivalent to the varchar(max) datatype as declare @cmd long varchar;
, however that won't work in ASE.
Hannah Vernon
(70988 rep)
Oct 19, 2020, 09:16 PM
• Last activity: Oct 28, 2020, 02:45 AM
1
votes
0
answers
44
views
Do any databases other than SAP ASE support key custodians?
[SAP Sybase ASE](https://www.sap.com/products/sybase-ase.html) supports the notion of a [key custodian](https://help.sap.com/viewer/3542b1cbbec34816b0b36cf19c760659/16.0.2.2/en-US/a7d5a3fdbc2b1014ace1b2a66212286b.html). This allows for a setup where the trust can be split between two roles: the data...
[SAP Sybase ASE](https://www.sap.com/products/sybase-ase.html) supports the notion of a [key custodian](https://help.sap.com/viewer/3542b1cbbec34816b0b36cf19c760659/16.0.2.2/en-US/a7d5a3fdbc2b1014ace1b2a66212286b.html) . This allows for a setup where the trust can be split between two roles: the database administrator and a key custodian. The database administrator has the privileges to create user accounts and give them privileges on tables and accounts, whereas the key custodian only has the ability to create and assigns encryption keys to users. Hence neither of these roles by themselves can create a full set of credentials that would allow access the data stored in the database. This capability is wonderful in low trust environments.
I get the sense that SAP ASE is no longer a priority at SAP. This might be totally wrong, and is only based on the fact that I am predominantly seeing HANA being pushed these days. I am therefore looking for other database systems that have an equivalent capability.
So far I haven't been able to find any database where it isn't the admin that in one way or another has the task of creating encryption keys as well.
Are there other database servers with an equivalent functionality that I have missed? I would really appreciate any guidance and tips!
Thank you!
Sebastian Probst Eide
(11 rep)
Feb 7, 2018, 04:46 PM
-1
votes
1
answers
1874
views
How to move databases to another drive in same server for sybase ASE 16 on windows.
I am trying to move sybase user database from one drive to another drive, can you please help me with procedure. My database : Sybase ASE 16 OS windows.
I am trying to move sybase user database from one drive to another drive, can you please help me with procedure.
My database : Sybase ASE 16
OS windows.
datalearner
(11 rep)
Aug 2, 2017, 02:43 PM
• Last activity: Aug 2, 2017, 08:31 PM
1
votes
2
answers
4658
views
How to find locking schema for set of tables in database?
There are some 20 tables in a database of **Sybase instance**, where i need to find the locking schema of tables. Once locking schema is found, i need to compare it in other database which also have same 20 tables. build-ASE16 SP2
There are some 20 tables in a database of **Sybase instance**, where i need to find the locking schema of tables.
Once locking schema is found, i need to compare it in other database which also have same 20 tables.
build-ASE16 SP2
user115806
(51 rep)
Sep 19, 2016, 07:47 PM
• Last activity: Oct 13, 2016, 06:19 PM
Showing page 1 of 8 total questions