stored procedures - SQL - Check for consistency between the table data without using Cursors -


I am using SQL and I have 4 tables.

  1. tbl_project (project_id is the primary key
  2. tbl_task (Task_id as the primary key and project_ID included as a foreign key) < li> tbl_assignment (Includes assignment_id as primary key function_id as foreign key)
  3. One project may have one or more functions
  4. One assignment can be one or more assignments >
  5. In an assignment One or more documents may be

    Now I have to write a stored procedure that will validate a project and return the verification result, where the form of project id parameter

    1. The project needs to check at least one task.
    2. All the tasks under this project have at least 1 assignment
    3. At least 1 document for this project / work

      INMENT I have a floating table where I need it

      Is there any way to implement this argument without using the cursor

      / div> < p>

      You do not need a cursor to type this type of verification. These are three questions that do this:

      No unused projects:

        Choose p. * Tbl_projects p from external to join tbl_tasks t p.project_id = t.project_id where t.project_id is zero;   

      There is at least one assignment in the job: select

        p. * Tbl_tasks t from the external join tbl_assignments a.task_id = t.task_id where a .task_id is zero;   

      All assignments have at least one document: select

        p. * Tbl_assignments join a left outer tbl_documents at a.assignment_id = d.assignment_id where d.assignment_id is zero;    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -