Last active
January 23, 2025 23:40
-
-
Save TiloGit/eed089c56aa1aa07d060d46294b0cbdc to your computer and use it in GitHub Desktop.
Read IBM FileNet GCD from Database as XML script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$SQLServer = "mysqlserver1232.westus2.cloudapp.azure.com" | |
$SQLDBName = "ABC_FNGCD" | |
$uid ="sa" | |
$pwd = "my-db-pass123" | |
##modify below query if you want specific GCD version | |
$SqlQuery = "select gcd_blob FROM FNGCD WHERE epoch_id = (select last_epoch_id from FNGCD where epoch_id = 0);" | |
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection | |
$SqlConnection.ConnectionString = "Server = $SQLServer; Database = $SQLDBName; User ID = $uid; Password = $pwd;" | |
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand | |
$SqlCmd.CommandText = $SqlQuery | |
$SqlCmd.Connection = $SqlConnection | |
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter | |
$SqlAdapter.SelectCommand = $SqlCmd | |
$DataSet = New-Object System.Data.DataSet | |
$SqlAdapter.Fill($DataSet) | |
$DataSet.Tables | |
$instream = [System.IO.MemoryStream]::new($DataSet.Tables.gcd_blob) | |
$zlib = [System.IO.Compression.ZLibStream]::new( | |
$instream, | |
[System.IO.Compression.CompressionMode]::Decompress) | |
$outstream = [System.IO.MemoryStream]::new() | |
$zlib.CopyTo($outstream) | |
$zlib.Dispose() | |
# Choose encoding here | |
$enc = [System.Text.Encoding]::UTF8 | |
##out to console | |
$enc.GetString($outstream.ToArray()) | |
##out to XML file | |
$enc.GetString($outstream.ToArray()) | out-file my-gcd.xml -encoding utf8 |
pretty print output XML file, see here: https://gist.github.com/TiloGit/3c2d49d09696c7054d3f76c78c341b1b
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
IBM FileNet GCD (XML) is compressed with zlib stored in DB Blob/binary/bytea column these days it seems. If you have the GCDUtil from IBM support you still better of using that one.
If you have Java use
java.util.zip.InflaterOutputStream
(zlib)Here a little PS script (needs 7.x or newer PS) to read the zlib compressed GCD and output as XML.
if you get
your GCD is not compressed and you can just use plain MS SQL CMD
if I get around will do a bash script/other DBs
see here for other info about the GCD: https://bpmadmin.blogspot.com/2013/09/how-to-open-filenet-global_25.html