Jason L. Froebe – Tech tips and How Tos for Fellow Techies

Tips & Tricks for Databases (Sybase, Oracle, MySQL, PostgreSQL, SQLite), Windows, Linux, Solaris, Perl, Java, Bash and so much much more

Join us in our efforts to support Childhood Apraxia of Speech Association!

by Jason L Froebe on May 1, 2013, no comments

Join us in our efforts to support Childhood Apraxia of Speech Association!
As you know, our darling Asher has Apraxia. He is talking more and more each day, but every word is a battle for him. This research has had a direct impact on his ability to speak, and other kids like him. So help us out, throw a couple of bucks our way, and show us your support. We’ve got a long “walk” ahead of us still, but for Asher, and all the other kids like him, we’re gonna do it!

Thank you for supporting Childhood Apraxia of Speech Association. Your contribution is greatly appreciated and will continue to help CASANA fund important apraxia programs and research.

Read more about Apraxia

Share Button

Ed Barlow’s sp__helprotect updated for SAP Sybase ASE 15.7 Solved

by Jason L Froebe on April 23, 2013, no comments

I needed to copy the permissions from one database to another but the sp__helprotect stored procedure in Ed Barlow’s Extended System Stored Procedure Library for Sybase and Sql Server wasn’t producing output with “GRANT” and “REVOKE”. It also had problems with DBCC privileges. Here you go:

sp__helprotect.sql

/* Procedure copyright(c) 1995 by Edward M Barlow */
/*  Updated for v15.7 by Jason Froebe */

/******************************************************************************
**
** Name        : sp__helpprotect.sql
**
******************************************************************************/
if exists (select * from sysobjects
           where  name = "sp__helprotect"
           and    type = "P")
begin
   drop proc sp__helprotect
end
go

create procedure sp__helprotect
        @parameter varchar(30) = NULL            /* name of object or user to check     */,
        @do_system_tables char(1) = null, /* if not null will include system tbls */
        @dont_format char(1) = null,
        @groups_only char(1) = null
as
        declare @type char(2), @uid int, @msg varchar(255), @objid int

        if @parameter is NULL
                select @objid=null
        else
                select @objid = object_id(@parameter)

        /* define our table */
        select   id,uid,action,protecttype,columns,grantor,
                        column_name             = "                               "
                        ,action_text            = "                               "
                        ,protecttype_text = "                               "
                        ,ending                                 = "                               "
        into    #protects
        from    sysprotects
        where 1=2

        /* Either a passed object or all objects */
        if @objid is not null or @parameter is null
        begin

                select uid,gid into #groups from sysusers

                if @groups_only is not null
                        delete  #groups
                        where    uid != gid

                /* IT IS AN OBJECT */
                insert  #protects
                select  id,p.uid,action,protecttype,columns,grantor,"","","",""
                from    sysprotects p, #groups g
                where   id=isnull(@objid,id)
                and      p.uid = g.uid

                /* REVOKES ON COLUMNS */
                insert  #protects
                select  id,p.uid,action,2,columns,grantor,
                        "("+col_name(p.id,c.number)+")","","",""
                from            sysprotects p, master.dbo.spt_values c, #groups g
                where   p.columns is not null
                and             convert(tinyint,substring(p.columns,c.low,1)) & c.high=0
                and             c.type = "P"
                and             c.number < = 255
                and             c.number>0
                and             c.low>1
                and             col_name(p.id,c.number) is not null
                and             id=isnull(@objid,id)
                and      p.uid=g.uid

                if @do_system_tables is null and @objid is null
                        delete #protects
                        from   #protects p, sysobjects o
                        where  p.id = o.id
                        and    o.type = 'S'
        end
        else
        begin

                /* IS IT A USER */
                select @uid = uid from sysusers where name=@parameter
                if @@rowcount = 0 or @uid is null
                begin
                   print "No User Or Object Found"
                   return (1)
                end

                insert  #protects
                select  distinct id,uid,action,protecttype,columns,grantor,"","","",""
                from    sysprotects p
                where   uid=@uid
                /* and          isnull( p.columns,0x01 ) = 0x01 */

                /* REVOKES ON COLUMNS */
                insert  #protects
                select  id,uid,action,2,columns,grantor,
                        "("+col_name(p.id,c.number)+")", "","",""
                from    sysprotects p, master.dbo.spt_values c
                where isnull( p.columns,0x01 ) != 0x01
                and     convert(tinyint, substring(p.columns, c.low, 1)) & c.high = 0
                and     c.type = "P"
                and     c.number < = 255
                and     c.number>0
                and     c.low>1
                and     col_name(p.id,c.number) is not null
                and     uid=@uid

                if @do_system_tables is null
                        delete #protects
                        from   #protects p, sysobjects o
                        where  p.id = o.id
                        and    o.type = 'S'
        end

/* References etc */
delete  #protects
where   action in(151,207,222,233,236)

update  #protects
set     action_text = name
from    master.dbo.spt_values v
where   v.type='T'
and     v.number = #protects.action

update  #protects
set     protecttype_text = name
from    master.dbo.spt_values v
where   v.type='T'
and     v.number = #protects.protecttype +204

-- protecttype column can contain these values: 0 for grant with grant. 1 for grant. 2 for revoke
update  #protects
set     protecttype_text =
   case
     when protecttype = 0
       then "GRANT"
     when protecttype = 1
       then "GRANT"
     when protecttype = 2
       then "REVOKE"
   end

update  #protects
set     ending = " WITH GRANT OPTION"
where   protecttype = 0

declare @max_len int
select @max_len = max(char_length( rtrim(protecttype_text)+" "+rtrim(action_text)+" on "+rtrim(object_name(id))+column_name+" to "+rtrim(user_name(uid))+ending))
from #protects

if @max_len < 60
        select
         substring(
           rtrim(protecttype_text)
           + " "
           + rtrim(action_text)
           + case when id = 0 then " " else " on " end
           + rtrim(object_name(id))
           + column_name
           + " to "
           + rtrim(user_name(uid))
           + ending
         ,1,59)
        from #protects
        where rtrim(action_text) != ""
        order by object_name(id),protecttype_text
else if @max_len < 80
        select
         substring(
           rtrim(protecttype_text)
           + " "
           + rtrim(action_text)
           + case when id = 0 then " " else " on " end
           + rtrim(object_name(id))
           + column_name
           + " to "
           + rtrim(user_name(uid))
           + ending
         ,1,79)
        from #protects
        where rtrim(action_text) != ""
        order by object_name(id),protecttype_text
else if @max_len < 132
        select
         substring(
           rtrim(protecttype_text)
           + " "
           + rtrim(action_text)
           + case when id = 0 then " " else " on " end
           + rtrim(object_name(id))
           + column_name
           + " to "
           + rtrim(user_name(uid))
           + ending
         ,1,131)
        from #protects
        where rtrim(action_text) != ""
        order by object_name(id),protecttype_text


return (0)
go
grant execute on sp__helprotect to public
go
Share Button

Want a free ebook? Java Application Development on Linux

by Jason L Froebe on April 12, 2013, no comments

Nikesh Jauhari over on the Linux Poison blog, posted about the free eBook – Java Application Development on Linux, a 599 page ebook from informIT. Yeah, when you download the book, you will need to give informIT your contact info. If you don’t want to, you could probably just use an email address that you don’t use except for such registration things.

Share Button

PowerBuilder: Download your PowerBuilder patches for v11.x, 12.x before April 15th! Sybase is taking them away!

by Jason L Froebe on April 12, 2013, no comments

Download the ebfs (patches) for PowerBuilder 11x and 12x now before Sybase removes them from the my.sybase.com!

Announcement from SAP/Sybase:

April 11, 2013
Dear Valued Sybase Customer:

This letter provides notification of the end of sale for the following versions of Sybase PowerBuilder.

Product Platform End of Sale Migration Path
PowerBuilder 12.x Windows 04/15/2013 PowerBuilder 12.5.2
PowerBuilder 12.5.x Windows 04/15/2013 PowerBuilder 12.5.2

Please note that EBFs for PowerBuilder 11.x, 11.5.x, 12.x and 12.5.x (except for PowerBuilder 12.5.2) will no longer be available as of April 15, 2013.

If you have any questions, please call your local Sybase Technical Support Center. One of our Customer Service representatives will respond to your questions or direct your call to someone who can. For the number of your closest Technical Support Center, please go to: www.sybase.com/contactus/support.

Thank you for your cooperation in this product transition. We regret any inconvenience that discontinuing the sale of this product may cause your organization. Our support staff is available to assist you in any way possible.

Sincerely,
Sue Dunnell
PowerBuilder Product Manager
Sybase, an SAP Company

Share Button

Howto Perl: Crypt::CBC module with the blowfish encryption cipher

by Jason L Froebe on April 9, 2013, no comments

I came up with the following example a few years back. Crypt::CBCperl is quite easy to use but can be confusing to new users of it. I prefer to use the subroutines encrypt_hex and decrypt as the encoded string is hexidecimal not in binary format. This allows me to work with it as if it was a normal string, such as sending it in a tweet or email or possibly embed it in an image.

use warnings;
use strict;
use Crypt::CBC;

our $cipher = Crypt::CBC->new(
  -key => 'g0oB3r__g0oB3r',
  -cipher => 'Blowfish'
);

# Encrypts a string and returns it.
sub encrypt {
  return( $cipher->encrypt_hex($_) );
}

# Decrypts an encrypted string and returns it.
sub decrypt {
  return( $cipher->decrypt( pack("H*", $_) ) );
}

#########

my $encrypted_string = encrypt('happy')
my $decrypted_string = decrypt($encrypted_string);

printf "'happy' -> encrypted as '%s' -> decrypted to '%s'\n", $encrypted_string, $decrypted_string;
Share Button
Facebook login by WP-FB-AutoConnect