Multiple clobs in a single row of data

I have several clobs in a single row of data and have created a procedure where I attempt to display the first 4k of each clob.
using a for loop cursor I select all of the clobs in a row at the same time and then I use dbms_lob.read to get the first 4k of data.
For the first lob of each row everything works fine but when I attempt to dbms_lob.read the second one I get an "ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275" and I'm not sure why?
does anyone know of an example where two or more clobs are selected and then converted to 4K varchars?
sample columns for the table:
SPECIALREQUIREMENTSS     CLOB
REFERENCERANGE     CLOB
ALERTVALUE     CLOB
REFERENCELAB     VARCHAR2(50 CHAR)
TESTINCLUDES     CLOB
LASTUPDATE     DATE
sample code (I removed some code for clairity - this produces the same error):
create or replace
procedure test_lobs as
v_lab_blob blob;
v_lobamt binary_integer := 32767;
v_lobpos pls_integer := 1;
v_labrec labman.lab_testingdata%rowtype;
v_buffer varchar2(32767) :='';
v_start_left number;
begin
-- *** housekeeping
dbms_lob.createtemporary(v_labrec.testincludes,TRUE);
dbms_lob.createtemporary(v_labrec.specialrequirementss,TRUE);
Plpdf.init;
Plpdf.NewPage;
Plpdf.SetColor4Drawing(66,66,66);
Plpdf.SetColor4Filling(180,180,180);
v_start_left := Plpdf.GetPageWidth-Plpdf.GetPageRightSpace;
-- *** select the test name for shaded printing
for x in (select indexnumber, test from labman.lab_testingdata where test like 'A%') loop
-- *** select the test data for printing
select * into v_labrec from labman.lab_testingdata where indexnumber = x.indexnumber;
-- *** test includes
if dbms_lob.getlength(v_labrec.testincludes) > 0 or v_labrec.testincludes is not null then
Plpdf.SetPrintFont('Arial','B',8);
Plpdf.LineBreak(.1);
Plpdf.PrintCell(25,5,'Test Includes:',0,0,'R',0,null,0);
Plpdf.SetPrintFont('Arial',null,8);
if dbms_lob.getlength(v_labrec.testincludes) > 32767 then
v_buffer := '*** error - text is greater than 32k ***';
else
v_lobamt := 32767;
v_buffer := '';
dbms_lob.read(v_labrec.testincludes,v_lobamt,v_lobpos,v_buffer);
end if;
Plpdf.SetLeftMargin(Plpdf.GetCurrentX);
Plpdf.PrintFlowingText(5,v_buffer,null,0);
Plpdf.SetLeftMargin(v_start_left);
Plpdf.lineBreak;
end if;
-- *** special requirements
Plpdf.SetPrintFont('Arial','B',8);
Plpdf.LineBreak(.1);
Plpdf.PrintCell(25,5,'Special Requirements:',0,0,'R',0,null,0);
Plpdf.SetPrintFont('Arial',null,8);
if dbms_lob.getlength(v_labrec.specialrequirementss) > 32767 then
v_buffer := '*** error - text is greater than 32k ***';
elsif dbms_lob.getlength(v_labrec.specialrequirementss) = 0 then
v_buffer := '';
else
v_lobamt := 32767;
v_buffer := '';
dbms_lob.read(v_labrec.specialrequirementss,v_lobamt,v_lobpos,v_buffer);
end if;
Plpdf.SetLeftMargin(Plpdf.GetCurrentX);
Plpdf.PrintFlowingText(5,v_buffer,null,0);
Plpdf.SetLeftMargin(v_start_left);
Plpdf.lineBreak;
commit;
end loop;
Plpdf.SendDoc(v_lab_blob);
-- store the PDF document
delete from store_blob;
commit;
INSERT INTO STORE_BLOB (blob_file, created_date)
VALUES (v_lab_blob, SYSDATE);
COMMIT;
end test_lobs;

didn't think that checking for a length of zero and null would produce two different results - should have known better.
Thanks for your help!
elsif dbms_lob.getlength(v_labrec.specialrequirementss) = 0
or v_labrec.specialrequirementss is null then

Similar Messages

  • How to loop through a single row of data?

    What I'm trying to do is use a cursor to loop through a clob. When I create my cursor I get the an error telling me that the table does not exist. Which implies that I have an implicit cursor. Is there a way to get around this?

    > How to loop through a single row of data?
    By not looping as there is only a single row?
    > What I'm trying to do is use a cursor to loop through a clob
    Processing (looping through) a CLOB has nothing to do with a cursor.
    > When I create my cursor I get the an error telling me that the table does
    not exist. Which implies that I have an implicit cursor.
    Incorrect. It simply means that
    a) you do not have permissions to access that table from within the current context
    b) it does not exist (e.g. you have misspelled the object name, you have not qualified it properly within the current scope, etc)

  • Customizing Sharepoint Calendar Week Group View to display multiple weeks in a single row

    Hi,
    SharePoint Calendar's Week Group View is useful for comparing multiple co-worker's schedule, and we have a business needs to be able to view the schedule for with the date range of more than one week at a time between co-workers for planning purposes, is
    there a way (code or no-code) to manipulate the date/week range so that the calendar display more than 7 days in a single row?

    Hi,
    As there is no such OOTB feature, I would suggest that you can change the calendar scope to “Month” or create a Gantt view to display more weeks in a view.
    Or you can try to create a custom calendar web part to meet your requirement.
    Here are some samples of custom calendar web part for your reference:
    http://www.codeproject.com/Articles/108676/SharePoint-Custom-Calendar
    http://gunnarpeipman.com/2009/01/creating-sharepoint-global-calendar/
    https://blog.metrostarsystems.com/2013/10/21/creating-a-custom-sharepoint-calendar-rollup/
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to update a single row of data table

    How we can update a single row of the data table by clicking the button in the same row.
    Thanks in Advance.

    Hi!
    What do You mean 'update'? Get fresh data from DB or change data and commit it in DB?
    If commit, try to read here:
    http://developers.sun.com/jscreator/learning/tutorials/2/inserts_updates_deletes.html
    Thanks,
    Roman.

  • Inserting table in web form/ Inserting multiple cells in a single row

    Dear Mr Johnson,
    Thanks for your early reply.
    I am rather disappointed .....as I need to distribute my form urgently with a table insertion capability.
    I had purchased Adobe webform central subscription with the idea that a paid subscription will fetch me the full editing capability of the Adobe form central web forms.
    Please inform me as to when this vital update regarding the table insertion/ multiple cells insertion in a single row capability (update) will be functional and available for our use as today is 26th of January, 2013.
    Kindly reply ASAP.
    Thanks,
    with kind regards,
    Dr Ali

    See this thread from two days ago where Randy Swineford of Adobe says that it is expected to be added at the end of January: http://forums.adobe.com/thread/1140470?tstart=0
    I don't know if it will include a table tool.

  • Showing multiple Objects in a single row in Gantt Chart

    Hi,
    I am wokring on extending the cPro4.5 gantt chart.
    I have a tree hierarchy which I want to display on the Gantt Chart. But my need is to display all the children and its parent in single row i.e. in a new row bove the Poject row in the gantt tree (hierarchy shown on the left side) of existing chart.
    Is it possible with the Gantt chart?
    If yes, then where and how do I pass this information to the transformation I call in the end to convert the abap tables into XML file which is finally shown on the gantt.
    Kindly guide.
    Regards,
    Varun

    Hi Varum,
    Sorry but I think I don't understand your requirement. Do you need see on the left of your gantt project structure?
    Thanks,
    Sara

  • Multiple clobs for a single record, best approach

    In the past, we've typically dealt with a single clob per table, maybe 2 at the most, but in a recent design session our users indicated a need to have about 10 >4000 byte fields in order to records different aspects of code violations. In many cases, only 3-4 of these will exceed the 4000 character limit at any one time, but it could be any 3 of the potential 10 (and under those circumstances, the other 7 of 10 will contain data, they just wouldn't be the main focus of the overall entry).
    We're using 8K blocks in our system right now, and so even if I tasked our Analyst with keely trying to determine if all of these fields were truly CLOB-worthy, we'd still be exceeding 8K if we converted some of these 10 fields into VARCHAR2 (2000-4000 byte) columns.
    One idea that came up, was to create a separate 1:1 table which only contains the 10 CLOBS, since they're not expected to be searched during any OLTP activity. That way, any occasional full table scans wouldn't have to load the "header" of any CLOBs stored inline. That seemed like a good solution, but I thought I'd post here so see what other alternatives are out there.
    Thanks,
    --=Chuck

    didn't think that checking for a length of zero and null would produce two different results - should have known better.
    Thanks for your help!
    elsif dbms_lob.getlength(v_labrec.specialrequirementss) = 0
    or v_labrec.specialrequirementss is null then

  • IR: Display single row of data over multi report rows.

    In an interactive report, is it possible to display the data from one database row over two or more displayed rows on a page?

    Corvette Captain wrote:
    In an interactive report, is it possible to display the data from one database row over two or more displayed rows on a page?Yes. Create the required structure using the Detail View properties.
    Users can switch between views using the view controls. You can display the report in Detail View by default via a Dynamic Action: +{thread:id=2187972}+

  • Merge 2 rows into single row with data update?

    hello all,
    i have a table with below data,
    declare @tbl table (uid int, uname varchar(10), start_dt date, end_dt date)
    insert into @tbl values (1, 'env1', '4/4/2010', '5/5/2012')
    insert into @tbl values (2, 'env2', '5/4/2010', '6/6/2012')
    --earlier start data is '4/4/2010' from 'env1'
    --latest end data is '6/6/2012' from 'env2'
    insert into @tbl values (3, 'env1', '3/3/2010', '4/4/2012')
    insert into @tbl values (4, 'env2', '2/2/2010', '5/5/2012')
    --earlier start data is '2/2/2010' from 'env2'
    --latest end data is '5/5/2012' from 'env2'
    insert into @tbl values (5, 'env1', '8/8/2010', '12/12/2012')
    insert into @tbl values (6, 'env2', '9/9/2010', '10/10/2012')
    --earlier start data is '8/8/2010' from 'env1'
    --latest end data is '12/12/2012' from 'env1'insert into @tbl values (6, 'envX', '9/9/2010', '10/10/2012')insert into @tbl values (6, 'envY', '9/9/2010', '10/10/2012')
    i need to merge 2 rows for column  "uname" having value "env1" & "env2" to "envZ" and need to capture earlier start date and latest end date from both and update with new.
    the desire output should be,
    declare @tbl table (uid int, uname varchar(10), start_dt date, end_dt date)
    insert into @tbl values (1, 'envZ', '4/4/2010', '6/6/2012')
    insert into @tbl values (4, 'envZ', '2/2/2010', '5/5/2012')
    insert into @tbl values (5, 'envZ', '8/8/2010', '12/12/2012')
    insert into @tbl values (6, 'envX', '9/9/2010', '10/10/2012')
    insert into @tbl values (6, 'envY', '9/9/2010', '10/10/2012')
    note - i must need to update one row and delete other row as i can't insert new rows (having huge data with other columns also).
    please suggest optimize query. thanks!

    Which version and edition of SQL Server are you using?
    Whenever there is a row with 'env1', there is a corresponding 'env2' and vice versa? 
    The row with 'env2' is always after the row with 'env1'?   (uid+1)
    If the answers are yes to both questions above, here's a possibility:
    -- code #1 v3
    ;with
    ENVZ as (
    SELECT uid= case when T1.start_dt <= T2.start_dt then T1.uid else T2.uid end,
    start_dt= case when T1.start_dt <= T2.start_dt then T1.start_dt else T2.start_dt end,
    end_dt= case when T1.end_dt > T2.end_dt then T1.end_dt else T2.end_dt end
    from @tbl as T1
    inner join @tbl as T2 on T2.uid=T1.uid+1 and T2.uname='env2'
    where T1.uname = 'env1'
    MERGE
    into @tbl as T3
    using ENVZ as T4
    on T3.uid = T4.uid
    when matched and (T3.uname in ('env1','env2')) then
    UPDATE set T3.uname= 'envZ',
    T3.start_dt= T4.start_dt,
    T3.end_dt= T4.end_dt
    when not matched by source and (T3.uname in ('env1','env2')) then
    DELETE;
    The table @tbl is read three times in the above code. There are probably ways to optimize the above code. Or even other more efficient approach.
    José Diz     Belo Horizonte, MG - Brasil

  • How to Disassemble Varying Multiple Repeating Records from Single Row

    I have a flat file that has hundreds of thousands of rows.  Each row is a new record.
    On each row there are about 23 elements that occur once per row and then there are two groups of 4-6 fields each group that repeat a certain number of times.  There is an integer field before each group that indicates how many times the group repeats
    0 or greater.  An few examples rows are the following. 
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|0|0
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|1|b|b|b|b|0
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|2|b|b|b|b|c|c|c|c|0
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|2|b|b|b|b|c|c|c|c|1|d|d|d|d|d|d
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|2|b|b|b|b|c|c|c|c|2|d|d|d|d|d|d|e|e|e|e|e|e
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|0|1|b|b|b|b|b|b
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|0|2|b|b|b|b|b|b|c|c|c|c|c|c
    I'd rather not do a custom pipeline if possible unless there is something already written.
    thanks in advance.

    Thank you for the quick response.  Would rather stick in biztalk if possible.
    I was able to get something like this to process through no problem.
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|1|b|b|b|b
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|0
    Just using and unbounded record with the group order type set to sequence. each row could have 0 to hundreds
    of groups.  And I've been able to process files with millions of rows.
    I'm wondering if there is a way to check the integer number in order to tell the group how many records
    there will be?
    Sucks that it is all the same delimiter.

  • Multiple Colums in a Single Row

    Hi ,
    I have a requirement as follows.
    Table Test
    Col1 Col2
    Jim 200
    Jack 300
    Jon 400
    I would require the output as follows
    Col1 Col2 Col3 Col4 Col5 Col6
    Jim 200 Jack 300 Jon 400
    Any help would be greatly appreciated.
    Regards,
    Prithwish.

    I tried like this......
    create table ex_abc
    as SELECT   'Jim' Col1, 200 Col2 FROM DUAL
                     UNION ALL
                     SELECT   'Jack', 300 FROM DUAL
                     UNION ALL
                     SELECT   'Jon', 400 FROM DUAL;
    select * from   ex_abc;     
    Col1 Col2
    Jim 200
    Jack 300
    Jon 400
    --Anonymous block
    set serveroutput on
    /* Formatted on 06/07/2013 1:58:47 PM (QP5 v5.126.903.23003) */
    DECLARE
       v_String    VARCHAR2 (4000);
       v_String1   VARCHAR2 (4000);
       v_a         VARCHAR2 (4000);-- := 'Jack 300 Jim 200 Jon 400';
       v_count     NUMBER;
    BEGIN
       SELECT   listagg (col1 || ' ' || col2, ' ') WITHIN GROUP (ORDER BY col1)
         INTO   v_a
         FROM   ex_abc;
       SELECT   regexp_count (v_a, '[^ ]+') INTO v_count FROM DUAL;
       FOR i IN reverse 1 .. v_count
       LOOP
          v_String :=
                'SELECT regexp_substr('
             || ''''
             || v_a
             || ''''
             || ',''[^ ]+'',1,'
             || i
             || ')   FROM dual';
          v_String1 := '(' || v_String || ') col'||i||',' || v_String1;
       END LOOP;
       DBMS_OUTPUT.PUT_LINE(   'select '
                            || SUBSTR (v_String1, 1, LENGTH (v_String1) - 1)
                            || ' from dual');
    END;
    Output:
    --A dynamic select query will be generated as below:
    select (SELECT regexp_substr('Jack 300 Jim 200 Jon 400','[^ ]+',1,1)   FROM dual) col1,(SELECT regexp_substr('Jack 300 Jim 200 Jon 400','[^ ]+',1,2)   FROM dual) col2,(SELECT regexp_substr('Jack 300 Jim 200 Jon 400','[^ ]+',1,3)   FROM dual) col3,(SELECT regexp_substr('Jack 300 Jim 200 Jon 400','[^ ]+',1,4)   FROM dual) col4,(SELECT regexp_substr('Jack 300 Jim 200 Jon 400','[^ ]+',1,5)   FROM dual) col5,(SELECT regexp_substr('Jack 300 Jim 200 Jon 400','[^ ]+',1,6)   FROM dual) col6 from dual;
    The output of above query is:
    Col1          Col2             Col3         Col4         Col5          Col6
    Jack     300     Jim     200     Jon     400Edited by: nkvkashyap on Jun 7, 2013 2:16 AM

  • SQL Update a Single Row Multiple Times Using 2 Data Sets

    I'm working in tsql and have an issue where I need to do multiple updates to a single row based on multiple conditions. 
    By Rank_
    If the column is NULL I need it to update no matter what the Rank is.
    If the Ranks are the same I need it to update in order of T2_ID.
    And I need it to use the last updated output.
    I've tried using the update statement below but it only does the first update and the rest are ignored. Here is an example of the data sets i'm working w/ and the Desired results. Thanks in advance!
    update a
    set Middle = case when a.Rank_> b.Rank_ OR a.Middle IS NULL then ISNULL(b.Middle,a.Middle) end,
    LName = case when a.Rank_> b.Rank_ OR a.Lname IS NULL then ISNULL(b.LName,a.LName) end,
    Rank_ = case when a.Rank_> b.Rank_ then b.Rank_ end
    from #temp1 a
    inner join #temp2 b on a.fname = b.fname
    where b.T2_ID in (select top 100% T2_ID from #temp2 order by T2_ID asc)

    The Merge clause actually errors because it attempt to update the same record.  I think this CTE statement is the closest I've come but I'm still working through it as I'm not too familiar w/ them.  It returns multiple rows which I will have to
    insert into a temp table to update since the resulting row I need is the last in the table.
    ;WITH cteRowNumber
    AS(
    Select DISTINCT
    Row_Number() OVER(PARTITION BY a.LName ORDER BY a.LName ASC, a.Rank_ DESC,b.T2ID ASC) AS RowNumber
    ,a.FName
    ,a.LName
    ,b.LName as xLname
    ,a.MName
    ,b.MName AS xMName
    ,a.Rank_
    ,b.Rank_ AS xRank
    ,b.T2ID
    FROM #temp1 a
    inner join #temp2 b
    ON a.fname = b.fname
    ), cteCursor
    AS(
    Select a.RowNumber,
    a.Fname
    ,a.LName
    ,a.xLname
    ,a.MName
    ,a.xMName
    ,a.xRank
    ,a.T2ID
    ,CASE WHEN a.Rank_ >= a.xRank THEN ISNULL(a.xRank,a.Rank_) else ISNULL(a.Rank_,a.xRank) end AS Alt_Rank_
    ,CASE WHEN a.Rank_ >= a.xRank THEN ISNULL(a.xMName,a.MName) else ISNULL(a.MName,a.xMName) end AS Alt_MName
    ,CASE WHEN a.Rank_ >= a.xRank THEN ISNULL(a.xLName,a.lname) else ISNULL(a.LName,a.xlname) end as Alt_Lname
    FROM cteRowNumber a
    where a.RowNumber = 1
    UNION ALL
    Select crt.RowNumber
    ,crt.FName
    ,crt.LName
    ,crt.xLname
    ,crt.MName
    ,crt.xMName
    ,crt.xRank
    ,crt.T2ID
    ,CASE WHEN Prev.Alt_Rank_ >= crt.xRank THEN ISNULL(crt.xRank,Prev.Alt_Rank_) else ISNULL(Prev.Alt_Rank_,crt.xRank) end AS Alt_Rank
    ,CASE WHEN Prev.Alt_Rank_ >= crt.xRank THEN ISNULL(crt.xMName,Prev.Alt_MName) else ISNULL(Prev.Alt_MName,crt.xMName) end AS Alt_MName
    ,CASE WHEN Prev.Alt_Rank_ >= crt.xRank THEN ISNULL(crt.xLName,Prev.Alt_Lname) else ISNULL(Prev.Alt_Lname,crt.xLName) end as Alt_Lname
    FROM cteCursor prev
    inner join cteRowNumber crt
    on prev.fname = crt.fname and prev.RowNumber + 1 = crt.RowNumber
    SELECT cte.*
    FROM cteCursor cte

  • Single row of XML data missing

    OK, much strangeness here.
    I have an mx:DataGrid taking its data from an array
    collection thusly:
    logSheetData = logs.lastResult.logsheet.data as
    ArrayCollection;
    The XML is being generated perfectly by a php page.
    If the xml consists of 2 or more nodes (i.e. the mysql_query
    returned 2 or more rows of data from the database) then the grid
    populates properly and everyone is happy. However, if the query
    returns only a single row of data, the grid is blank.
    I've checked the php and the contents of the database - if
    there's only a single row of data to come back, one row's worth of
    XML is returned.
    This has been driving me mad all morning! Help!
    -Update-
    I have patched the problem by adding in an empty node to the
    xml structure if only 1 row of data is returned - this seems to
    fool the grid and causes it to display properly. Buy why!

    Corvette Captain wrote:
    In an interactive report, is it possible to display the data from one database row over two or more displayed rows on a page?Yes. Create the required structure using the Detail View properties.
    Users can switch between views using the view controls. You can display the report in Detail View by default via a Dynamic Action: +{thread:id=2187972}+

  • Display spool output i.e a single row in a single line

    hello All,
    I have report that outputs many columns  is single row , when run in the background.
    The problem that I am facing that the the single row of columns is wrapped into second line when certain limit of chararcters is reached. That is the single row of data is placed into two lines.
    While running the job in the background I choose the LOCL or LP01 printer with format X_65_255.
    Also note that I have other SAP systems but in that systems when I use the same procedure(printer and format also the same) for the same report the outputf for single row is not warpped into 2 lines but appears in the same line.
    Please provide your input. Points will be rewrded for helpful answers
    regards
    Sachin

    Note that this solution is for downloading wide formats only - not printing...
    Here is what I did:
    To create format Y_1024_1023 (New name!)
    1) Transaction SPAD
    2) Click "Full Administration" button
    3) Click on "Device Types" tab
    4) Click "Display" button next to "Format Types" field
    5) Place cursor on X_65_255
    6) Click in menu Format --> Create using template (F5)
    7) Change Number of rows to 1023 (if set to 65, you will have more pages and hence more headers)
    9) Change Number of Columns to 1023 (as wide as can be displayed in SP01)
    8)Give new name to format e.g. Y_1023_1023
    To create spool device YSPOOL:
    1) Transaction SPAD
    2) Click on "Device/Servers" tab (first tab!)
    3) Click 'Display" button next to Output Devices field
    4) Click "Create" button (Shift-F1)
    5) Give output device long name (e.g.YSPOOL) and short name (e.g.YSPO)
    6) Device attributes tab --> Device type = ASCIIPRI (Some generic ASCII printer) - I actually used a ZU_ASCII created in our system but ASCIIPRI should also work.
    7) Access method tab --> Host printer = some value (e.g. outfile2)
    8) Save
    Now assign Y_1024_1023 to Device type:
    1) Transaction SPAD
    2) Click on Device types tab
    3) Enter "ASCIIPRI" in "Device types" field and click display button
    4) Click on "Formats" button (F6)
    5) Click on "Create' button (Shift-F1)
    6) In popup, type Y_1023_1023 (or use drop-down to choose from)
    7) Save
    Per OSS Note 186603 --> Call SPAD and choose Settings -> Spool System -> Other. Select 'SP01: Number of Lines for List Display from Format'. You may have to clear cache via SPAD->Goto->Cache control -->Click "Reset Cache Settings".
    Now, when you schedule your background job, choose YSPOOL as your output device and choose the format as Y_1024_1023.  The spool generated from this job will be 1023 columns wide and 1024 lines long (less headers!).  Note that opening such a large spool (long & wide) will consume lots of app server memory so exit out as soon as download to presentation server is complete.

  • Split single row in multiple rows based on date range

    I need sql script that can split single row in multiple rows based on start date and end date column in table.
    Thank you

    I agree to your suggestion of having a dates table permanently in the database. Thats how we also do for most of our projects as well
    But in most projects the ownership  of table creation etc lies with the client as they will be the DBAs and will be design approval authorities. What I've seen is the fact that though
    many of them are in favour of having calendar table they dont generally prefer having a permanent table for numbers in the db. The best that they would agree is for creating a UDF which will have
    tally table functionality built into it based on a number range and can be used in cases where we need to multiply records as above.
    Wherever we have the freedom of doing design then I would also prefer creating it as a permanent table with required indexes as you suggested.
    >> many of them are in favour of having calendar table they dont generally prefer having a permanent table
    Those people do not understand about database and are not DBAs :-)
    It is our job to tell them what is right or wrong.
    ** This is a real story! I had a client several years back, who was the CEO of a software company.
    He use the query:
    select * from table_name
    In order to get the last ID!
    The table_name was actually a view that took data from several tables, and the main table that he wanted to get the ID included several string columns, with lot of data!
    he actually pulled all this data to the application, just to get the lat ID in a specific table!
    It is our job as Consultants or DBAs to fix's his misunderstanding :-)
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

Maybe you are looking for