Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

To build dynamic SQL Query using some conditions: Pseudo code required

831217Mar 6 2011 — edited Mar 7 2011
Hi,
I have a requirement where in i have to build a dynamic query based on one count.

Some details on requirement:

1) It's a Proc where i need to return some columns
2) There are some fix set of columns
3) Based on one Count column, i have to decide the rest of the columns.

Consider there is an employee who can work on 'N' number of assignments.

For a particular employee i have to return all the predefined details of assignments like:
1) Assignment Name
2) Assignmanet Id
3) Assignemnt Start Date
4) Assignment End Date

This 'N' can vary from employee to employee. Based on which i have to return my result set. For instance if employee has 3 assignemnts, i have to return Fix columns( employee info) + (3*4) columns. Similarly if the employee has 4 assignments, i will be returning Fix columns + (4*4) columns.

Certainly, the Employee ID is coming as an I/P parameter.

The source table is a vertical table having all details of the employee assignments.

Can anyone help me in coding this proc with the help of some pseudo code?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 4 2011
Added on Mar 6 2011
3 comments
228 views