Quantcast
Channel: Sybase – Jason L. Froebe – Tech tips and How Tos for Fellow Techies
Viewing all 102 articles
Browse latest View live

SAP Sybase ASE MDA Tables: Why is the OwnerName and OwnerID omitted in most of the MDA tables?

$
0
0

If you look SAP Sybaseat the MDA poster, you will find the object names, the database names and the like but not the owner_id or owner_name. Let’s pick on monOpenObjectActivity, one of the most heavily used mda tables

Having monOpenObjectActivity is great but what if I have two tables named the same in the same database with a different owner? Such a scenario is not uncommon in a development system when having a separate database for each developer is not practical.

A row in monOpenObjectActivity could be mydb.john.table_a or mydb.jane.table_a. While I do have the object id, there is no owner_name(DBID, OBJID) function, so I need to go into each individual database and query sysobjects. What a hassle! ASE already knows, or should know, which owner id the object belongs to so why need I have to create a dynamic query for each and every row in monOpenObjectActivity? Sure, I could create a look up table but it wouldn’t be able to handle temporary objects (e.g. #table) very well.

The following tables have Owner something in the column names:

1> select convert(varchar(30), object_name(id)) as "Object Name", convert(varchar(30), name) as "Column Name" from syscolumns where lower(name) like "%owner%"
2> go
Object Name                    Column Name
------------------------------ ------------------------------
monProcessObject               OwnerUserID
monCachedProcedures            OwnerUID
monCachedProcedures            OwnerName
monProcessProcedures           OwnerUID
monSpinlockActivity            OwnerPID
monSpinlockActivity            LastOwnerPID
monMemoryUsage                 PoolOwnerKPID
monProcessProcedures           OwnerName
monCachedObject                OwnerUserID
monCachedObject                OwnerName
sp_namecrack                   @owner

I think we need two functions: owner_name(DBID, OBJID) and owner_id(DBID, OBJID)

We also need the OwnerID and preferrably OwnerName added to the appropriate MDA tables.

What do you think?


If you’re an author of technical books, please ensure that your publisher and/or editor typesets your book contents to be readable.

$
0
0

If you’re an author of technical books, please ensure that your publisher and/or editor typesets your book contents to be readable. Especially tables and program outputs. Just because the application can’t format the output worth a damn, doesn’t mean you need to transfer it to a book:

Example from Sybase 15.0 Replication Server Administration
book_output

SAP Sybase IQ: Free “Getting started with SAP Sybase IQ server” mini course!

$
0
0

SAP Sybase has recently made available a mini course called “Getting started with SAP Sybase IQ server” for you to learn IQ, a major data warehouse product. Do yourself a favor and learn IQ. There aren’t enough IQ DBAs in the world… YET!

SAP SybaseGetting started with SAP Sybase IQ server

This how-to booklet will help you learn the basics and get started with SAP Sybase IQ as quickly as possible. You do not need to go through all of the lessons. After completing the first three sections you will have a running SAP Sybase IQ database (Don’t worry…the course comes with a database schema and data ready to load).

You can then pick and choose from the remaining lessons, based on your interest:

Please download the zip file for all the ” Metadata, Data and Queries for Lessons in the Quick Start Guide ”

To benefit from this book, you should be familiar with the following concepts:

  • Relational database systems
  • Database schemas
  • SQL

HOWTO: Install SAP Sybase Control Center 3.2.7 on Windows 8

$
0
0

SAP/Sybase doesn’t SAP Sybaseofficially support running SCC on Windows 8. This seems to be more of an issue with the InstallShield installer. Seriously, why do people still use InstallShield??

If you try installing SCC 3.2x on Windows 8, you’ll get a nasty error when you run setup.exe or setupconsole.exe:

scc_setup

scc_setup_details

You *can* install and run SCC 3.2.x on Windows 8 if you are willing to run the 32bit version of SCC. You will need to install Microsoft C++ 2005 SP1 x86.

Next, open a cmd.exe as Administrator and run “setup.exe -i gui”

Sybase ASE: Adding log to a completely log full database – errors 1105 and 3475 “There is no space available in SYSLOGS”– SOLVED

$
0
0

When SAP Sybasea sybase database’s log is completely full, you won’t be able to add any log space to it. Attempting to add to the log produces a 3475 error:
 

00:0006:00000:00001:2014/01/08 09:03:09.09 server  ERROR: Can't get a new log page in db 4. num_left=17 num_in_plc=17.
00:0006:00000:00001:2014/01/08 09:03:09.09 server  Error: 1105, Severity: 17, State: 7
00:0006:00000:00001:2014/01/08 09:03:09.09 server  Can't allocate space for object 'syslogs' in database 'mydb' because 'logsegment' segment is full/has no free extents. If you ran out of space in syslo
gs, dump the transaction log. Otherwise, use ALTER DATABASE to increase the size of the segment.
00:0006:00000:00001:2014/01/08 09:03:09.09 server  Error: 3475, Severity: 21, State: 7
00:0006:00000:00001:2014/01/08 09:03:09.09 server  There is no space available in SYSLOGS to log a record for which space has been reserved in database 'mydb' (id 4). This process will retry at interval
s of one minute.

 
So what to do? If you separate your data and log segments, you will need to temporarily add the log segment to a data device so the database can recover. Once it recovers, we can add space to the log and remove the log segment from the data device. For good measure, we run dbccs to correct any allocation issues that may be contributing to the out of log space.
 
Add the log segment to a data device (use sp_helpdb dbname to determine which data device has space):

exec sp_configure "allow updates", 1
go
update sysusages set segmap = 7 where dbid = 4 and lstart = 1492992
go
checkpoint
go
shutdown with nowait
go

Add space to the log:

alter database mydb log on mydevicel001 = 500
go

 
Before we do anything else, let’s run dbccs. Of course, you will want to run the dbccs without the fix option to identify if there are other issues prior to running with the fix:

exec kill_user_connections mydb
exec kill_user_connections mydb
exec kill_user_connections mydb
exec kill_user_connections mydb
exec kill_user_connections mydb
exec sp_dboption mydb, 'dbo use', true
exec sp_dboption mydb, 'single user', true
dbcc traceon(3604)
dbcc checkdb(mydb, fix_spacebits)
dbcc checkalloc(mydb, fix)
exec sp_dboption mydb, 'dbo use', false
exec sp_dboption mydb, 'single user', false
go

If no lingering issues, we can remove the log segment from the data device:

exec sp_dboption mydb, 'single user', true
go
use mydb
go
exec sp_dropsegment logsegment, mydb, mydeviced005
go
use master
go
exec sp_dboption mydb, 'single user', false
go

SAP is fixing Bug CR 756957 in ASE 15.7 SP110 that may be the root cause of the 3475 error:

In certain circumstances, databases, including system databases, can incorrectly get into LOG SUSPEND mode, issuing message: “Space available in the log segment has fallen critically low in database ‘ < dbname > ‘. All future modifications to this database will be suspended until the log is successfully dumped and space becomes available.” This may happen even though there is much unreserved space in the database. The problem may also manifest in 3475 errors: “There is no space available in SYSLOGS to log a record for which space has been reserved in database < dbname > .”

SAP Sybase IQ: How many connections are in use? SOLVED

$
0
0

Very simple question. Very simple answer.

select 
    @@max_connections as 'max_connections', 
    count(*) as 'active_connections', 
    (1 - (@@max_connections - count(*)) / convert(numeric, @@max_connections)) * 100 as 'percent_active' 
  from sp_iqconnection();

Output:

 max_connections active_connections percent_active
 --------------- ------------------ ---------------------
             350                 68               19.4286

@@max_ connections: For the network server, the maximum number of active clients (not database connections, as each client can support multiple connections). For Adaptive Server Enterprise, the maximum number of connections to the server. — Sybase IQ > Reference: Building Blocks, Tables, and Procedures > SQL Language Elements > Variables

SAP SYBASE IQ 16.0 SP8 MANUALS FIXED TO WORK WITH TABLET/PHONE PDF READERS LIKE ALDIKO

$
0
0

Aldiko Book Reader Premium Full v2.2.3.apkMany PDF readers for smart phones (Android/iphone) and tablets manage the pdf files Calibre_Logobased solely on the Title and Author fields in the PDF file. While for this is fine for your average book, it is not all that helpful with manuals that tend to have abbreviated or no data in the title/author fields. In the case of the manuals for Sybase IQ, I’m unable to load the manuals for say v15.4 and v16.0 as they have the same Title/Author data.

How to fix? Easy. Go get Calibre. Drop the PDF files on to the running Calibre. Edit them by hitting the E key.

In my case, I edited the “Title”, “Author”, “Tags”, “Publisher” and “Languages”:

Calibre

Calibre doesn’t modify the PDF files themselves so I will need to export the files to a custom directory. In Calibre nomenclature, this is “Saving”. Highlight all the titles you want to export and hit “S” twice. Why twice? No idea. Choose the directory.

You can now copy the exported PDF files to your phone, tablet, whatever without fear of the v16.0 version of the P&T Guide being rejected by Aldiko because the v15.4 version is already added.

Here are the IQ v16.0 SP8 manuals that I’ve ‘fixed’ to work with Aldiko. They are identical to the PDFs on sybooks with the exception of the PDF fields I mentioned previously.

No copyright infringement is intended. SAP/Sybase, please feel free to take these and host them.

IQ 16.0 SP8 – SAP IQ Cockpit – SAP, Inc_
IQ 16.0 SP8 – Installation and Configuration Guide [ Windows ] – SAP, Inc_
IQ 16.0 SP8 – Installation and Configuration Guide [ Solaris ] – SAP, Inc_
IQ 16.0 SP8 – Installation and Configuration Guide [ HP-UX ] – SAP, Inc_
IQ 16.0 SP8 – Administration_ User Management and Security – SAP, Inc_
IQ 16.0 SP8 – Reference_ Statements and Options – SAP, Inc_
IQ 16.0 SP8 – User-Defined Functions – SAP, Inc_
IQ 16.0 SP8 – Administration_ In-Memory Row-Level Versioning – SAP, Inc_
IQ 16.0 SP8 – Reference_ Building Blocks, Tables, and Procedures – SAP, Inc_
IQ 16.0 SP8 – Reference_ Programming – SAP, Inc_
IQ 16.0 SP8 – Release Bulletin [ Windows ] – SAP, Inc_
IQ 16.0 SP8 – Release Bulletin [ Linux ] – SAP, Inc_
IQ 16.0 SP8 – Administration_ Multiplex – SAP, Inc_
IQ 16.0 SP8 – What’s New in SAP IQ 16.0 – SAP, Inc_
IQ 16.0 SP8 – Migration [ Windows ] – SAP, Inc_
IQ 16.0 SP8 – Administration_ Load Management – SAP, Inc_
IQ 16.0 SP8 – Guide to Licensed Options – SAP, Inc_
IQ 16.0 SP8 – Migration [ Linux and UNIX ] – SAP, Inc_
IQ 16.0 SP8 – Quick Start [ Windows ] – SAP, Inc_
IQ 16.0 SP8 – Quick Start [ Linux and UNIX ] – SAP, Inc_
IQ 16.0 SP8 – Administration_ Spatial Data – SAP, Inc_
IQ 16.0 SP8 – Performance and Tuning Guide – SAP, Inc_
IQ 16.0 SP8 – Release Bulletin [ IBM AIX ] – SAP, Inc_
IQ 16.0 SP8 – Release Bulletin [ HP-UX ] – SAP, Inc_
IQ 16.0 SP8 – Release Bulletin [ Solaris ] – SAP, Inc_
IQ 16.0 SP8 – Administration_ Database – SAP, Inc_
IQ 16.0 SP8 – Unstructured Data Analytics – SAP, Inc_
IQ 16.0 SP8 – Utility Guide – SAP, Inc_
IQ 16.0 SP8 – Administration_ Backup, Restore, and Data Recovery – SAP, Inc_
IQ 16.0 SP8 – Installation and Configuration Guide [ IBM AIX ] – SAP, Inc_
IQ 16.0 SP8 – Administration_ Globalization – SAP, Inc_
IQ 16.0 SP8 – Installation and Configuration Guide [ Linux ] – SAP, Inc_
IQ 16.0 SP8 – Interactive SQL Guide – SAP, Inc_
IQ 16.0 SP8 – Introduction to SAP IQ – SAP, Inc_

SAP IQ: dbisql is unable to load the SybaseIQ SQLAnywhere plugins. SOLVED!

$
0
0

I recently patched an SAP IQ server to 16.0 SP8 PL30 and ran into an interesting error message when trying to start dbisql:

$ dbisql
Interactive SQL could not load the "SQLAnywhere" plug-in.
Its "ngdbc.jar" file has moved or has been deleted. You will not be able to connect to the databases handled by that plug-in.
Interactive SQL could not load the "SybaseIQ" plug-in.
Its "ngdbc.jar" file has moved or has been deleted. You will not be able to connect to the databases handled by that plug-in.
Interactive SQL could not load the "HANA" plug-in.
Its "ngdbc.jar" file has moved or has been deleted. You will not be able to connect to the databases handled by that plug-in.
Interactive SQL could not load the "GenericODBC" plug-in.
Its "ngdbc.jar" file has moved or has been deleted. You will not be able to connect to the databases handled by that plug-in.
Interactive SQL cannot start because it is not installed correctly. No database plug-ins has been registered.
To fix this problem, you should reinstall the program.

If you scan your IQ directory, you will notice there isn’t a “ngdbc.jar” file. You take a look at another IQ box that is working and it doesn’t have the ngdbc.jar file either. The error message is incorrect. The message should report that it isn’t able to access the saip16.jar (or saip11.jar if you’re on IQ 15.x) and/or the jodbc4.jar file in the $SYBASE/IQ-(IQ RELEASE)/java directory (e.g. $SYBASE/IQ-16_0/java).
Verify that the two files exist and the permissions are correct:

316 -rwxr-xr-x.  1 sybase sybase  320071 Mar 20 14:51 jodbc4.jar
112 -rwxr-xr-x.  1 sybase sybase  112325 Mar 20 14:56 saip16.jar

If everything looks okay and it still gives the error, you will need to re-register the plugins. The first thing is to move the dbisql ‘registry':

$ mv $SYBASE/IQ-(IQ RELEASE)/bin64/dbisql_64.rep $SYBASE/IQ-(IQ RELEASE)/bin64/dbisql_64.rep.old

Next, re-register (for IQ 16):

$ cd $SYBASE/IQ-(IQ RELEASE)/java
$ dbisql -Xregister sa16 SybaseIQ com.sybase.saisqlplugin.IQISQLPlugin "$(pwd)/saip16.jar:$(pwd)/jodbc4.jar"

for IQ 15:

$ cd $SYBASE/IQ-(IQ RELEASE)/java
$ dbisql -Xregister sa11 SybaseIQ com.sybase.saisqlplugin.IQISQLPlugin "$(pwd)/saip11.jar:$(pwd)/jodbc4.jar"

dbisql should now work :)


Wanted: SAP manuals in ePub format

$
0
0

Every time SAP comes out with a new set ofSybase SAP pdf manuals, the meta data has to be corrected. Often the stored titles, description, etc are wildly wrong. Very sloppy and unprofessional for a mega corp the size of SAP.

The ePub book format has been out for many years and has many features that make it tablet, phone, PC, whatever friendly. Reading a SAP manual at night? No problem, change the font color to white on black so you don’t wake your spouse. The font is too small? No problem, choose a larger or different font. You can’t do any of that with a PDF. Try reading the ASE Admin guides on a 4″ iPhone. I dare you. You might as well pour salt in your eye sockets.

SAP Sybase Replication Server ERROR -99999 Severity 5 Values exceed buffer length – SOLVED

$
0
0

Running SAP Sybase SAP SybaseReplication Server has always been interesting and rather frustrating that in its fragility. Today’s lesson is not exactly that clear. Take the following error message:

ERROR #1027 DSI EXEC(104(1) repdb_svr.rep_db) - /dsiutil.c(390)
    Open Client Client-Library error: Error: -99999, Severity 5 -- 'Values exceed buffer length'.
ERROR #5215 DSI EXEC(104(1) repdb_svr.rep_db) - /dsiutil.c(393)
    The interface function 'SQLPrepare' returns FAIL for database 'repdb_svr.rep_db'. The errors are retryable. The DSI thread will restart automatically. See messages from the interface function for more information.

RANT: While Replication Server says it is retryable, it never actually retries.
It is for the DSI connection but which buffer?? Replication Server doesn’t list any “buffers” for the DSI explicitly. There are a myriad of caches for the DSI connection. In the error message I see two hints to narrow it down: “Values exceed” and “SQLPrepare”. The most likely cache candidates, to me, would be the batch size (dsi_cmd_batch_size) and the dynamic sql cache (dynamic_sql_cache_size).
A simple check would be to disable dynamic SQL and see if we get the same error message:

suspend connection to repdb_svr.rep_db
go
alter connection repdb_svr.rep_db set dynamic_sql to 'off'
go
resume connection to repdb_svr.rep_db
go

Within a few seconds, I received the same message, so that wasn’t the culprit. Before we do anything else, let’s reenable the dynamic sql:

suspend connection to repdb_svr.rep_db
go
alter connection repdb_svr.rep_db set dynamic_sql to 'on'
go

That leaves the batch size as the most likely culprit. So let’s increase that and see what happens:

suspend connection to repdb_svr.rep_db
go
admin who, dsi, repdb_svr, rep_db
go
--  record Cmd_batch_size (default is 8192
--  Increase dsi_cmd_batch_size 
alter connection repdb_svr.rep_db set dsi_cmd_batch_size to '32768'
go
resume connection to repdb_svr.rep_db
go

The error message did not reoccur and I see replication moving by monitoring the admin,sqm in rep server and the rs_lastcommit table in the replicate database to ensure we’re moving.

You may ask what changed that would require increasing the batch size. Well, a very large transaction that was trying to insert data that already existed but since not all the data already existed, we needed to change INSERT into DELETE followed by INSERT:

alter connection to repdb_svr.rep_db set dsi_command_convert to 'i2di'

Why would that cause it to go boom? Well, the dsi_command_convert is applied AFTER replication server slices and dices the transactions into batches.

UPDATED: HOWTO: Extract Permissions from SAP Sybase IQ

$
0
0

Back in 2013 I posted a method of extracting the table/view permissions from SAP IQ. With later 15.4 patches and v16 the USER_NAME() function would fail on the grantee column of sys.systableperm. An easy way to extract the users is to simply join the grantee column with sys.sysuser. I broke up the case statement to we don’t have a leading comma in the grant statement: “grant , insert on “. Since we’re dealing with tiny tables, there shouldn’t be any undue harm in simply running each grant generation statement separately and union them (to make dbisql happy for those of you that don’t have multiple results enabled).


    SELECT 'GRANT SELECT ON ' + USER_NAME(st.creator) + '.' + st.table_name + ' TO ' + su.user_name + ';'
    FROM
        sys.systable st,
        sys.systableperm stp,
        sys.sysuser su
    WHERE stp.stable_id = st.table_id
        and su.user_id = stp.grantee
        and stp.selectauth = 'Y'
        and lower(su.user_name) not in ('dba', 'public', 'sys', 'dbo', 'diagnostics', 'rs_systabgroup', 'sa_debug', 'extenv_main', 'extenv_worker', 'sys_spatial_admin_role')
    
    UNION ALL 
    
    SELECT 'GRANT DELETE ON ' + USER_NAME(st.creator) + '.' + st.table_name + ' TO ' + su.user_name + ';'
    FROM
        sys.systable st,
        sys.systableperm stp,
        sys.sysuser su
    WHERE stp.stable_id = st.table_id
        and su.user_id = stp.grantee
        and stp.deleteauth = 'Y'
        and lower(su.user_name) not in ('dba', 'public', 'sys', 'dbo', 'diagnostics', 'rs_systabgroup', 'sa_debug', 'extenv_main', 'extenv_worker', 'sys_spatial_admin_role')
    
    UNION ALL 
    
    SELECT 'GRANT UPDATE ON ' + USER_NAME(st.creator) + '.' + st.table_name + ' TO ' + su.user_name + ';'
    FROM
        sys.systable st,
        sys.systableperm stp,
        sys.sysuser su
    WHERE stp.stable_id = st.table_id
        and su.user_id = stp.grantee
        and stp.updateauth = 'Y'
        and lower(su.user_name) not in ('dba', 'public', 'sys', 'dbo', 'diagnostics', 'rs_systabgroup', 'sa_debug', 'extenv_main', 'extenv_worker', 'sys_spatial_admin_role')
    
    UNION ALL
    
    SELECT 'GRANT ALTER ON ' + USER_NAME(st.creator) + '.' + st.table_name + ' TO ' + su.user_name + ';'
    FROM
        sys.systable st,
        sys.systableperm stp,
        sys.sysuser su
    WHERE stp.stable_id = st.table_id
        and su.user_id = stp.grantee
        and stp.alterauth = 'Y'
        and lower(su.user_name) not in ('dba', 'public', 'sys', 'dbo', 'diagnostics', 'rs_systabgroup', 'sa_debug', 'extenv_main', 'extenv_worker', 'sys_spatial_admin_role')
    
    UNION ALL 
    
    SELECT 'GRANT REFERENCE ON ' + USER_NAME(st.creator) + '.' + st.table_name + ' TO ' + su.user_name + ';'
    FROM
        sys.systable st,
        sys.systableperm stp,
        sys.sysuser su
    WHERE stp.stable_id = st.table_id
        and su.user_id = stp.grantee
        and stp.referenceauth = 'Y'
        and lower(su.user_name) not in ('dba', 'public', 'sys', 'dbo', 'diagnostics', 'rs_systabgroup', 'sa_debug', 'extenv_main', 'extenv_worker', 'sys_spatial_admin_role')
    
    UNION ALL
    
    SELECT 'GRANT INSERT ON ' + USER_NAME(st.creator) + '.' + st.table_name + ' TO ' + su.user_name + ';'
    FROM
        sys.systable st,
        sys.systableperm stp,
        sys.sysuser su
    WHERE stp.stable_id = st.table_id
        and su.user_id = stp.grantee
        and stp.insertauth = 'Y'
        and lower(su.user_name) not in ('dba', 'public', 'sys', 'dbo', 'diagnostics', 'rs_systabgroup', 'sa_debug', 'extenv_main', 'extenv_worker', 'sys_spatial_admin_role')

SAP Sybase IQ and ODBC (Linux/UNIX)

$
0
0

Connecting to SAP SAP_IQSybase’s IQ server shouldn’t be scary but the documentation leaves a lot to be desired. Log on to your favorite Linux or Unix box and make sure you source the IQ.sh file wherever you installed the software.

Let’s use the following hypothetical server:

IQ Server:  MyIQboxOfDoom
Port:  5000
Hostname: myiqboxofdoom

If you want a single odbc.ini file for all users, you’ll need to create the file and store it somewhere. Make sure you set the ODBCINI environment variable somewhere (NOT the IQ.sh file as it will but overwritten anytime you patch IQ) to the file. For example: export ODBCINI=/opt/databases/odbc.ini

If you want each user to have their own odbc.ini file, they will need to create the file named as ${HOME}/.odbc.ini The format will be the same as odbc.ini
odbc.ini / .odbc.ini contents:

[MyIQboxOfDoom]
CommLinks=tcpip(ip=myiqboxofdoom;port=5000;DOBROADCAST=NONE;VERIFY=NO)
AutoStop=no

Connecting is a simple matter of:

dbisql -c "dsn=MyIQboxOfDoom;uid=myuser;pwd=mypass" -nogui

Of course you could embed the user in the odbc.ini file like so:

[MyIQboxOfDoom]
CommLinks=tcpip(ip=myiqboxofdoom;port=5000;DOBROADCAST=NONE;VERIFY=NO)
AutoStop=no
uid=myuser

UPDATED: HOWTO: Extract Permissions from SAP Sybase IQ using the LIST() function

$
0
0

Back in August I provided an updated method to extract the permissions for tables in a SAP IQ server. This provided SAP_IQquite a few GRANT statements to execute. If you have thousands of tables and/or thousands of users, the created a large file that can take a while to execute. We can reduce the number of GRANT statements by combining the SELECT, DELETE, UPDATE, ALTER, REFERENCE and INSERT grants into a single GRANT statement with the LIST() function.

The LIST() function joins a value from a set of rows with a specified delimiter. Think of this as the equivalent of the Perl JOIN() command.

Take for example the following strings:

VALUE1
VALUE2 
VALUE3

In Perl if you wanted a single string with a comma as the delimiter you would write the following:

my $STRING = join(', ', 'VALUE1', 'VALUE2', 'VALUE3');
print "$STRING\n";
VALUE1, VALUE2, VALUE3

In IQ we can do the equivalent with the LIST() function:

CREATE TABLE #test (column_a CHAR(6));
INSERT INTO #test VALUES ('VALUE1');
INSERT INTO #test VALUES ('VALUE2');
INSERT INTO #test VALUES ('VALUE3');

SELECT LIST(column_a, ', ') FROM #test;
VALUE1, VALUE2, VALUE3

The extract permissions for IQ tables code as updated to use the LIST() function:

SELECT 'GRANT ' 
    + LIST ( stp.auth, ', ' )
    + ' ON '
    + USER_NAME(st.creator)
    + '.'
    + st.table_name
    + ' TO '
    + su.user_name + ';'
FROM
    ( SELECT grantee, stable_id, 'SELECT' as auth FROM sys.systableperm WHERE selectauth = 'Y'
      UNION ALL
      SELECT grantee, stable_id, 'DELETE' as auth FROM sys.systableperm WHERE deleteauth = 'Y'
      UNION ALL
      SELECT grantee, stable_id, 'UPDATE' as auth FROM sys.systableperm WHERE updateauth = 'Y'
      UNION ALL
      SELECT grantee, stable_id, 'ALTER' as auth FROM sys.systableperm WHERE alterauth = 'Y'
      UNION ALL
      SELECT grantee, stable_id, 'REFERENCE' as auth FROM sys.systableperm WHERE referenceauth = 'Y'
      UNION ALL
      SELECT grantee, stable_id, 'INSERT' as auth FROM sys.systableperm WHERE insertauth = 'Y'
    ) stp,
    sys.systable st,
    sys.sysuser su
WHERE stp.stable_id = st.table_id
    and su.user_id = stp.grantee
    and lower(su.user_name) not in ('dba', 'public', 'sys', 'dbo', 'diagnostics', 'rs_systabgroup', 'sa_debug', 'extenv_main', 'extenv_worker', 'sys_spatial_admin_role')
GROUP BY su.user_name, st.table_name, st.creator

Produces the following SQL output:

GRANT SELECT ON MYUSER.my_table TO otheruser_i;
GRANT DELETE, UPDATE, INSERT, SELECT ON MYUSER.my_table TO otheruser_u;
GRANT DELETE, UPDATE, INSERT, SELECT ON MYUSER.my_table TO otheruser_e;

FW: ASE 15.7: Create a Remote Server to SAP IQ 16.0

SAP IQ: Error: server ‘iq_mpx_1’ was started on an incorrect host ‘myhost1’: this server was created with this connection string ‘host=myhost11:5535’ SOLVED

$
0
0

Recently I built a SAP_IQSAP IQ Multiplex cluster and ran into a self inflicted issue. After I configured the secondary nodes I updated the coordinator node (primary node) with the private (interconnect) and public (what you connect to with an application) connection information. Problem was, I made a small typo and didn’t catch it until after I tried starting the coordinator node.

I configured the coordinator node as such:

alter multiplex server ip_mpx_1 database '/dba/syb/iq_mpx.db' PRIVATE HOST 'node1-clu' PORT 5535 HOST 'myhost11' port 5535;

Upon attempting to start the coordinator node it failed to start with the following message:

MPX: startup failure message: server 'iq_mpx_1' was started on an incorrect host 'myhost1': this server was created with this connection string 'host=myhost11:5535
-- (stcxtlib/st_database.cxx 9455)
Database server shutdown due to startup error

As soon as I saw the message I swore but the fix is quite simple. First, shutdown any secondary nodes. Update your IQ configuration file (or start command line options) so it starts in single node mode and overrides the multiplex configuration:

# single node mode
-iqmpx_sn 1

#For use starting multiplex databases only. Starts the server with override to acknowledge that the write server is starting (1) on a different host, (2) with a different server name, or (3) using a different path to its catalog (.db) file. Do not start two write servers against the same database.
-iqmpx_ov 1

Start the IQ coordinator and reissue the alter multiplex command:

alter multiplex server ip_mpx_1 database '/dba/syb/iq_mpx.db' PRIVATE HOST 'node1-clu' PORT 5535 HOST 'myhost1' port 5535;

Update your IQ configuration file to either remove or comment out the lines we added earlier.

Start up your coordinator. It should now start fine. Please note you will need to resync your secondary nodes before starting them.


HOWTO: SAP Sybase IQ Loading Tables with AutoIncrement/Identity with Zero as a value SOLVED

$
0
0

If the source table has an identity or autoincrement field AND the value starts at zero “0” then load table either server -> server or from file will not work.  IQ is hard coded to reject the rows with the zero value for identity/autoincrement using load table.  Creating a staging table with a numeric field instead of identity/autoincrement will not work with the export file because the export file has the field flagged as an identity/autoincrement field.
 
This isn’t documented anywhere.
 
Workaround/resolution:
1. Extract out the source table
2. Create a staging table using the same DDL as the destination table, swapping the identity/autoincrement field with numeric(10,0)
3. Load the table into the staging table
4. Turn on identity_insert for the destination table

Set temporary option identity_insert= 'destination_table';

5. Insert into destination table from staging table

Insert into destination_table select * from staging_table;

6. Turn off identity_insert for the destination table

Set temporary option identity_insert = '';

7. Drop staging table
8. Rebuild any views that are invalid
FW Howto: List Invalid Views and fix the views in SAP Sybase IQ

HOWTO: SAP IQ Drop Device File from DBSpace

$
0
0

Sometimes when we build an IQ Data Warehouse, our initial space/growth estimate is off significantly enough to warrant reducing the size of the dbspace(s). The process is quite easy put there are a few steps to perform:

Determine how much space is used by the data/indexes. The usage field is the percentage of the totalsize that is being used. For example, the below shows 38% of 4.99TB being used. (4.99 TB * 1024 GB/TB) * 0.38 = 1941.70 GB used:

select convert(varchar(20), DBSpaceName), Usage, TotalSize from sp_iqdbspace() where DBSpaceName = 'IQ_USER_MAIN';
DBSpaceName          Usage TotalSize
------------------------------------
IQ_USER_MAIN         38    4.99T

Determine which device files are part of a dbspace

select convert(varchar(20), DBSpaceName), convert(varchar(20), DBFileName), convert(varchar(70), Path), DBFileSize, Usage from sp_iqfile() where DBSpaceName = 'IQ_USER_MAIN';
DBSpaceName          DBFileName           Path                                                                   DBFileSize Usage
---------------------------------------------------------------------------------------------------------------------------------
IQ_USER_MAIN         IQ_USER_MAIN_FILE_01 /sap/iq/devices/test_usermain001.iq                                    1024G      38
IQ_USER_MAIN         IQ_USER_MAIN_FILE_02 /sap/iq/devices/test_usermain002.iq                                    1024G      38
IQ_USER_MAIN         IQ_USER_MAIN_FILE_03 /sap/iq/devices/test_usermain003.iq                                    1024G      38
IQ_USER_MAIN         IQ_USER_MAIN_FILE_04 /sap/iq/devices/test_usermain004.iq                                    1024G      38
IQ_USER_MAIN         IQ_USER_MAIN_FILE_05 /sap/iq/devices/test_usermain005.iq                                    1024G      34

Verify that the used data will fit in the new allocation

sp_iqdbspace IQ_USER_MAIN

BACKUP DATABASE

backup database FULL to '/backups/test_FULL.dmp';

Alter the file to be dropped to be read only

alter dbspace IQ_USER_MAIN ALTER FILE IQ_USER_MAIN_FILE_05 readonly

Empty the device file (raw device) to be dropped (if dropping more than one file, drop the device file *LEAST* used first)

sp_iqemptyfile 'IQ_USER_MAIN_FILE_05'

Drop the device file (you may need to restart before IQ will let you do this)

ALTER DBSPACE IQ_USER_MAIN DROP FILE IQ_USER_MAIN_FILE_05

Verify the device was dropped

select convert(varchar(20), DBSpaceName), convert(varchar(20), DBFileName), convert(varchar(70), Path), DBFileSize, Usage from sp_iqfile() where DBSpaceName = 'IQ_USER_MAIN';
DBSpaceName          DBFileName           Path                                                                   DBFileSize Usage
---------------------------------------------------------------------------------------------------------------------------------
IQ_USER_MAIN         IQ_USER_MAIN_FILE_01 /sap/iq/devices/test_usermain001.iq                                    1024G      48
IQ_USER_MAIN         IQ_USER_MAIN_FILE_02 /sap/iq/devices/test_usermain002.iq                                    1024G      48
IQ_USER_MAIN         IQ_USER_MAIN_FILE_03 /sap/iq/devices/test_usermain003.iq                                    1024G      45
IQ_USER_MAIN         IQ_USER_MAIN_FILE_04 /sap/iq/devices/test_usermain004.iq                                    1024G      47

SAP IQ: Uptime

$
0
0

At some point you will be asked how long your IQ server has been up.

To determine when the IQ server was started issue:

SELECT PROPERTY('StartTime')

Output:

2015-08-14 18:04:53.918

For the number of days, hours, and minutes we can slice and dice like so:

-- Declarations
DECLARE @UPTIME_DAYS INTEGER
DECLARE @UPTIME_HOURS INTEGER
DECLARE @UPTIME_MINUTES INTEGER

-- Populate variables
SELECT DATEDIFF(day, PROPERTY('StartTime'), CURRENT TIMESTAMP) into @UPTIME_DAYS
SELECT DATEDIFF(hour, PROPERTY('StartTime'), CURRENT TIMESTAMP) % 24 into @UPTIME_HOURS
SELECT DATEDIFF(minute, PROPERTY('StartTime'), CURRENT TIMESTAMP) % 60 into @UPTIME_MINUTES

-- OUTPUT
SELECT @UPTIME_DAYS || ' days ' || @UPTIME_HOURS || ' hours ' || @UPTIME_MINUTES || ' minutes '

Output:

132 days 15 hours 40 minutes

SAP IQ: iqinit error SQLCode: -1000338, SQLState: ‘QDD38’, Severity: 14: Insufficient cache to allocate free list SOLVED

$
0
0

When you create a new IQ v16 instance, you need to use the iqinit program for initial creation of the database.

iqinit -iqpath '/siq/devices/main001.iq' -iqpgsize 131072 -iqblksize 16384 -p 4096 -iqtmppath '/siq/devices/temp001.iqtmp' -dba DBA,SUPER_PASSWORD  -m '/siq/devices/myiq.mir' -o '/siq/log/myiq.iqmsg' -t '/siq/devices/myiq.log' -b -c '/siq/devices/myiq.db'

Occasionally you may run into the SQLCode: -1000338, SQLState: ‘QDD38’, Severity: 14: Insufficient cache to allocate free list error message which basically states the IQ temp cache is too small to start the maintenance IQ instance. The iqinit program is a compiled program that calls the $SYBASE/IQ-16_0/bin64/iqsrv16 program.

SQL Anywhere Initialization Utility Version 16.0.0.809
=============================================================
IQ server starting with:
     10 connections         (       -gm )
    106 cmd resources       ( -iqgovern )
   2459 threads             (     -iqmt )
    512 Kb thread stack size   (   -iqtss  )
  1259008 Kb thread memory size ( -iqmt * -iqtss )
     48 IQ number of cpus  ( -iqnumbercpus )
      0 MB maximum size of IQMSG file ( -iqmsgsz )
      0 copies of IQMSG file archives ( -iqmsgnum )
=============================================================

CHAR collation sequence:  ISO_BINENG(CaseSensitivity=Respect)
CHAR character set encoding:  ISO_8859-1:1987
NCHAR collation sequence:  UCA(CaseSensitivity=UpperFirst;AccentSensitivity=Respect;PunctuationSensitivity=Primary)
NCHAR character set encoding:  UTF-8
Database is not encrypted
Creating system tables
Creating system views
Setting option values
Exception Thrown from stcxtlib/st_database.cxx:1938, Err# 49, tid 2 origtid 2
   O/S Err#: 0, ErrID: 5120 (st_databaseException); SQLCode: -1000338, SQLState: 'QDD38', Severity: 14
[21221]: Insufficient cache to allocate free list. Temp buffers required: 132; temp buffers avaliable: 63.
-- (stcxtlib/st_database.cxx 1938) .
SQL error (-1000338) -- Insufficient cache to allocate free list. Temp buffers required: 132; temp buffers avaliable: 63.
-- (stcxtlib/st_database.cxx 1938) .
Database "/siq/devices/myiq.db" not created

Unfortunately there is no way to specify the IQ temp cache size via the iqinit program:

Usage: iqinit [options] database
        @data expands data from environment variable data or file data

Options (use specified case, as shown):
        -a             accent sensitivity on all UCA string comparisons
        -af            accent sensitivity (French rules) on all
                       UCA string comparisons
        -b             blank padding of strings for comparisons
        -c             case sensitivity on all string comparisons
        -dba uid,pwd set dba username and password
        -dbs size    set initial database size
        -ea alg      encryption algorithm (default none)
        -ek key      specify encryption key
        -ep            prompt for encryption key
        -et            enable encrypted tables
        -i             do not install jConnect support
        -k             SYS.SYSCOLUMNS and SYS.SYSINDEXES views not created
        -l             list available collation sequences
                       (use -l+ to list older collations)
        -le            list available character set encoding labels
                       (use -le+ to list more encoding label aliases)
        -m name      set transaction log mirror name
        -n             no transaction log
        -o file      log output messages to file
        -p size      set page size (must be power of 2 = 2048 and = 32768)
        -pd            legacy system stored procedure behavior
        -q             quiet: do not display messages
        -s             add checksum to database pages
                       (by default checksums are added to database pages,
                       use '-s-' to turn off adding checksums to database pages)
        -t name      transaction log file name (default is database.log)
        -z coll      specify collation sequence for CHAR data type (defaults
                       to server platform's codepage and ordering)
        -ze encoding specify character set encoding for CHAR data type
        -zn coll     specify collation sequence for NCHAR data type
                       (use '-zn UTF8BIN' if the ICU libraries are not
                       available on the server that will load the database. ICU
                       libraries might not be installed on some platforms, such
                       as Windows CE.)
        -iqpath        The path name of the main segment file containing the
                       IQ data.
        -iqsize        The size in MB of either raw partition or OS file with
                       the -iqpath.
        -iqpgsize      The page size in bytes for the Sybase IQ segment of the
                       database.
        -iqblksize     The I/O transfer block size in bytes..
        -iqreservesize Specifies the size in MB of the space to reserve for
                       the Main IQ store.
        -iqmsgpath     The path name of the segment containing the Sybase IQ
                       message trace file.
        -iqtmppath     The path name of of the temporary segment file.
        -iqtmpsize     The size in MB of either the raw partition or OS file
                       for the -iqtmppath.
        -iqtmpreservesize     The size in MB of space to reserve for the
                        temporary IQ store.

Since iqinit calls the iqsrv16 program, we can rename the iqsrv16 to iqsrv16.orig and wrap it with the following iqsrv16 shell script:

#!/bin/ksh

$SYBASE/IQ-16_0/bin64/iqsrv16.orig -iqtc 200 -iqmc 200 $*

Note that I’m allocating 200mb of both main and temporary cache. The IQ instance is now able to start and once the database is created, we can simply replace the iqsrv16 wrapper with the iqsrv16.orig program.

IQ Error: The multiplex server ‘iq_node_3’ is not included in the multiplex – SOLVED

$
0
0

When you run SAP’s IQ Multiplex cluster for a while you start finding little gotchas that will just drive you to drink. If you don’t drink, you will wish you do. (Just like with any other cluster system)

In my latest foray into the murky waters of IQ Multiplex (v16), if one of the nodes if offline for a while, the coodinator node will mark the node as excluded so the cluster carries on. Not really a big deal until you try to bring up the problem node:

I. 02/09 10:31:45. Database server stopped at Tue Feb 09 2016 10:31
DBSPAWN ERROR:  -82
Unable to start specified database: autostarting database failed
Exception Thrown from stcxtlib/st_database.cxx:10050, Err# 21, tid 2 origtid 2
   O/S Err#: 0, ErrID: 5120 (st_databaseException); SQLCode: -1013113, SQLState: 'QNA49', Severity: 14
[22016]: The multiplex server 'iq_node_3' is not included in the multiplex.
-- (stcxtlib/st_database.cxx 10050)

Error: The multiplex server 'iq_node_3' is not included in the multiplex. The multiplex server 'iq_node_3' is not included in the multiplex.
Server failed to start

JNLERROR 2016-02-09-10:31:46 Start of IQ instance iq_mpx_cluster1 failed

Log into the coordinator node, in my case iq_node_1, and run

select server_name, status, mpx_mode, inc_state from sp_iqmpxinfo();"
server_name        status   mpx_mode         inc_state
---------------------------------------------------------------
iq_node_1          included coordinator      N/A
iq_node_2          included writer           active
iq_node_3          excluded unknown           timed_out

As you can see, the iq_node_3 node is excluded due to the connection to it from the coordinator timed out. What to do? Simple, first we re-include the node (on the coordinator):

alter multiplex server iq_node_3 status included;

Next we need to resync iq_node_3:

Resync IQ secondary node

The problem node should start up just fine now.

Viewing all 102 articles
Browse latest View live


Latest Images