Question

I have a working stored procedure code that calls a table from the SAMPLE database. But my problem now is I am confused on how do i make it into a flowchart as the conditions are within the SELECT statement itself.

CREATE PROCEDURE TAXDUE ()

    DYNAMIC RESULT SETS 1
    LANGUAGE SQL

BEGIN

    DECLARE display CURSOR WITH RETURN TO CLIENT FOR     
        SELECT EMPNO, LASTNAME, SALARY,
                   CASE 
                     WHEN SALARY < 15001 THEN SALARY 
                     WHEN SALARY BETWEEN 15001 AND 22000 THEN SALARY * 0.05
                     WHEN SALARY BETWEEN 20001 AND 32000 THEN (SALARY * 0.07) + 125
                     WHEN SALARY BETWEEN 32001 AND 45000 THEN (SALARY * 0.10) + 200
                     ELSE SALARY
                   END AS "TAX DUE"          
        FROM EMPLOYEE 
        WHERE WORKDEPT IN ('A00', 'B01', 'C01');

    OPEN display;

END    

How do i layout this into a flowchart? I can visualize it never tried making a flowchart out of a SELECT statement that has conditions in it.

Was it helpful?

Solution

SQL is a declarative language.

You specify what you want not how to get it. As such you cannot really flow chart a piece of SQL as the "flow" is all about how something is acheived.

You can run an "explain" to see how the RDBMS retrieved the data on this database at this time, but RDBMSes are fickle and change their access paths frequently.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top