Focal Point
[CLOSED] SQLMSS Passthru with JSON output

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

December 20, 2019, 12:53 PM
Hallway
[CLOSED] SQLMSS Passthru with JSON output
Starting in SQL Server 2016, you have the ability to Format Query Results as JSON. With the ability in SQL Server2016 and later, you can create milti-level JSON:



I know that IBI has ON TABLE HOLD FORMAT JSON, however it only has the ability to show data in a single level (please correct me if I'm wrong).


So, my question is, has anyone been able to do a SQL Passthru query to retrieve JSON output?

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


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
December 21, 2019, 04:23 PM
Satheesh Babu
i did similar json format from SQL DB before IBI release the JSON Format. I created Stored procedure to return the json format and created synonym in webfocus for that stored procedure. I created procedure with PCHOLD format WP . Then in the HTML Page AJAX, called the procedure. Sometimes i used custom java script parser to manipulate the json.


WebFOCUS 8.2.04
AIX/UNIX/Windows, All Outputs
December 23, 2019, 05:02 AM
Tony A
The closest I ever got (to date) was using PUTDDREC - not exactly what you want owing to the thought required, but ...

Previous post

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
December 24, 2019, 04:40 AM
Frans
is your goal to retrieve the JSON output, or pass the JSON with WebFOCUS to a client?


Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
December 26, 2019, 03:43 AM
Efrem
This is a little better but I'm not sure if this meets your requirements:

TABLE FILE CAR
SUM
DCOST
RCOST
BY COUNTRY
BY CAR
BY MODEL
ON TABLE HOLD AS BASEAPP/current_json_structured FORMAT JSON STRUCTURE HIERARCHY
END

{
"sort_keys": [{
"COUNTRY": "ENGLAND",
"CAR": "JAGUAR",
"MODEL": "V12XKE AUTO",
"verbs": [{
"DEALER_COST": 7427,
"RETAIL_COST": 8878
}]
},
{
"COUNTRY": "ENGLAND",
"CAR": "JAGUAR",
"MODEL": "XJ12L AUTO",
"verbs": [{
"DEALER_COST": 11194,
"RETAIL_COST": 13491
}]
},
{
"COUNTRY": "ENGLAND",
"CAR": "JENSEN",
"MODEL": "INTERCEPTOR III",
"verbs": [{
"DEALER_COST": 14940,
"RETAIL_COST": 17850
}]
},
{
"COUNTRY": "ENGLAND",
"CAR": "TRIUMPH",
"MODEL": "TR7",
"verbs": [{
"DEALER_COST": 4292,
"RETAIL_COST": 5100
}]
},
{
"COUNTRY": "FRANCE",
"CAR": "PEUGEOT",
"MODEL": "504 4 DOOR",
"verbs": [{
"DEALER_COST": 4631,
"RETAIL_COST": 5610
}]
},
{
"COUNTRY": "ITALY",
"CAR": "ALFA ROMEO",
"MODEL": "2000 4 DOOR BERLINA",
"verbs": [{
"DEALER_COST": 4915,
"RETAIL_COST": 5925
}]
},
{
"COUNTRY": "ITALY",
"CAR": "ALFA ROMEO",
"MODEL": "2000 GT VELOCE",
"verbs": [{
"DEALER_COST": 5660,
"RETAIL_COST": 6820
}]
},
{
"COUNTRY": "ITALY",
"CAR": "ALFA ROMEO",
"MODEL": "2000 SPIDER VELOCE",
"verbs": [{
"DEALER_COST": 5660,
"RETAIL_COST": 6820
}]
},
{
"COUNTRY": "ITALY",
"CAR": "MASERATI",
"MODEL": "DORA 2 DOOR",
"verbs": [{
"DEALER_COST": 25000,
"RETAIL_COST": 31500
}]
},
{
"COUNTRY": "JAPAN",
"CAR": "DATSUN",
"MODEL": "B210 2 DOOR AUTO",
"verbs": [{
"DEALER_COST": 2626,
"RETAIL_COST": 3139
}]
},
{
"COUNTRY": "JAPAN",
"CAR": "TOYOTA",
"MODEL": "COROLLA 4 DOOR DIX AUTO",
"verbs": [{
"DEALER_COST": 2886,
"RETAIL_COST": 3339
}]
},
{
"COUNTRY": "W GERMANY",
"CAR": "AUDI",
"MODEL": "100 LS 2 DOOR AUTO",
"verbs": [{
"DEALER_COST": 5063,
"RETAIL_COST": 5970
}]
},
{
"COUNTRY": "W GERMANY",
"CAR": "BMW",
"MODEL": "2002 2 DOOR",
"verbs": [{
"DEALER_COST": 5800,
"RETAIL_COST": 5940
}]
},
{
"COUNTRY": "W GERMANY",
"CAR": "BMW",
"MODEL": "2002 2 DOOR AUTO",
"verbs": [{
"DEALER_COST": 6000,
"RETAIL_COST": 6355
}]
},
{
"COUNTRY": "W GERMANY",
"CAR": "BMW",
"MODEL": "3.0 SI 4 DOOR",
"verbs": [{
"DEALER_COST": 10000,
"RETAIL_COST": 13752
}]
},
{
"COUNTRY": "W GERMANY",
"CAR": "BMW",
"MODEL": "3.0 SI 4 DOOR AUTO",
"verbs": [{
"DEALER_COST": 11000,
"RETAIL_COST": 14123
}]
},
{
"COUNTRY": "W GERMANY",
"CAR": "BMW",
"MODEL": "530I 4 DOOR",
"verbs": [{
"DEALER_COST": 8300,
"RETAIL_COST": 9097
}]
},
{
"COUNTRY": "W GERMANY",
"CAR": "BMW",
"MODEL": "530I 4 DOOR AUTO",
"verbs": [{
"DEALER_COST": 8400,
"RETAIL_COST": 9495
}]
}
]
}
December 26, 2019, 07:21 PM
Hallway
quote:
Originally posted by Frans:
is your goal to retrieve the JSON output, or pass the JSON with WebFOCUS to a client?


I am wanting to pass the JSON to a webpage into a JS charting library. So, basically using WebFOCUS like an API endpoint. I am currently using the FORMAT JSON output in WebFOCUS, but I have to do a lot of JavaScript Array and Object manipulation to get it into the proper format to pass to the charting engine. I could write a query in SQL Server that would give me the needed format. It would simplify the process if it were possible for a "SQL Passthru" to actually work like a true SQL Passthru.


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
December 26, 2019, 07:24 PM
Hallway
quote:
Originally posted by Tony A:
The closest I ever got (to date) was using PUTDDREC - not exactly what you want owing to the thought required, but ...

Previous post

T


Nice work T. I'll see if I can make this work.


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
December 27, 2019, 03:20 PM
Satheesh Babu
I have done similar in WF 8201 for Year calendar and Kendo Grid.

1. Create a Stored procedure that should return your json.
2. In webfocus Create a procedure and choose Format WP.
3. Use the HTML Form to Store it as variable.
4. You can call this Procedure in the AJAX.
5. The result format will be in JSON .



TABLE FILE SP_REMINDER_DETAIL_SELECT_JSON_FOR_CALENDAR
PRINT
     SP_REMINDER_DETAIL_SELECT_JSON_FOR_CALENDAR.ANSWERSET1.VALIDJSON AS ''
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET ASNAMES ON
ON TABLE NOTOTAL
ON TABLE HOLD AS REMINDER_DETAILS FORMAT WP
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/warm.sty,
$
TYPE=REPORT,
     COLUMN=N1,

$
ENDSTYLE
END
-RUN

SET HTMLFORMTYPE=TXT
-HTMLFORM BEGIN

  !IBI.FIL.REMINDER_DETAILS;

-HTMLFORM END

  



WebFOCUS 8.2.04
AIX/UNIX/Windows, All Outputs