How to validate similar columns fetched by the cursor

Hi,
I have one table which has columns like COMP_PART_NUMBER_1 , COMP_PART_NUMBER_2 up to COMP_PART_NUMBER_50
Need to validate columns as shown below,I want to know how to make create dynamic script for the below validation so that there is no need to add same logic for 50 times.
IF rec_SCR_assy.COMP_PART_NUMBER_1 IS NOT NULL THEN
IF LENGTH(rec_SCR_assy.COMP_PART_NUMBER_1) > 8 THEN
     v_error_description := NVL(v_error_description,'') || 'The Component 1 Part Number length should not be greater than 8| ';
ELSE
v_upd_script := ' COMP_PART_NUMBER_1 = ''' || rec_SCR_assy.COMP_PART_NUMBER_1 || '''';
END IF;
END IF;
I have tried to create pl sql block as :-
FOR vcnt IN 1..50
LOOP
VFIELD_COMP_PART := 'COMP_PART_NUMBER_' || VCNT;
v_exec_query:=' begin
IF rec_SCR_assy.'||VFIELD_COMP_PART ||' IS NOT NULL THEN
IF LENGTH(rec_SCR_assy.'||VFIELD_COMP_PART||') > 8 THEN
:v_error_description := NVL(:v_error_description,'''') || ''The Component 1 Part Number length should not be greater than 8| '';
ELSE
:v_upd_script := '' rec_SCR_assy.'||VFIELD_COMP_PART||' = '''''' ||rec_SCR_assy.'||VFIELD_COMP_PART ||'||'''''''';
end if;
END IF; end;';
execute immediate V_EXEC_QUERY using v_error_description,v_upd_script;
This code is giving an error as it is not possible to create a bind variable to the cursor in dynamic script.
Please help me to find the solution for it.Thanks in advance.

Try like this ...
DECLARE
   v_exec_query   VARCHAR2 (4000);
BEGIN
   FOR i IN (SELECT column_name
               FROM all_tab_cols
              WHERE table_name = 'EMP')
   LOOP
      v_exec_query :=
            ' begin
IF rec_SCR_assy.'
         || i.column_name
         || ' IS NOT NULL THEN
IF LENGTH(rec_SCR_assy.'
         || i.column_name
         || ') > 8 THEN
:v_error_description := NVL(:v_error_description,'''') || ''The Component 1 Part Number length should not be greater than 8| '';
ELSE
:v_upd_script := '' rec_SCR_assy.'
         || i.column_name
         || ' = '''''' ||rec_SCR_assy.'
         || i.column_name
         || '||'''''''';
end if;
END IF; end;';
      DBMS_OUTPUT.put_line (v_exec_query);
   END LOOP;
END;
--Output
BEGIN
   IF rec_scr_assy.emp_info IS NOT NULL
   THEN
      IF LENGTH (rec_scr_assy.emp_info) > 8
      THEN
         :v_error_description :=
               NVL (:v_error_description, '')
            || 'The Component 1 Part Number length should not be greater than 8| ';
      ELSE
         :v_upd_script :=
               ' rec_SCR_assy.EMP_INFO = ''' || rec_scr_assy.emp_info || '''';
      END IF;
   END IF;
END;
BEGIN
   IF rec_scr_assy.deptno IS NOT NULL
   THEN
      IF LENGTH (rec_scr_assy.deptno) > 8
      THEN
         :v_error_description :=
               NVL (:v_error_description, '')
            || 'The Component 1 Part Number length should not be greater than 8| ';
      ELSE
         :v_upd_script :=
                   ' rec_SCR_assy.DEPTNO = ''' || rec_scr_assy.deptno || '''';
      END IF;
   END IF;
END;
BEGIN
   IF rec_scr_assy.comm IS NOT NULL
   THEN
      IF LENGTH (rec_scr_assy.comm) > 8
      THEN
         :v_error_description :=
               NVL (:v_error_description, '')
            || 'The Component 1 Part Number length should not be greater than 8| ';
      ELSE
         :v_upd_script :=
                       ' rec_SCR_assy.COMM = ''' || rec_scr_assy.comm || '''';
      END IF;
   END IF;
END;
BEGIN
   IF rec_scr_assy.sal IS NOT NULL
   THEN
      IF LENGTH (rec_scr_assy.sal) > 8
      THEN
         :v_error_description :=
               NVL (:v_error_description, '')
            || 'The Component 1 Part Number length should not be greater than 8| ';
      ELSE
         :v_upd_script :=
                         ' rec_SCR_assy.SAL = ''' || rec_scr_assy.sal || '''';
      END IF;
   END IF;
END;
BEGIN
   IF rec_scr_assy.hiredate IS NOT NULL
   THEN
      IF LENGTH (rec_scr_assy.hiredate) > 8
      THEN
         :v_error_description :=
               NVL (:v_error_description, '')
            || 'The Component 1 Part Number length should not be greater than 8| ';
      ELSE
         :v_upd_script :=
               ' rec_SCR_assy.HIREDATE = ''' || rec_scr_assy.hiredate || '''';
      END IF;
   END IF;
END;
BEGIN
   IF rec_scr_assy.mgr IS NOT NULL
   THEN
      IF LENGTH (rec_scr_assy.mgr) > 8
      THEN
         :v_error_description :=
               NVL (:v_error_description, '')
            || 'The Component 1 Part Number length should not be greater than 8| ';
      ELSE
         :v_upd_script :=
                         ' rec_SCR_assy.MGR = ''' || rec_scr_assy.mgr || '''';
      END IF;
   END IF;
END;
BEGIN
   IF rec_scr_assy.job IS NOT NULL
   THEN
      IF LENGTH (rec_scr_assy.job) > 8
      THEN
         :v_error_description :=
               NVL (:v_error_description, '')
            || 'The Component 1 Part Number length should not be greater than 8| ';
      ELSE
         :v_upd_script :=
                         ' rec_SCR_assy.JOB = ''' || rec_scr_assy.job || '''';
      END IF;
   END IF;
END;
BEGIN
   IF rec_scr_assy.emp_no IS NOT NULL
   THEN
      IF LENGTH (rec_scr_assy.emp_no) > 8
      THEN
         :v_error_description :=
               NVL (:v_error_description, '')
            || 'The Component 1 Part Number length should not be greater than 8| ';
      ELSE
         :v_upd_script :=
                   ' rec_SCR_assy.EMP_NO = ''' || rec_scr_assy.emp_no || '''';
      END IF;
   END IF;
END;
BEGIN
   IF rec_scr_assy.sys_nc00009$ IS NOT NULL
   THEN
      IF LENGTH (rec_scr_assy.sys_nc00009$) > 8
      THEN
         :v_error_description :=
               NVL (:v_error_description, '')
            || 'The Component 1 Part Number length should not be greater than 8| ';
      ELSE
         :v_upd_script :=
               ' rec_SCR_assy.SYS_NC00009$ = '''
            || rec_scr_assy.sys_nc00009$
            || '''';
      END IF;
   END IF;
END;
BEGIN
   IF rec_scr_assy.ename IS NOT NULL
   THEN
      IF LENGTH (rec_scr_assy.ename) > 8
      THEN
         :v_error_description :=
               NVL (:v_error_description, '')
            || 'The Component 1 Part Number length should not be greater than 8| ';
      ELSE
         :v_upd_script :=
                     ' rec_SCR_assy.ENAME = ''' || rec_scr_assy.ename || '''';
      END IF;
   END IF;
END;Regards,
Friend

Similar Messages

  • How to create  some columns dynamically in the report designer depending upon the input selection

    Post Author: ekta
    CA Forum: Crystal Reports
    how  to create  some columns dynamically in the report designer depending upon the input selection 
    how  export  this dynamic  report in (pdf , xls,doc and rtf format)
    report format is as below:
    Element Codes
    1
    16
    14
    11
    19
    10
    2
    3
    Employee nos.
    Employee Name
    Normal
    RDO
    WC
    Breveavement
    LWOP
    Sick
    Carers leave
    AL
    O/T 1.5
    O/T 2.0
    Total Hours
    000004
    PHAN , Hanh Huynh
    68.40
    7.60
    76.00
    000010
    I , Jungue
    68.40
    7.60
    2.00
    5.00
    76.00
    000022
    GARFINKEL , Hersch
    66.30
    7.60
    2.10
    76.00
    In the above report first column and the last columns are fixed and the other columns are dynamic depending upon the input selection:
    if input selection is Normal and RDO then only 2 columns w'd be created and the other 2 fixed columns.
    Can anybody help me how do I design such report....
    Thanks

    Hi Developer life,
    According to your description that you want to dynamically increase and decrease the numbers of the columns in the table, right?
    As Jason A Long mentioned that we can use the matrix to do this and put the year field in the column group, amount fields(Numric  values) in the details,  add  an filter to filter the data base on this column group, but if
    the data in the DB not suitable to add to the matrix directly, you can use the unpivot function to turn the column name of year to a single row and then you can add it in the column group.
    If there are too many columns in the column group, it will fit the page size automatically and display the extra columns in the next page.
    Similar threads with details steps for your reference:
    https://social.technet.microsoft.com/Forums/en-US/339965a1-8cca-41d8-83ef-c2548050799a/ssrs-dataset-column-metadata-dynamic-update?forum=sqlreportings 
    If your still have any problem, please try to provide us more details information, such as the data structure in the DB and the table structure you are currently designing.
    Any question, please feel free to let me know.
    Best Regards
    Vicky Liu

  • How can i register column with in the query

    hi all
    how can i register column with in the query?

    Thanks.
    In my business one, the column width was registed.
    But I don't know how can I do it.
    So I try to save the query again after change column width.
    Then the query was opend with changed column width.
    Is it right function?
    Is there any way to register the column width?
    It's very troublesome to change column width every time.
    seiichi

  • How to display a Column Header for the characteristic Text column

    Hi All
    Our users want me to provide for a column header for the characteristic text.
    Here is what I mean
    I am reporting 0plant in the rows as key and Text. In the column on Plant Key the column header says Plant but there is no column header for the plant text.
    Eq:
    Plant                                                        Amount
    IE00         Initiator Plant                               244
    IE01         Initiator Plant NJ                          890
    Our users in the plant text column want a dummy column header to be displayed. SInce they download the data from the BW report to Excel and use pivot reporting. How can I introduce a column header for the texts.
    Thanks
    Karen

    Hi Karen,
    I am not sure if this is possible, although Users can ask anything :).
    In Planning we used to predefine cell headings via Macros and creating dummy cells in between.  I am not sure if a similar scenario can work here.
    By default this is not possible in Reports.  In BEx workbooks, you could probably try with Macros.
    Another easy option is to bring the data in the Cube as another field or create a nav. attribute in the master for text and use it as a nav. attr. in the Cube and put it in your Query row alongside.
    -Aby

  • How to add a column that shows the difference of two metrics columns?

    I created a pivot table with two metrics columns. One metrics column has the aggregation rule of 'Min', the other has 'Max'. Now I want to add a column to show the difference of these two metrics for each row. Is this possible? How to do it? Thank you in advance.

    Use TimeStampdiff:
    TIMESTAMPDIFF(SQL_TSI_HOUR, MIN(xxxx), MAX(xxx))
    It's in the help file if you need more help.
    regards
    Alex

  • How to parse XML string fetched from the database

    i want to parse the XML string which is fetched from the oracle database.
    i have inserted the string in xml format in the database. The type of the field in which it is inserted is varchart2.
    I am successfully getting it using jdbc, storing it in a String.
    Now it is appended with xml version 1.0 and string is ready for parsing.
    Now i am making following programming.
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = Builder.parse(xmlString);
    Element root = doc.getDocumentElement();
    NodeList node = root.getElementsByTagName("product");
    But i am getting IOException at the statement
    Document doc = Builder.parse(xmlString);
    there fore i request u to kindly help me in solving this error.
    -regards
    pujan

    DocumentBuilder does not have a method parse with xml string as aparameter. The string should be a xml document uri.
    Convert xml string to StringReader.
    parse(new InputSource(new StringReader(xmlString)));

  • Cursor tips : refresh data fetched by the cursor within run time,discussion

    Hello there,
    May be what I am asking about is kind of weird, but here is the Q:
    let us assume that I have cursor defined as follows:
    cursor emp_cursor is
            select EMPNO, ENAME, deptno
            from emp
            where deptno = 10 ;
    emp_rec  emp_cursor%rowtype;  then inside the loop through the data fetched by this cursor, I need to update some records, which might match the criteria of the cursor, by trying the following code segment:
    open emp_cursor;
          loop
            fetch emp_cursor into emp_rec;
            exit when emp_cursor%notfound;
            "PROCESS THE RECORD'S DATA "
            DBMS_OUTPUT.Put_Line('count of the records: ' || emp_cursor%rowcount);
            DBMS_OUTPUT.Put_Line('deptno: ' || emp_rec.deptno);
            DBMS_OUTPUT.Put_Line('emp no: ' || emp_rec.empno);
            update emp
            set deptno = 10
            where empno= 7566;
            commit;
            DBMS_OUTPUT.Put_Line('after the update');
          end loop;
          close emp_cursor; but the run never shows the record of employee 7566 as one record of the cursor, may be this is the execution plan of the cursor,
    but for the mentioned case, need to re-enter those updated records to the cursor data, to be processed, ( consider that the update statement is conditioned so that not executed always)
    any hints or suggestion
    Best Regards,

    John Spencer wrote:
    Justin Cave wrote:
    Not possible. You'd have to close and re-open the cursor in order to pick up any changes made to the data after the cursor was opened.Then close and re-open it to get any changes made while processing the second iteration, then close and re-open it to get any changes made while processing the third iteration ad infinitum :-)I'm not claiming there are no downsides to the process :-)
    On a serious note, though, the requirement itself is exceedingly odd. You most likely need to rethink your solution so that you remove this requirement. Otherwise, you're likely going to end up querying the same set of rows many, many, many times.
    Justin

  • How to calculate a column bases on the result of another column?

    Hello folks, i need some help with this senario.
    I don't know to explain this in a simple way, but i'll give it a go.
    I display a report in ApplicationExpress like this
    Each row displays a product where the user are going to make a forecast for 18 months ahead.
    [productname] [Stock] [sales] [PMonth] [NewstockMonth] [salesmonth1]      [ProductionMonth1]     [NewstockMonth1] ....
    [product1]______[10]____[5]____[0]_________[5]__________[10]_________[10]______________[5]
    [product2]______[2 ]____[0]____[0]_________[2]__________[5]__________[10]______________[ 7]
    [product3]______[30]____[20]___[0]_________[10]_________[5]_________[10]______________[15]
    Stock and sales are results of a function i have in my select.
    productionmonth is a text field where the user can edit the production and is saved in the table.
    So when the user has entered some inputs in the textboxes, and pressed the submit buttom, the newstockmonth columns
    should be calculated from the result i get from the previous month.
    newstockmonth = (stock-sales)+productionMonth
    newstockmonth1 =(newstockmonth-salesmonth1)+productionmonth1
    At this point my submit process has update in a for loop for each row. But i don't quite know how i can calculate every newstockmonth columns.

    Hi Klaus,
    your condition only works if the Shop is in the query. If I understood it correctly you have one query with
    Country   Shop   Total Sales
    and one with
    Country   Number of Shops   Total Sales
    and you don't want to restrict the second Total Sales but the Total Sales from the first query.
    Best regards
       Dirk

  • How to validate date columns in tabular forms?

    Hi,
    I have two date columns in a tabular form
    1.Start_date 2.End_date so here i need to validate the end_date as should not be lesser value than start_date column
    so any solution for this?

    Hi,
    use a validation of type "Function returning boolean" and the following code:
    IF to_date(:YOUR_END_DATE,'YYYY-MM-DD') < to_date(:YOUR_START_DATE,'YYYY-MM-DD') THEN RETURN FALSE;
    ELSE RETURN TRUE;
    END IF;The date format is of course in your choice.
    Hope this helps...
    Thanks
    Sandro

  • How to un-group columns on my the report and how to add an export to PDF

    Hello OBIEE developers...
    So, I have this report with about 7 columns, I just submitted to my boss he came back saying "Don’t group the columns, the users typically want to see data on each row".... I am not quite sure what in the world he is talkign about, do I need to report each separate or if separate how do start that? I am sorry I am new to this area, some of my questions might be senseless..
    Also, on the same dashboard I am required to add an option where users can export the dashboard to PDF, how do I go about that?
    please help
    Edited by: 994621 on Apr 25, 2013 10:32 AM

    Sri,
    Right, may be that's what I should have said: once you've opened the dashboard then I need to export it as a dashboard. How do I that? There is a way, my predecessor was able to do it. I have a report with a print as a pdf on the dashboard with pdf icon on it (its a separate dashboard from the report) and you are able to print it as the pdf doc. I just can't figure out how he was able to do this,
    Any idea?
    Edited by: 994621 on Apr 25, 2013 2:13 PM

  • How to switch of Column sorting in the Web (7.0)

    Hi All,
    In my 7.0 created Web report I get a sorting icon in each column header. It's probably a basic question but how can I make these sorting icons disappear from my report? Probably a analysis item setting, but I can't find it.
    Many thanks,
    Ron

    Hi,
    you can use a command to custome a report, report Interface (RRI).
    You have to customize it with the transaction RSBBS (jump).
    You define a sender your query andf receveir another query.
    Then you can use a standard web item = Button group.
    In the internal display you custom a button. In menu you choose ' Command via command wiaizar' -> all command -> command for data provider -> Basic data provider command -> RRI
    Hope it helps

  • How to validate lov column

    Hi All,
    its very urgent.
    i have one page,page having lov,create and clear buttons.
    normally user select lov in list of values and click on the create button it ll navigate to next page.
    and also click on the clear button it ll clear the column.
    but my requirement is,in lov column user enter manually(this value not in list of values).
    and user click on the create button at that time page ll not move to next page i need to open list of values page.
    how to reslove this issue.
    please guide me
    Thanks in advance.
    Edited by: its urgent on Mar 13, 2012 6:51 AM

    If this value is false, then it pops up the LOV if the value is not valid.
    Not sure why you are not getting it. Try to play with other properties.
    Regards,
    Peddi

  • How do I make columns fixed in the CAT2 view

    We are using CATS in SAP version 4.6c.
    I would like to make the left columns, in the CAT2 timesheet view, fixed (eg. rec. cost center), so when you scoll only the weekdays/time columns "moves".
    Anybody who know how to do that if possible at all?
    /Finn

    Hi Finn,
    In CAT2 screen, in the right most side of Data Entry Area(Table control), there is button called 'Configuration' (it has a Table icon). Clik that button & then clik on
    'Administrator' there you will see the settings i.e.
    'No. of fixed columns'. Choose '4' or what ever you want & activate & close it. You will get the disired output.
    All the Best!
    Thanks,
    Sarika.

  • How do I merge columns but keep the content in both?

    I'm using Numbers '09.
    If I have first names in column A and last names in column B...how do I combine both into column A to look like this: Last Name, First Name (ex:  Doe, John)?
    Thanks,
    Mark

    m,
    First, add a new column "before" the existing column A. It's not possible to combine the current content of A with the current content of B and have them appear in the place of the original Column A data. So, we add a new column for the combination. If you don't want to continue to display the original First Name data hide that column.
    When you combine two character strings, it's called Concatenation. There's a concatenation operator and a concatenation function. You can use either. Here are examples that meet your spec:
    In the first data row of the new column A, write: =C&", "&B
    Copy and Paste or Fill to the rest of column A.
    Regards,
    Jerry

  • How to validate detail columns on a Master-Detail page

    How do you add validation to the detail columns/items on a Master-Detail page? For example I want to execute a 'not null' validation on a column in a detail row when the user attempts to add a new row.
    Edited by: user9108091 on Oct 12, 2010 8:58 AM

    Is the detail a tabular-form style?
    If you are in version 4.x you can add it like any other validation.
    If you are in version 3.x and below, you have to write your own PL/SQL validation using the wwv_flow.g_f01, g_f02, etc. arrays and make the validation a type of "function returning error text". A not-null return value will be your error message. A null return value will be synonymous with passing validation. Unfortunately this method is a bit inelegant in that if you display the error on the same page, the screen usually repaints as part of the whole process and since the row was not saved (nor any other changes the user may have made to existing rows) the new row will disappear. If you display on the error page, the error is a bit inconvenient/inconsistent for the end user relative to item-level error display, but the page will usually be cached in the browser's cache and the state of what the user entered is retained.
    The error page also usually defaults to the "login" template. If it did, this is rather unattractive, IMHO. If you switch it to your current page tempate for most of your application pages (e.g.: two level tabs), even though it doesn't have tabs it will look a little more consistent with your other application pages.

Maybe you are looking for

  • Mass activity report

    Hello, I would need to create a report compliant with mass activities. Does anyone know where I could find some documentation (in English) about that? I found a bunch of function modules like FKK_AKTIV2_RUN_KEY_CONSTRUCT that are directly related wit

  • IDOC Types

    Hi all,   can anyone let me know the difference between the 4 IDOC type MATMAS01 MATMAS02 MATMAS03 MATMAS04 Regards Simin.R

  • Packet drop when clients moving from one Access point to another

    HI  All , I am new to wireless . I am using  WS-SVC-WISM-1-K9  wism module and using 5 Access points . When my clients are moving from one access point to another we are getting packet drops . Kindly anyone suggest me what all configuration i need to

  • Who wants to be a Millionaire ??? CODE???

    hi i'm tryin to make a basic game who wants to be a millionaire...i got the following..layout of the textfield textarea etc.. but i cant seem to use the vectors to store the questions from a txt file then transfer it over to the textarea box or radio

  • CRITICAL BUSINESS PROCESS MAPPING

    HI FRIENDS                  UNDER THE PROJECT I AM WORKING WHERE CLIENT HAS A SPECIFIC REQUIREMENT - MY CLENT IS A PHARMACEUTICAL HOUSE. NOW THEY DO FREE SAMPLE DELIVERY TO MEDICAL REPRESENTATIVES. FREE DELIVERY IS NOT A PROBLEM BUT HOW I WILL MAP ME