Focal Point
[SOLVED] Data Migrator Synonym- Custom Query Possible?

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6357041196

February 27, 2019, 02:29 PM
Scott Holmes
[SOLVED] Data Migrator Synonym- Custom Query Possible?
Hello- If this DataMigrator post belongs in a different forum, please let me know and I'll move it accordingly.

In DataMigrator (DMC), I am trying to create a synonym that represents a complex query. I'm looking for a way to supply a custom query as the definition of the synonym. In my case, I have a table that recursively refers to itself (ex. Employee table with a manager ID column pointing back to employee ID of different row). I need to traverse the records for relations and build a list of descendant records (ex. A particular Department Head and all employees underneath). Oracle is the DBMS holding the table, so I can leverage the CONNECT BY analytic function (or the ANSI SQL WITH keyword equivalent) in a SQL select statement to get the desired results, but I can't find a way to place that SQL in a synonym. The closest I found was being able to place the SQL in a custom SQL object in the data flow. Unfortunately, the Test SQL statement button returns errors for both the Oracle and ANSI syntax SQL statements. It appears the custom SQL object does not support the syntax.

Does anyone have any suggestions on how to create a recursive listing that can be reused in many dataflows? Thanks.

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS Release 82; DataMigrator Release 7707
February 27, 2019, 03:06 PM
FP Mod Chuck
Hi Scott

Welcome to Focal Point! It is a great forum for getting answers to your development questions!

DataMigrator questions usually fall under the iWay Software product forum but you don't have to move it there this time.

I am not a SQL expert by any means and your SQL sounds complex. I think you want to create a DBMS SQL Flow and choose your Oracle connection under the properties. The datamigrator user guide describes this flow in chapter 5. When you use this type of flow a synonym is not required as it will pass your oracle specific SQL directly to Oracle for processing. The result set of that can then be loaded into a separate Oracle table.


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
February 27, 2019, 03:56 PM
Scott Holmes
Thank you for the quick reply! I will put future DMC posts in the iWay Software Product forum.

I was able to follow your advice and create a DBMS SQL Flow with a hardcoded literal value in the SQL statement, but I could not find a way to pass a variable into it for filtering sake. Without filtering, this query would become extremely expensive. Is there a way to pass in a filtering criteria such as an ID (ex. WHERE emp_id = &&emp_id_var)?

If not, I also tried the route of creating a stored procedure as the basis for the synonym. I was able to create the synonym this way, and the sample data dialog would allow me to supply a value for the stored procedure's input variable. However, I could not find any way to specify a variable in the synonym or dataflow using the synonym so that a value could be passed in at runtime. Surely there's a way to supply stored procedure input values at runtime, but I could not figure it out nor any documentation.

Any advice is appreciated. Thanks.


WebFOCUS Release 82; DataMigrator Release 7707
February 27, 2019, 05:24 PM
Clif
Support for using variables in a DBMS SQL Flow was added in Release 7.7.08M. You may want to upgrade to the current production release.

When you create a synonym for a database stored procedure you can pass a value to an input parameter a WHERE condition for a single value.

For example if you had the classic ORACLE sample schema scott and followed the instructions in the DMUG in the section "How to Use a Relational Stored Procedure as a Data Source" to create a procedure and synonym you could then use that synonym as a data source. Then you would add a WHERE condition T1.PEMPNO = &EMPNO. When you test or run the procedure it would prompt you for EMPNO and you enter a value like 7839 and you'll get back one row.

To submit or schedule the flow you would provide a value in a stored procedure.

One more thing. To address your original question about how to create a synonym that reflects a complex query you can do that too, as long as it returns a single answer set. Save the query in file a with extension of sql. Then when you create a synonym in the Object Type pull-down select External SQL Scripts and enter the location and name.

Now you can use that synonym as a data source as you would use any other. Of course you can't use them as targets.
February 28, 2019, 04:40 PM
Scott Holmes
I'll check with our installation guys what our plan is for upgrading to 7.7.08M.

I also followed your instructions on supplying a variable to a stored procedure. After a few missteps (I'm still pretty new to DMC), I was able to get it to work. I was also able to get the SQL file synonym source to work.

Thank you both for your help on this issue.


WebFOCUS Release 82; DataMigrator Release 7707