How to insert a null value to combobox which is bind with datasource

Hi,
i am working on c# winforms application. I have 2 comboboxes one is CustomerCbBox and another is OrderCbBox. CustomerCbBox is bind with data source.
on CustomerCbBox SelectedIndexChanged event data is populated in OrderCbBox from data source. 
i want to add a null or empty field in CustomerCbBox. all I want is that when the user don't Select Customer Name and OrderNo null or empty data enter in database. but when i click Insert Button it generate error "Object reference is not "object
reference not set to an instance of an object".
here is my code.
  private void MainForm_Load(object sender, EventArgs e)
production pd = new production();
CustomerCbBox.DataSource = pd.Customer();
CustomerCbBox.DisplayMember = "Cust";
CustomerCbBox.ValueMember = "CustId";
 private void CustomerCbBox_SelectedIndexChanged(object sender, EventArgs e)
                  try
                      string PartyName = CustomerCbBox.SelectedIndex.ToString();
                       PONum1.DataSource = pd.GetPOnumActive(PartyName1);
                          PONum1.DisplayMember = "PONum";
                          PONum1.ValueMember = "PONum";
                  catch (Exception ex)
                      MessageBox.Show(ex.Message);
     Please help me to solve this problem thanks.      

Hello,
We could check whether the user has selected any items before adding that to database.
if (CustomerCbBox.SelectedIndex > -1)
// do something
}else{//add dbnull to database}
And for adding null to databse, we could pass DBNull.Value instead.
Regards,
Carl
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How to insert a NULL value in SQL using JDBC Adapter

    Hi All,
    I have a File -> JDBC scenario.
    In the File and in the SQL table  I have a column called "MR_DATE" that needs to be mapped
    I have to do the following:
    If MR_DATE is NOT equal to "00000000"
             then pass MR_DATE to SQL table
    else
              set the MR_DATE column in the table as NULL.
    Please suggest
    regards,
    Piyush

    Hi Piyush,
    In the receiver JDBC adapter select the option Interpretation of Empty String Values as NULL.
    Pass date as empty, it will be interpreted as NULL by adapter and inserted in database.
    Regards,
    Gautam Purohit

  • Insert a null value?

    does anyone know how to insert a null value?
    For example:
    insert into tbl_table (col1,col2)
    values (null,null)
    thanks.

    insert into tbl_table (col1,col2)
    values (null,null)
    This query will insert null into the DB, if the column "NOT
    NULL" property is false. Otherwise null can't be inserted into DB.
    If "NOT NULL" is true then,
    insert into tbl_table (col1,col2)
    values ('','') blank value can be inserted, but not null.
    Thanks
    Sankalan
    (www.mindfiresolutions.com)

  • How to insert check box value in table?

    Hi all
    kindly help me how to insert check box value in database. what code i have to use as i am new in programing.
    thanx in advance

    Hi,
    There is no "Check box" in a table, a check box is a GUI (Graphical user interface) item.
    What you want is to store a boolean value in a table. For that you can use the varchar2(1) datatype and store Y or N. (or anything else)
    (you cannot define boolean as a datatype for a column).
    If you're using a front-end application like apex then it might be useful for you to read the documentation about chekc boxes :
    http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10497/check_box.htm#CHDDFBFH
    (for the rest if it's Oracle Forms then everything is already said).
    Edited by: user11268895 on Aug 17, 2010 10:44 AM

  • SQL Loader-How to insert -ve & date values from flat text file into coloumn

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide.

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide. Try something like
    someDate    DATE 'DDMMYYYY'
    someNumber1      "TO_NUMBER ('s99999999.00')"
    someNumber2      "TO_NUMBER ('99999999.00s')"Good luck,
    Eric Kamradt

  • How do I restrict null values??????

    Hi,
    Created BW report Purchase Orders Awaiting Goods Receipting. Having difficulty in restricting the report to those orders that have not been goods receipted. How do I restrict null values. 
    thanks in advance
    S VR

    Hi,
    I believe you are using Standard Business Content.
    You can use the following reports for overcome your requirement:
    Query Name: 0PUR_C01_Q0017 - Quantities – Purchase Order – Delivery - Invoice
    Link: http://help.sap.com/saphelp_nw04/helpdata/en/99/670539b15b186ce10000000a114084/content.htm
    Try to use it. And let me know still you are having some doubts.
    Regards,
    Vivek V

  • How to insert or select value d'silva

    Hi,
    How to insert or select value d'silva into/from table.
    please let me know.
    Thanks,
    Sathis.

    Just escape the ' character:
    SQL> insert into emp values(999, 'D''Silva', 'Jose');
    1 row created.
    SQL> select * from emp where last_name = 'D''Silva';
    EMPLOYEE_ID LAST_NAME                 FIRST_NAME
            999 D'Silva                   Jose
    [pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to insert Google geocoded values in database

    Hi
    I have tried Google map integration with apex , it is wonderful.
    Can I have some tips on how can I insret the same geocoded values in my database for the infrastructure and mesh the infra with google map.
    Please help
    Prashant

    Hi,
    how to insert and update values in mysql database in c++ from"mysql.h"
    Please see some thread with some samples:
    http://www.cplusplus.com/forum/general/118160/
    I suggest you ask this issue to MySQL forum since you are using it.
    http://forums.mysql.com/
    Best regards,
    Shu
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to update the null values to some number on the NUMBER type of column

    Hello All,
    I have one NUMBER type of column in DB table. It has some (null) values. I want to update with value 1. I tried to run the Update statement , It gives 0 rows updated.
    SELECT objectid,attr20 FROM table;
    object id attr20
    ====== ====
    fff70b67-8d54-4ad7-bc57-7b40a0d8b219     (null)
    cac5264a-b363-487b-bfe6-6b84d60064e9     (null)
    2fc2a626-51d8-401c-9495-18aacd4c35c8     (null)
    1b60bfa4-ff68-4488-adf6-2a83528c0e20     (null)
    1c662829-24c1-4b3c-9289-0128e170c043     5
    74f11331-545b-435f-bf4b-f57c7a6b4500     2
    c941c1ac-a18e-47ec-843c-dbe2a5b51001     0
    d7eba203-93c0-48ea-a109-9b06015ef387     0
    eba72fa3-21d8-4489-bb93-917ebbd67de2     0
    I ran following query but no success.
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 = NULL
    0 rows updated
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 = null
    0 rows updated
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 = ''
    0 rows updated
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 =' '
    Error starting at line 1 in command:
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 =' '
    Error report:
    SQL Error: ORA-01722: invalid number
    01722. 00000 - "invalid number"
    *Cause:   
    *Action:
    can some one help me out to update such values ????

    Hi,
    "=" will not work for NULL values. Please remeber two NULL values are NOT same. Try IS operator.
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 IS NULLRegards,
    Avinash

  • HT201209 how do I add higher value "money" to my itunes account with out buying an iTunes gift card instead of buying 1 song at a time?

    how do I add higher value "money" to my itunes account with out buying an iTunes gift card instead of buying 1 song at a time?

    I know you can link your credit card to your Ipad, go to the app strore and go to the bottom and tap apple Id and sighn in then go to payment information and you can set up a credit card. Hope this helps

  • How can I find out the iCloud ID which is registered with my iPhone?

    How can I find out the iCloud ID which is registered with my iPhone? I dont know which ID is actually registered with my phone Please help me

    Someone logged into iCloud with his ID maybe my friend or someone but if I get the email info then I can tell him to remove the lock. The ID is started with s*****@hotmail.com. I already asked few of my friends whos name started with s but still didnt find the right one What can I do now?

  • How to insert a blank value in not nul column using transform activity

    can anyone help me on how to insert blank values in a not null column using transform activity or however possible..This is a requirement in my project ..

    vidya
    In DB adapter or-mappings.xml , did you made any changes. If not the open that file in any notepad editor and change the following
    <attribute-mapping xsi:type="direct-mapping">
    <attribute-name>director</attribute-name>
    <field table="MYTABLE" name="MAKE_IT_BLANK_NOT_NULL" xsi:type="column"/>
    <attribute-classification>java.lang.String</attribute-classification>
    </attribute-mapping>You can try to add this:
    <attribute-mapping xsi:type="direct-mapping">
    <attribute-name>director</attribute-name>
    <field table="MYTABLE" name="MAKE_IT_BLANK_NOT_NULL" xsi:type="column"/>
    <null-value></null-value>
    <attribute-classification>java.lang.String</attribute-classification>
    </attribute-mapping>Refer below link for details
    Re: Insertion of Blank value to a Not Null varchar column in SQL server table
    Thanks
    AJ

  • How to eliminate explicit "null" values

    Hello,
    I am having a problem in eliminating the explicit "null" values while retrieving them from the database.
    Here is my problem as follows,
    For the optional fields in a form i am explicitly entering "null" as value or else it is throwing null pointer exception in linux. While i am trying to display the values existing in a table it is displaying fine when i use this condition
    if(varialble.equals("null") ||varialble.equals("") || variable.equals(null))
    varialble = "";
    else
    out.println(variable)
    But when i use the same for the values i retrieve from the view it is displaying "Null" for the explicit "null" values and null from implicit null values.
    Please help me out how to remove the explicit null values. It would be great help if somebody replies me at the earliest.
    Thanks in advance
    daya

    the following is the code which i am using to retrieve values.
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.*;
    import StrChk.*;
    public class DataSearch extends HttpServlet
         Connection con=null;
         Statement st=null;
         ResultSet rs=null;
         ResultSetMetaData rsmd=null;
         PrintWriter out=null;
         public void doPost(HttpServletRequest req, HttpServletResponse res)
         throws IOException,ServletException
              String key;
              String sql;
              res.setContentType("text/html");
              out = res.getWriter();
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con = DriverManager.getConnection("jdbc:odbc:daya","daya","daya");
                   st = con.createStatement();
              catch(Exception e)
                   System.out.println("Error Accessing DataBase:"+e);
              key = req.getParameter("key");
    //          Search(str1.retString(key));
              Search(key);
         public void Search(String key)
              int res=0;
              boolean flag=true,found=false;
              StringTokenizer strt = new StringTokenizer(key, " ");
              String sql;
              String str1,str2;
              int i=0;
    int count = strt.countTokens();
    String keywords[] = new String[count+1];
              keywords=key;
              i++;
              if(count > 1)
         count++;
                   while(strt.hasMoreTokens())
                   keywords[i] = strt.nextToken();
                        i++;
              out.println("<html><title>DataSearch</title>");
              out.println("<script>");
              out.println("function myclose(){ self.close(); } ");
              out.println("</script><body>");
              for(i=0; i<count && flag==true; i++)
                   try
              /* sql = "select ";
                   sql += " nvl(\"Topic Title\",' '), ";
                   sql += " nvl(\"Name\",' '), ";
                   sql += " nvl(\"Title\",' '), ";
                   sql += " nvl(\"Affiliation\",' '), ";
                   sql += " nvl(\"Street Name\",' '), ";
                   sql += " nvl(\"City\",' '), ";
                   sql += " nvl(\"State\",' '), ";
                   sql += " nvl(\"Country\",' '), ";
                   sql += " nvl(\"Zip Code\",' '), ";
                   sql += " nvl(\"Phone\",' '), ";
                   sql += " nvl(\"Fax\",' '), ";
                   sql += " nvl(\"eMail\",' '), ";
                   sql += " nvl(\"Web Site\",' ') ";
                   sql += " from SEARCHVWUSERDET where ";
                   sql += " lower(\"Name\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Title\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Affiliation\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Street Name\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"City\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"State\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Country\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"eMail\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Web Site\") like " + "lower('%" + keywords[i] + "%')";*/
                   sql = "select ";
                   sql += " nvl(\"Name\",' '), ";
                   sql += " nvl(\"Title\",' '), ";
                   sql += " nvl(\"Affiliation\",' '), ";
                   sql += " nvl(\"Street Name\",' '), ";
                   sql += " nvl(\"City\",' '), ";
                   sql += " nvl(\"State\",' '), ";
                   sql += " nvl(\"Country\",' '), ";
                   sql += " nvl(\"Zip Code\",' '), ";
                   sql += " nvl(\"Phone\",' '), ";
                   sql += " nvl(\"Fax\",' '), ";
                   sql += " nvl(\"eMail\",' '), ";
                   sql += " nvl(\"Web Site\",' '), ";
                   sql += " nvl(\"Key Words\",' ') ";
                   sql += " from searchcombi where ";
                   sql += " lower(\"Name\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Title\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Affiliation\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Street Name\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"City\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"State\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Country\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"eMail\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Web Site\") like " + "lower('%" + keywords[i] + "%') or";
                   sql += " lower(\"Key Words\") like " + "lower('%" + keywords[i] + "%')";
                   sql += " order by \"Name\" ";
                   rs = st.executeQuery(sql);
                   //out.println(sql);
                   if(rs.next())
                        if(i == 0)
                             flag=false;
                        found=true;
                        res=0;
                   do
                        res++;
                   }while(rs.next());
                   out.println(res++);
                   out.println("<center><font color=#ff9999 face=\"verdana, geneva, arial, sans-serif\" size=2><b>Searched for \""+ keywords[i]+"\", ");
                   out.println("Total Matches found : "+res+"</center><br>");
                   rs = st.executeQuery(sql);
                   while(rs.next())
                        res++;
                             out.println("<table width=600 align=center>");
                             str1 = disp(rs.getString(1),keywords[i]);
                             out.println(str1);
                             //if(str1.equals("null") || str1.equals(" ") || str1.equals(null))
                             if(str1 == "null" || str1 == "")
                                  str1 = "";
                             else
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Name </td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>"+str1+"</td></tr>");
                                  //System.out.println(str1);
                                  //out.println(str1);
                             str2="";
                             str1 = disp(rs.getString(2),keywords[i]);
                             if(!str1.equals("") || !str1.equals(""))
                                  str2 = str1;          
                             str1 = disp(rs.getString(3),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  if(str2.length() > 0 || !str2.endsWith(", "))
                                       str2+= ", ";
                                  str2 += str1;
                             if(!str2.equals(""))
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Title, Affiliation</td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>");
                                  out.println(str2);     
                                  out.println("</td></tr>");
                             str2="";
                             str1 = disp(rs.getString(4),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  str2 = str1;          
                             str1 = disp(rs.getString(5),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  if(str2.length() > 0 || !str2.endsWith(", "))
                                       str2+= ", ";
                                  str2 += str1;
                             str1 = disp(rs.getString(6),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  if(str2.length() > 0 || !str2.endsWith(", "))
                                       str2+= ", ";
                                  str2 += str1;
                             str1 = disp(rs.getString(7),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  if(str2.length() > 0 || !str2.endsWith(", "))
                                       str2+= ", ";
                                  str2 += str1;
                             str1 = disp(rs.getString(8),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  if(str2.length() > 0 || !str2.endsWith(", "))
                                       str2+= ", ";
                                  str2 += str1;
                             if(!str2.equals(""))
                                  out.println("<tr><td valign=top width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Address </td>");
                                  out.println("<td><font face=\"verdana, geneva, arial, sans-serif\" size=2>");
                                  out.println(str2);     
                                  out.println("</td></tr>");
                             str1 = disp(rs.getString(9),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Phone</td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>"+str1+"</td></tr>");
                             str1 = disp(rs.getString(10),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Fax</td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>"+str1+"</td></tr>");      
                             str1 = disp(rs.getString(11),keywords[i]).toLowerCase();
                             if(!str1.equals(" ") || !str1.equals(""))
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>eMail</td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>"+str1+"</td></tr>");
                             str1 = disp(rs.getString(12),keywords[i]).toLowerCase();
                             if(str1.equals("null") || str1.equals(" ") || str1.equals(null))
                                  str1="";
                             else
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Web Site</td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>"+str1+"</td></tr>");
                             str1 = disp((rs.getString(13)).replace(',',' '),keywords[i]);
                             if(str1 == "null" || str1 == null || str1 == "")
                             //if(!rs.wasNull())
                                  out.println("nothing");
                             else
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Key Words</td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>"+str1+"</td></tr>");
                             out.println("<tr><td width=150><hr></td><td><hr></td></tr>");
                             out.println("</table><br>");
                   } // end while
                   } // end if
                   catch(Exception e)
                        System.out.println("Exception while executing query: "+ e);
              } // end for
              if(!found)
                   out.println("<center><font color=#ff9999 face=\"verdana, geneva, arial, sans-serif\" size=2><b>Searched for \""+ key+"\", ");
                   out.println("Total Matches found : 0</center><br>");
              out.println("<center><a href=\"javascript:myclose()\"><font color=red face=\"verdana, geneva, arial, sans-serif\" size=2>Close</a></center>");
              out.println("</body></html>");
         public void doGet(HttpServletRequest req, HttpServletResponse res)
         throws IOException,ServletException
              doPost(req,res);
         public String disp(String str1, String str2)
              int i,j,k;
              boolean found=false;
              String s1,s2,s3;
              String t1,t2;
              t1 = initCap(str1);
              s1 = t1.toLowerCase();
              s2 = str2.toLowerCase();
              for(i=0;i<s1.length() && !found ;i++)
                   k=i;
                   for(j=0;j<s2.length() && k < s1.length() && s1.charAt(k) == s2.charAt(j) ;j++,k++);
                   if(j==s2.length())
                        found=true;
              if(found)
                   i--;
                   s3 = t1.substring(0,i);
                   s3 += "<font color=blue face=\"verdana, geneva, arial, sans-serif\" size=2><b>";
                   s3 += t1.substring(i,i+str2.length());
                   s3 += "</font></b>";
                   s3 += t1.substring(i+str2.length(),t1.length());
              else
                   s3 = t1;
              return s3;
         public String initCap(String str)
              StringTokenizer st = new StringTokenizer(str," ");
              String s1="";
              String s2="";
              String s3="";
              String s4="";
              while(st.hasMoreElements())
                   s1 = (String)st.nextElement();
                   if(s1.length() > 0)
                        s2 = s1.substring(0,1);
                        s2 = s2.toUpperCase();
                   if(s1.length() > 1)
                        s3 = s1.substring(1,s1.length());
                   s2 += s3;
                   s4 +=" "+s2;
              return s4;

  • How to check for null values in pl sql?

    Hello,
    I have an sql statement where I read the db column into a number of variables, some of the columns contain NULL values or empty varchars. How can I check if my variable contains any data?
    Thanks,
    J

    to check if your variable contain null or not use like this
    if v_variable is null if you use
    if v_variable=NULL this is right according to syntax but it will not give you desired result
    SQL> declare
      2  v_empname varchar2(20);
      3  v_comm number;
      4  begin
      5  select ename,comm into v_empname,v_comm from emp
      6  where empno=7839 and comm is NULL;
      7  dbms_output.put_line(v_empname);
      8  if v_comm is NULL then
      9  dbms_output.put_line(v_empname);
    10  end if;
    11  end;
    12  /
    KING
    KING
    PL/SQL procedure successfully completed.but if you will use = null then you will not get result
    SQL> declare
      2  v_empname varchar2(20);
      3  v_comm number;
      4  begin
      5  select ename,comm into v_empname,v_comm from emp
      6  where empno=7839 and comm is NULL;
      7  dbms_output.put_line(v_empname);
      8  if v_comm = NULL then
      9  dbms_output.put_line(v_empname);
    10  end if;
    11  end;
    12  /
    KING                   -------------king will get printed only once.
    PL/SQL procedure successfully completed.

  • How can I get null values for the later weeks

    Hi All,
    When I execute this code I get the records till current week.
    How can I display the output so that I get null values for the later weeks. (with the help of v_numOfWeeks variable in the code)
    Thanks,
    Vikram
    DECLARE
       v_query VARCHAR2(4000);
       TYPE ref_cursor IS REF CURSOR;
       v_refcur ref_cursor;
       v_sum NUMBER;
       v_id NUMBER;
       v_name VARCHAR2(1000);
       v_weeknum NUMBER;
       v_pernum NUMBER;
       v_numOfWeeks NUMBER := 5;
    BEGIN
    v_query := ' SELECT SUM(product_bkg), postn_id, postn_tbl.postn_name, b.week_num, b.period_num
                              FROM ops_cv_extract b, (SELECT row_id, desc_text postn_name
                          FROM s_postn) postn_tbl
                          WHERE lvl_6_id = 5767
                          AND fiscal_year = 2008
                          AND b.week_num < 4
                          AND b.period_num = 3
                          AND b.postn_id = TO_NUMBER(postn_tbl.row_id)
                          GROUP BY postn_id, postn_tbl.postn_name, b.week_num, b.period_num
                          ORDER BY  postn_tbl.postn_name, b.week_num';
    OPEN v_refcur FOR v_query;
    LOOP
       FETCH v_refcur INTO v_sum, v_id, v_name, v_weeknum, v_pernum;
       EXIT WHEN v_refcur%notfound;
       dbms_output.put_line('P'|| v_pernum||'W'|| v_weeknum||' '||v_name||' '||v_sum);
    END LOOP;
    END;
    This is the output when I execute this code.
    P3W1 COMM CNTRL ISAM 213 26961.61
    P3W2 COMM CNTRL ISAM 213 12870.4
    P3W3 COMM CNTRL ISAM 213 245.88
    P3W1 COMM CNTRL ISAM 273 72831.2
    P3W2 COMM CNTRL ISAM 273 8739.38
    P3W3 COMM CNTRL ISAM 273 3764.92
    P3W1 COMM CNTRL TAM 213 49844
    P3W2 COMM CNTRL TAM 213 20515.17
    P3W3 COMM CNTRL TAM 213 16167.46
    P3W2 COMM CNTRL TAM 216 12561.4
    P3W3 COMM CNTRL TAM 216 2027.1
    P3W1 COMM CNTRL TAM 273 -3336.71
    P3W2 COMM CNTRL TAM 273 -1376.68
    P3W3 COMM CNTRL TAM 273 19707.42
    P3W1 Damon Walters -609.07
    P3W2 Damon Walters 30030.24
    P3W3 Damon Walters 37475.1
    This is the output I'd like to get
    P3W1 COMM CNTRL ISAM 213 26961.61
    P3W2 COMM CNTRL ISAM 213 12870.4
    P3W3 COMM CNTRL ISAM 213 245.88
    P3W4 COMM CNTRL ISAM 213
    P3W5 COMM CNTRL ISAM 213
    P3W1 COMM CNTRL ISAM 273 72831.2
    P3W2 COMM CNTRL ISAM 273 8739.38
    P3W3 COMM CNTRL ISAM 273 3764.92
    P3W4 COMM CNTRL ISAM 273
    P3W5 COMM CNTRL ISAM 273
    P3W1 COMM CNTRL TAM 213 49844
    P3W2 COMM CNTRL TAM 213 20515.17
    P3W3 COMM CNTRL TAM 213 16167.46
    P3W4 COMM CNTRL TAM 213
    P3W5 COMM CNTRL TAM 213
    P3W1 COMM CNTRL TAM 273 -3336.71
    P3W2 COMM CNTRL TAM 273 -1376.68
    P3W3 COMM CNTRL TAM 273 19707.42
    P3W4 COMM CNTRL TAM 273
    P3W5 COMM CNTRL TAM 273
    P3W1 Damon Walters -609.07
    P3W2 Damon Walters 30030.24
    P3W3 Damon Walters 37475.1
    P3W4 Damon Walters
    P3W5 Damon Walters Edited by: polasa on Oct 28, 2008 6:42 PM

    Sure, in a Single SQL ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>-- Start Of Test Data --
    satyaki>with week_tab
      2  as
      3    (
      4      select 1 period_num, 1 week_num, 10 bkg1 from dual
      5      union all
      6      select 1, 2, 40 from dual
      7      union all
      8      select 1, 3, 30 from dual
      9      union all
    10      select 1, 2, 20 from dual
    11      union all
    12      select 1, 1, 10 from dual
    13      union all
    14      select 1, 1, 20 from dual
    15      union all
    16      select 1, 3, 10 from dual
    17      union all
    18      select 2, 1, 15 from dual
    19      union all
    20      select 2, 2, 20 from dual
    21      union all
    22      select 2, 3, 10 from dual
    23      union all
    24      select 2, 1, 15 from dual
    25      union all
    26      select 2, 2, 30 from dual
    27      union all
    28      select 2, 3, 20 from dual
    29    )
    30  -- End Of Test Data --
    31  select period_num,
    32         week_num,
    33         (
    34            select sum(week_tab.bkg1)
    35            from week_tab
    36            where period_num = m.period_num
    37            and   week_num   = m.week_num
    38            group by week_num, period_num
    39         ) sum_bkg1
    40  from (
    41        select dum.week_num,
    42              wk.period_num
    43        from (
    44                select 1 week_num from dual
    45                union all
    46                select 2 from dual
    47                union all
    48                select 3 from dual
    49                union all
    50                select 4 from dual
    51                union all
    52                select 5 from dual
    53              ) dum ,
    54              (
    55                select distinct period_num
    56                from week_tab
    57          ) wk
    58      ) m;
    PERIOD_NUM   WEEK_NUM   SUM_BKG1
             1          1         40
             1          2         60
             1          3         40
             1          4
             1          5
             2          1         30
             2          2         50
             2          3         30
             2          4
             2          5
    10 rows selected.
    Elapsed: 00:00:00.48
    satyaki>Regards.
    Satyaki De.

Maybe you are looking for