Focal Point
[SOLVED] JOIN SQL passthru output to HOLD table

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

November 13, 2012, 05:17 PM
TOM SCHULTE
[SOLVED] JOIN SQL passthru output to HOLD table
I am trying to generate an exception report based on metadata and the output of a SQL sorred procedure which returns what should be present. Basically, I will examine two conditions:

1] If SQL says the synonym should be present, and it is not, CREATE SYNONYM

2] If synonym is present, but should not be, queue e-mail to start DELETE SYNONYM wqorkflow.

I am holding the data of current synonyms, since I am iterating through them to do a REFRESH SYNONYM on each:

TABLEF FILE _EDAHOME/CATALOG/SYSAPPS 
PRINT 
   APPNAME
   COMPUTE SYNNAME/A1250 = APPFULL || '/' || FNAME;
WHERE NOT APPNAME IN (..);
WHERE FEXT EQ 'mas';
ON TABLE HOLD AS HMASTER FORMAT ALPHA
END


Then, later, I run the passthur to get the master list, and try to JOIN to get exceptions:

ENGINE SQLMSS SET DEFAULT_CONNECTION N1_Report_POL_ASP2
SQL SQLMSS EX Report_Services.dbo.Query_Writer_Views_Get;
 
JOIN LEFT_OUTER SYNNAME IN HMASTER TO UNIQUE Name IN SQLOUT
TABLE FILE SQLOUT
PRINT *
WHERE SYNNAME IS MISSING
 END


this is where I can use some help, since I feel I am on the right track, but I am obviously astray, since I get the error:

                                                    
0 ERROR AT OR NEAR LINE      5  IN PROCEDURE SQLOUT  FOCEXEC *                  
(FOC258) FIELDNAME OR COMPUTATIONAL ELEMENT NOT RECOGNIZED: SYNNAME
BYPASSING TO END OF COMMAND
(FOC009) INCOMPLETE REQUEST STATEMENT


There must be something I am missing on doing the join...

This message has been edited. Last edited by: Kerry,


WebFOCUS 7.7.04M/8001
Windows Server 2008
Excel, PDF, HTML, AHTML

http://www.plex.com
November 14, 2012, 09:36 AM
Euclid
I am just taking a shot in the dark on this answer since our SQL passthru is annoyingly disabled.

  
ENGINE SQLMSS SET DEFAULT_CONNECTION N1_Report_POL_ASP2
SQL SQLMSS EX Report_Services.dbo.Query_Writer_Views_Get;

TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS HSQLOUT FORMAT ALPHA
END

JOIN LEFT_OUTER SYNNAME IN HMASTER TO UNIQUE Name IN HSQLOUT AS J0 END

TABLE FILE HMASTER
PRINT *
WHERE SYNNAME IS MISSING
 END


The above code is suggesting to print and hold the sqlout file, then do a join with your HMASTER hold.

Also depending on both hold file field names, you may get an ambiguous name error unless you fully write out the field.

Just to add again I may be absolutely incorrect but it is worth a try.


Developer Studio 7.7.02
Windows XP Pro SP3 and Windows 7 64bit
all output
November 14, 2012, 09:57 AM
TOM SCHULTE
Thanks! It seems like there still may be a syntax issue there, as I am getting

(FOC376) SYNTAX ERROR OR MISSING ELEMENT IN JOIN/COMBINE COMMAND:


I thought it might be some missing -RUNs, so I tried

TABLE FILE SQLOUT
PRINT *
ON TABLE HOLD AS HSQLOUT FORMAT ALPHA
END
-RUN
 
JOIN LEFT_OUTER SYNNAME IN HMASTER TO UNIQUE Name IN HSQLOUT AS J0 END
-RUN
...

But no luck, yet. I think this is going in the right direction, though.


WebFOCUS 7.7.04M/8001
Windows Server 2008
Excel, PDF, HTML, AHTML

http://www.plex.com
November 15, 2012, 03:52 PM
TOM SCHULTE
I got it working, basically, I found I had to:

1] Use FOCUS format for each hold table with an index

2] Make sure the JOIN columns were of the same data type.

Here is basically my finished code:

…

TABLEF FILE _EDAHOME/CATALOG/SYSAPPS 
PRINT 
   -*APPNAME
   CONNECT
   APPFULL
   FNAME
   COMPUTE SYNONYM_NAME/A256 = UPCASE(256, FNAME, 'A256');
   COMPUTE SYNNAME/A1250 = APPFULL || '/' || FNAME;
-*WHERE …
WHERE FEXT EQ 'mas';
ON TABLE HOLD AS HMASTER FORMAT FOCUS INDEX SYNONYM_NAME
-* Need to have same data types to join later: (FOC237) LINKED AND REAL FIELD HAVE DIFFERENT FORMATS: NAME
-*(FOC36390)  LW internal error: Indexed field 'SYNONYM_NAME' is too long (limit is A256)
-*FORMAT ALPHA
END
-RUN
 
…
 

-* seek any SQW Views to add
ENGINE SQLMSS SET DEFAULT_CONNECTION …
SQL SQLMSS EX Report_Services.dbo.Query_Writer_Views_Get;
 
TABLE FILE SQLOUT
PRINT 
   COMPUTE SQLVIEW/A256 = UPCASE(256, NAME, 'A256');
ON TABLE HOLD AS HSQLOUT FORMAT FOCUS INDEX SQLVIEW
END
-RUN

JOIN LEFT_OUTER SQLVIEW IN HSQLOUT TO UNIQUE SYNONYM_NAME IN HMASTER AS J0
-RUN

 
TABLE FILE HSQLOUT
PRINT *
END
-RUN
-EXIT
 
…

This message has been edited. Last edited by: TOM SCHULTE,


WebFOCUS 7.7.04M/8001
Windows Server 2008
Excel, PDF, HTML, AHTML

http://www.plex.com