ODI - Groovy scripts that set the Begin Mapping Comand & End Mapping Command with PL/SQL code - oracle-data-integrator

Using Groovy how could I change the Physical layer settings in all ODI maps, including PL / SQL code in Begin Mapping Command & End Mapping Command and sets the Technology for Begin Mapping Command/Location for Begin Mapping Command & Technology for End Mapping Command/Location for End Mapping Command.
Thank you.

The IMappingFinder interface lets you retrieve a collection of mappings (by project for instance).
For each element in the collection you can then use getPhysicalDesign method to retrieve the physical design(s) of the mapping. From there, you can use the following methods to set the code, the technology and the logical schema :
setBeginCmd
setBeginCmdLogicalSchema
setBeginCmdTechnology
setEndCmd
setEndCmdLogicalSchema
setEndCmdTechnology
However, if you need to add some code at the beginning and end of every mapping, it might be a good candidate for a custom Knowledge Module instead. You could duplicate your IKM, add a step at the beginning and one at the end and make sure you use the new KM. That's what KM are used for. Here is an example : https://blogs.oracle.com/dataintegration/odi-12c-components-and-lkmsikms
The full documentation is here : https://docs.oracle.com/en/middleware/fusion-middleware/data-integrator/12.2.1.3/odikd/developing-knowledge-modules-oracle-data-integrator.pdf

Related

Large Number Entry in Oracle APEX

I have a Number field in DB and Oracle APEX.
My Issue is:
If Users want to entry the number data with this format "1.000.000,01", then takes Charakter Error that the entry must be Number.
How can I solve this problem in Application Layer ? In Database Layer there are some solutions , but in Application Layer so far I can not find any solution.
As Summary: I want to entry number as 1.000.000,12 in Application and I want to see it in the same format.
NOT: A procedure runs in the Application to insert the data in DB.
You can/should set appropriate format mask, e.g. 999G999G990D00 where
G represents thousands character (dot in your case)
D represents decimal character (comma in your case)
But, where do you set NLS numeric characters (represented by G and D)? In Apex 20.2, it is to be set in:
application builder
shared components
globalization attributes
security
initialization PL/SQL code - in here, you'll probably see what they are set to. Change those values, if necessary. For example:
begin
execute immediate q'[alter session set nls_numeric_characters = ',.']';
execute immediate q'[alter session set nls_date_format = 'dd.mm.yyyy hh24:mi:ss']';
end;

Difficulties creating a Firebird database in Delphi

clarification
David thinks this is a duplicate. I'm aware of that other question, I'm referring to the answer there. It just doesn't solve my problem; for instance I don't see the CreateDatabase property in the Object Inspector.
I am acquainted with Delphi, but this is the first time I need a database in a project. Using Delphi XE8.
In this answer to another question I found a script to create a database, which I used verbatim:
SET SQL DIALECT 3;
SET NAMES UTF8;
SET CLIENTLIB 'C:\fb25\bin\fbclient.dll';
CREATE DATABASE 'D:\MyProject.fdb'
USER 'sysdba' PASSWORD 'masterkey'
PAGE_SIZE 16384
DEFAULT CHARACTER SET NONE;
SET TERM ^ ;
CREATE PROCEDURE MY_PROC RETURNS (aParam INTEGER) AS
BEGIN
aParam = 10;
END^
But I'm having problems with FDConnection1. In its parameters I entered a database filename, but I don't see the CreateDatabase property said answer mentions. When I execute
FDScript1.ExecuteAll;
nothing happens.
How can I create my database? And where can I set CreateDatabase=yes?
edit 1: What I tried
I created a VCL application with a TFDScript (FDScript1) and a TFDConnection (FDConnection1). I entered the above script in the FDScript1.SQLScripts property and assigned FDConnection1 to its Connection property.
For FDConnection1 I set DriverName to "FB", entered a ConnectionName and entered a filename (full path) in params.database.
David points out that my assumption that CreateDatabase would be a Property is wrong. Should this then be in the script? (It does already say "CREATE DATABASE".)
The CreateDatabase connection definition parameter has been replaced by OpenMode parameter. I'd would suggest setting it to OpenOrCreate in your case (which creates database if doesn't exist, or uses the existing one):
...
FDConnection1.Params.Add('OpenMode=OpenOrCreate');
FDConnection1.Connected := True;
For FireDAC shipped with Delphi XE7 or below, use the mentioned CreateDatabase parameter.

Specify and use multiple libraries in ODBC connection string

My odbc connection string for connecting to DB2i looks like this:
Driver={Client Access ODBC Driver (32-bit)};system=xx.xx.xx.xx;dbq=LIB1 LIB2 LIB3 LIB4 LIB5 LIB6 LIB7 LIB8;languageid=ENU;qrystglmt=-1;cmt=0;signon=1
The above connection string specifies multiple libraries/schemas for use. But when I try to access a file/table from a library other than the first one (like from LIB2...LIB8) I get a exception saying "FILE xx not found in LIB1"
Why does not it automatically search for the file/table in other specified libraries, it searches for the file in the first library only?
I need a workaround for this situation.
Use "system naming" mode, by adding naming=1 to your connection string.
In your library list, place a comma before the first library.
Driver={Client Access ODBC Driver (32-bit)};system=systemname;naming=1;
dbq=,LIB1,LIB2,LIB3,LIB4,LIB5,LIB6,LIB7,LIB8;languageid=ENU;cmt=0;signon=1
This works as documented in the manual:
The library list is used for resolving unqualified stored procedure calls and finding libraries in catalog API calls. ...
Note:
The first library listed in this property will also be the default library, which is used to resolve unqualified names in SQL statements.
As stated above, Schema/library list is used to resolve functions/procedure names, not tables.
Let assume you need to read data from lib1.tab1 and lib2.tab2;
Here my personal workarounds (from easy to complex):
a) ask the db admin to have - for each table you need to use - the corresponding schema name, then do "select * from lib1.tab1 join lib2.tab2 on [...]" ;-)
b) ask the db admin to create on schema "MyAlias" several alias (create alias) for each table you want to use. Then do "set current schema=MyAlias" followed by all the SQL statement you need e.g. "select * from tab1 join tab2". Since you’re querying myalias.tab1 which is an alias pointing to table lib1.tab1 it should work.
c) Complex: create your own SQL function that returns the corresponding schema_name for a table (e.g. myfunct('TAB1'). This could be done reading system view “qsys2.systables” where table_name=’TAB1’ and returning TABLE_SCHEMA column, which is a varchar(128). Once you got it, build up a dynamically prepared using the variable you just obtained. E.g.
"set mylib = myfunct('TAB1').
"set mystmt = 'select * from '||table_schema || ‘.tab1’ …”
Prepare mystmt and then execute mystmt.
I did something similar in VBA using ado ibmdrda and it worked.
hope this helps.
f.

SSIS suitability

I'm tring to create an SSIS package to import some dataset files, however given that I seem to be hitting a brick
wall everytime I achieve a small part of the task I need to take a step back and perform a sanity check on what I'm
trying to achieve, and if you good people can advise whether SSIS is the way to go about this then I would
appreciate it.
These are my questions from this morning :-
debugging SSIS packages - debug.writeline
Changing an SSIS dts variables
What I'm trying to do is have a For..Each container enumerate over the files in a share on the SQL Server. For each
file it finds a script task runs to check various attributes of the filename, such as looking for a three letter
code, a date in CCYYMM, the name of the data contained therein, and optionally some comments. For example:-
ABC_201007_SalesData_[optional comment goes here].csv
I'm looking to parse the name using a regular expression and put the values of 'ABC', '201007', and
'SalesData' in variables.
I then want to move the file to an error folder if it doesn't meet certain criteria :-
Three character code
Six character date
Dataset name (e.g. SalesData, in this example)
CSV extension
I then want to lookup the Character code, the date (or part thereof), and the Dataset name against a lookup table
to mark off a 'checklist' of received files from each client.
Then, based on the entry in the checklist, I want to kick off another SSIS package.
So, for example I may have a table called 'Checklist' with these columns :-
Client code Dataset SSIS_Package
ABC SalesData NorthSalesData.dtsx
DEF SalesData SouthSalesData.dtsx
If anyone has a better way of achieving this I am interested in hearing about it.
Thanks in advance
That's an interesting scenario, and should be relatively easy to handle.
First, your choice of the Foreach Loop is a good one. You'll be using the Foreach File Enumerator. You can restrict the files you iterate over to be just CSVs so that you don't have to "filter" for those later.
The Foreach File Enumerator puts the filename (full path or just file name) into a variable - let's call that "FileName". There's (at least) two ways you can parse that - expressions or a Script Task. Depends which one you're more comfortable with. Either way, you'll need to create three variables to hold the "parts" of the filename - I'll call them "FileCode", "FileDate", and "FileDataset".
To do this with expressions, you need to set the EvaluateAsExpression property on FileCode, FileDate, and FileDataset to true. Then in the expressions, you need to use FINDSTRING and SUBSTRING to carve up FileName as you see fit. Expressions don't have Regex capability.
To do this in a Script Task, pass the FileName variable in as a ReadOnly variable, and the other three as ReadWrite. You can use the Regex capabilities of .Net, or just manually use IndexOf and Substring to get what you need.
Unfortunately, you have just missed the SQLLunch livemeeting on the ForEach loop: http://www.bidn.com/blogs/BradSchacht/ssis/812/sql-lunch-tomorrow
They are recording the session, however.

Serialize MS Access Database Objects to Text File(s)

Is there some code out there that lets me serialize all the objects in an MS Access MDB File.
All the Objects like Table definitions, Table Data, Query defintions, Report definitions, VB Modules should be written to one or multiple text files.
It is not necessary to reverse the operation (but would be nice to have). I want to put the text files to a VCS so I can track changes and document.
To import/export Access forms, modules or macros from/to
text files, use the undocumented
LoadFromText/SaveAsText methods of
the application object. (it seems you can use the same methods with query and report objects)
For tables, you can use the transferDatabase method of the DoCmd object. Be careful. By doing so you will loose the table structures and comparing text files content will be very hazardous. I'd advise you to develop your own tool for table structure comparison. I guess some pieces of software are also available on the net (google for MS Access table comparison)
To compare different versions of the same forms/modules/macros as text files, use a softare such as Files Compare Tool
You will have to write some 'cleaning' code when exporting with the SaveAsText commande, in order to ease file comparison by (for example) suppressing line numbers or internal access references.
Please check also the following links:
How do you use version control with Access development?
Working with multiple programmers on MS Access
Not sure what David Fenton's comment refers to since there is more than one way to do SaveAsText. If you do it as follows, it should be useful.
For Each obj In Access.Application.CurrentData.AllQueries
Access.Application.SaveAsText acQuery, obj.Name, strFilePath & "\Query_" & obj.Name & ".txt"
Next
As far as table definitions go, you may wish to try out the XML Export feature as follows:
For Each obj In Access.Application.CurrentData.AllTables
Access.Application.ExportXML acExportTable, obj.Name, _
strFilePath & "\TData_" & obj.Name & ".xml", _
strFilePath & "\TDef_" & obj.Name & ".xsd", , , acUTF8
Next

Resources