In MS SQL Server, if I want to check the results from a stored procedure, I can do the following in Management Studio.
--SQL SERVER WAY exec sp_GetQuestions('OMG Ponies')
The result in the results pane may look like this.
ID Title ViewCount Votes ----- ------------------------------------------------- ---------- -------- 2165 Indexed View vs Indexes on Table 491 2 5068 SQL Server equivalent to Oracle's NULLS FIRST 524 3 1261 Benefits Of Using SQL Ordinal Position Notation? 377 2 (3 row(s) affected)
No need to write loops or PRINT statements.
To do the same in Oracle, I could execute the following anonymous block in SQL Developer
--ORACLE WAY DECLARE OUTPUT MYPACKAGE.refcur_question; R_OUTPUT MYPACKAGE.r_question; USER VARCHAR2(20); BEGIN dbms_output.enable(10000000); USER:= 'OMG Ponies'; recordCount := 0; MYPACKAGE.GETQUESTIONS(p_OUTPUT => OUTPUT, p_USER=> USER, ) ; DBMS_OUTPUT.PUT_LINE('ID | Title | ViewCount | Votes' ); LOOP FETCH OUTPUT INTO R_OUTPUT; DBMS_OUTPUT.PUT_LINE(R_OUTPUT.QUESTIONID || '|' || R_OUTPUT.TITLE '|' || R_OUTPUT.VIEWCOUNT '|' || R_OUTPUT.VOTES); recordCount := recordCount+1; EXIT WHEN OUTPUT % NOTFOUND; END LOOP; DBMS_OUTPUT.PUT_LINE('Record Count:'||recordCount); CLOSE OUTPUT; END;
It means that
ID|Title|ViewCount|Votes 2165|Indexed View vs Indexes on Table|491|2 5068|SQL Server equivalent to Oracle's NULLS FIRST|524|3 1261|Benefits Of Using SQL Ordinal Position Notation?|377|2 Record Count: 3
So, the SQL version has 1 row, while oracle has 18, and the output is ugly. It is compounded if there are many columns and / or the data is numeric.
What is strange to me is that if I write this statement in SQL Developer or Management Studio ...
SELECT ID, Title, ViewCount, Votes FROM votes where user = 'OMG Ponies'
The results are pretty similar. It makes me feel like I either missed a technique or used the wrong tool.
oracle oracle10g oracle-sqldeveloper
Conrad Frix Aug 19 2018-10-10T00: 00Z
source share