Get rows not containing UTF-8 characters.

Hi guys,
The first part is just general information. If you want to go straight to my question go to the bottom.
Our business has recently loaded a lot of data from a legacy system to our database.
I have found out that there are some problems with the data added to our database.
Some characters which is not UTF-8(?) characters has been added to a column (LONG) in the table fnd_documents_long_text.
I noticed the data error because XML Publisher gave me the following warning:
java.io.UTFDataFormatException: Invalid UTF8 encoding.
I then copied the output xml from the server to my own desktop. When I tries to open the XML file in my editor it replaces a character with a Unicode substitution character:
Some bytes have been replace with the Unicode substitution character while..
Now. I found the line causing the error in XML Publisher and my editor.
The line is:
<LONG_TEXT>COPPER WIRE TO BS 4516 PT.1 [xCF].25 PVA GR.2 (LEWMEX) MAX REEL SIZE 25KG</LONG_TEXT>The [xCF] are what raises the whole problem. When I try to copy the character into the editor in the forum it shows ϱ
QUESTION
I want to find all the attachments (rows in fnd_documents_long_text), which will cause XML Publisher to fail executing a report request.
I have created the following PL/SQL Block to identify the rows that needs correction:
DECLARE
  CURSOR c1 IS
    SELECT  media_id,
            long_text
      FROM  fnd_documents_long_text
  v_media_id              fnd_documents_long_text.media_id%TYPE;
  v_long_text             fnd_documents_long_text.long_text%TYPE;
  l_test                  varchar2(2000);
BEGIN
  dbms_output.put_line('START');
  IF (c1%ISOPEN)
  THEN
    CLOSE c1;
  END IF;
  OPEN c1;
  LOOP
    FETCH c1 INTO v_media_id, v_long_text;
    EXIT WHEN c1%NOTFOUND;
      l_test := REGEXP_REPLACE(v_long_text,'[\x80-\xFF]','');
      IF (l_test != ' ')
      THEN
        dbms_output.put_line('Media: ' || v_media_id || ', Text: ' || v_long_text);
      END IF;
  END LOOP;
  CLOSE c1;
  dbms_output.put_line('END');
END;My problem is that the list I get back contains row where æøå üä etc. exists. How do I get the list so I only contains rows where screwed up characters like ϱ exists?
Thank you in advance.
/Kenneth

Kenneth_ wrote:
Which means that Š is a UTF8 chacter.?.
I have tried with several different UTF16 characters instead (水) but with the same result... :/
Kenneth_ wrote:I do not want to convert characters. I want to get a "list" of rows with non-utf8 characters in it, so the business can decide the next action.imho this is not a problem of "non-UTF" character. Greek letters as you mentioned in your first post are "part" of it, as Š and (水) are.
The difference betweeen utf-8 and utf-16 is not the letters representable but the bytes they use for the representation.
Your problem seems more to be a configuration problem of xml-publisher (or the xml-Document). There are some threads on this under the business suite forum.
regards chris

Similar Messages

  • Select Query to fetch rows that contain non alphabetic characters

    how to select rows from a table (tab1) where a specific column (tab1.col1) has non alphabetic characters

    hi,
    you didnt specify which version you are using.
    if you are working on oracle 10g you can use regular expressions like this:
    select * from tab1 where regexp_like(col1,'[^[[:alpha:]]]');

  • How to validate UTF-8 characters using Regex?

    Hi All,
    In one of my applications, i need to include UTF-8 character set for validation of a certain string, which I am validating using a Regex.
    However, I do not know how to include UTF-8 characters in a Regex, or if at all, we can specify the UTF-8 charaters ina regex.
    Please Help!! Its Urgent!!!
    Thanks in Advance,
    Rajat Aggarwal

    Ok, Let me re-state my problem again, and exactly what i am looking for:
    I have an XML file with the following header: <?xml version="1.0" encoding="UTF-8"?>
    This XML file contains a tag, whose text is to be validate for a syntax : Operand operator Operand.
    Now, the operand on the right hand side of the operator could be a variable, or a string literal, which may contain some permissible special characters (as said above), and may or may not contain UTF-8 characters as well.
    I am using the xerces SAXParser to parse the XML document, and am retrieving the text of the elemnt tag with the method <code>element.getChildText("<tagName>")<//code>
    According to the org.jdom.Element API Docs,
    the getChildText() method is defined as follows:
    h3. getChildText{noformat}public java.lang.String getChildText(java.lang.String name){noformat}<dl><dd>Returns the textual content of the named child element, or null if there's no such child. This method is a convenience because calling <code>getChild().getText()</code> can throw a NullPointerException. <br<dd><dl><dt>Parameters: </dt><dd><code>name</code> - the name of the child </dd><dt>Returns: </dt><dd>text content for the named child, or null if no such child
    </dd></dl></dd></dl>
    Now, I am not sure if the String that I am reading is in UTF-8 Format. Is there any special way of reading a string in that format, or for that matter, convert a string to UTF-8 encoding?
    h3.

  • UTF-8 characters (e.g À ) are not supporting in batch file

    I am trying to add user using batch file, I have used UTF-8 characters in username. I am trying below command net user Àdmin "sdf" /ADD /FULLNAME:Àdmin /COMMENT:"description" I observed that user added successfully but if i see local users
    then is shows ├Çdmin in place of Àdmin.
    If I run the above command manually on cmd it is working as per expected but it is not working if i execute this command using bat file.
    It looks like limitation of bat.
    I have gone though few forums and found that this could be the problem of DOS version.
    I am using 6.1.7600 DOS version.
    Could anybody help on this.
    Thanks,

    chcp 65001 helped me to run UTF-8 batches
    example for unicode character ⬥:
    chcp 65001
    C:\Tools\Code128\Code128Gen.exe 0 "aCLa" 2 D:\Out\128_N2T60_⬥CL⬥.bmp
    C:\Tools\Code128\Code128Gen.exe 0 "aCLAa" 2 D:\Out\128_N2T60_⬥CLA⬥.bmp
    Important:
    if your .bat file begins with BOM mark, remove it (switch the encoding to "UTF-8 without BOM") otherwise the interpreter will complain about first line of your batch, for example:
    C:\Tools\Code128>´╗┐chcp 65001
    '´╗┐chcp' is not recognized as an internal or external command,
    operable program or batch file.
    After some time, original UTF-8 batch file stopped working normally at commands which contained non-ascii characters. Commands were executed normally as before (producing correct output), but this misformatted message was shown at output of each:
    C:\Tools\Code128>C:\Tools\Code128\Code128Gen.exeThe system cannot write to the specified device.

  • IDoc to File - Russian Characters not in UTF-8 format - File Receiver

    Hello,
    My scenario is Idoc to File. My SAP sender system is a Unicode system and my RFC connection to XI is also set to a unicode connection. My idoc is sent to XI OK and whenever I look at the payload in SXMB_MONI, I see the Russian characters OK, but the problem is when the file gets created.
    My receiver system wants the file in UTF-8 format.  When the file gets created, the Russian characters are not in UTF-8 encoding format. For example, the Russian chars look like (but without the spaces inbetween): Ð # Ð µ Ñ # Ð ¶ Ð ° Ñ # Ð µ Ð » Ñ ...
    Instead, the chars should look like: Держатель
    My file type in my file receiver comm channel is binary and I am also using the AF_Modules/XMLAnonymizerBean with anonymizer.encoding of utf-8.
    Can someone please help me determine the problem?
    Thank you,
    Rhonda

    Hi Rhonda,
    Hope you have set the following for your file receiver adapter :
    1. Transfer Mode is set to Binary,
    2. File Type Text,
    3. Encoding ISO-8859-1( for Western European Latin ).
    Inorder to recognize russian Character, try as follows :
    Your sender idoc after coming into Pi has XML encoding declaration 'UTF-8'.
    Write a simple XSLT mapping to change the value of the attribute "encoding" to "ISO-8859-1" in the output XML of message mapping . Include this XSLT map as the second mapping step in your interface mapping.
    First step in your interface mapping will be your already existing message mapping.
    An example of the XSL code :
    <?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method='xml' encoding='ISO-8859-1' />
    <xsl:template match="/">
    <xsl:copy-of select="*" />
    </xsl:template>
    </xsl:stylesheet>
    Iam not sure whether Russian language encoding has ISO-8859-2 (Eastern European Latin) or
    ISO-8859-1( for Western European Latin )...pls check out !
    or you can also do java mapping instead of above mentioned xslt mapping  if you are comfortable with java code !
    Cheers,
    Ram.

  • Russian Characters not in UTF-8 format - File Receiver

    Hello,
    My scenario is Idoc to File.  My SAP sender system is a Unicode system and my RFC connection to XI is also set to a unicode connection.  My idoc is sent to XI ok and whenever I look at the payload in sxmb_moni, I see the Russian characters ok, but the problem is when the file gets created.  When the file gets created, the Russian characters are in unicode html encoding representation and not in UTF-8 encoding format.  For example, the Russian chars look like (but without the spaces inbetween): & # x 4 1 2 ; & # x 4 2 b ; & # x 4 2 5 ; & # x 4 1 e ; & # x 4 1 4 ; & # x 4 1 d ; & # x 4 1 e ;
    My file type in my file receiver comm channel is binary and I am also using the AF_Modules/XMLAnonymizerBean with anonymizer.encoding of utf-8.
    Can someone please help me determine the problem?
    Thank you,
    Rhonda
    Edited by: Rhonda Wilcox on Feb 18, 2009 3:14 PM

    A simple copy XSLT would help, as XSLT deescapes automatically:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="xml" omit-xml-declaration="yes"/>
    <!--  copy payload -->
      <xsl:template match="*">
      <xsl:copy-of select="." />
      </xsl:template>
      </xsl:stylesheet>
    But try to solve the issue in the IDoc sender first.
    Regards
    Stefan

  • Resulting grid does not contain at least one row, one column and one POV

    I have upgraded to 9.3.3 recently.
    We have a front end app which will run MDX queries to retrieve data.
    Sometimes based on the users selections MDX query might get back nothing i.e will get #missing across all rows/columns and this works fine with the existing 9.3.1 essbase server.
    If I run the same query against a 9.3.3 essbase cube I get the error "Resulting grid does not contain at least one row, one column and one POV. If you have any suppress row options selected pls clear them."
    I DO NOT have Supress missing data/zero enabled. Not sure why I get this error even though I dont have that option enabled.
    Essbase 9.3.3 on HP-UX ITanium 11.31
    APS 9.3.3 on win 2003 R2
    Smartview 9.3.3 - also tried with smartview 9.3.1.6 and see the same error.
    Any suggestions to fix this issues?

    The front end is using a VBA command "hypexecutequery" and with 9.3.3 essbase I get a return code -9 which means Operation was cancelled as per the smartview doc.
    In 9.3.1 essbase I get the return code 0 which means the query is fine even if it does not return any data.
    The query I am using now will return nothing as it is a check to see if there is any data. But with 9.3.3 Essbase I get an error code -9 which looks like it does not like the syntax or something.
    Any suggestions?

  • GetClob not working with UTF-8 characters

    Hi,
    I have a column with data type CLOB in a table in Oracle DB. I want to store
    and retrieve CJK(Chinese, Japanese, Korean) data. I have tried all the
    resultset functions provided by Oracle but I was not able to get UTF-8
    characters from CLOB column. Please let me know how can I get the UTF-8 data
    from a CLOB column in an Oracle DB.
    Thanks,
    Naval.

    Clob may be supporting unicode but isnt NCLOB specially for unicode!
    as the document "Migration to Unicode Datatypes for Multilingual Databases and
    Applications" says "Unicode datatypes were introduced in Oracle9i. Unicode datatypes are supported through the SQL
    NCHAR datatypes: NCHAR, NVARCHAR2, and NCLOB. (In this paper, “Unicode datatypes” refers
    to SQL NCHAR types.) SQL NCHAR datatypes have existed since Oracle8. However, in Oracle9i
    forward, they have been redefined and their length semantics have been changed to meet customer
    globalization requirements. Data stored in columns of SQL NCHAR datatypes are exclusively stored in
    a Unicode encoding regardless of the database character set. These Unicode columns allow users to
    store Unicode in a database, which may not use Unicode as the database character set. Therefore,
    developers can build Unicode applications without dependence on the database character set. The
    Unicode datatypes also make it easier for customers to incrementally migrate existing applications and
    databases to support Unicode."

  • Uploading AIR for IOS thru Application Loader I get the following error - The package does not contain an Info.plist.

    I'm publishing an .fla in AIR for IOS.
    I'm in CC 2014 so first I need to know which AIR should I publish in?
    newest is AIR 14.0.0.178 for IOS
    IOS deployment type is App Store
    publishes with no error.
    I see the following files included .swf and app.xml
    I convert the .ipa to a zip file
    Upload that thru the Application Loader I get the following error
    The package does not contain an Info.plist.
    Where is the infoplist for this and do I convert the .ipa and the info to a zip file?
    I converted the .ipa to a .zip and the intoplist file is NOT THERE  how do I generate this?
    Any help here?

    Ok this is becoming very very frustrating as I have been at this for hours now. So the only way to explain this is to write what I did step by step as I have to be doing something wrong, just to recap:
    I was publishing from Flash CC 2014 using AIR 14.0 and getting Digital Certificate is not valid message.
    Was instructed to download new AIR 17 , I did this installed into Flash and used to publish.
    I used my previous p12, app ID and distribution certificates all generated properly.
    The file worked ONCE but I got an app ID error ( I understood I used the wrong app ID)
    I changed it to the right app ID and the very next time and after 10 attempts I got the same error  Digital Certificate is not valid
    SO I then downloaded AIR 16.0
    RE DID ALL MY CERTIFICATES AND P12'S
    went to publish and I STILL GET THE SAME MESSAGE   Digital Certificate is not valid

  • Get an Error window, The source folder does not contain any supported camera raw files

    I am using CS2 and it would not open up my latest RAW files, I was getting a warning Could not complete your request because it is not the right kinds of document. So, I checked the Camera Raw Plug-in and it says Version 3.7. I see that my camera an Olympus E-20 is supported. But it is not opening the Raw files, the day before I took jpeg and they have opened. I will not trash my Adobe Photoshop CS2 because it was a royal pain to install and I don't know where the CD is.
    I installed the latest DNG Converter and when I try to open up the folder which has all the RAW images that didn't open in Adobe, I still get an Error window that says, "The source folder does not contain any supported camera raw files." Why? It says it supports my Olympus E-20. I actually have the E-20n, I don't think that is the problem. My RAW icons usually show up as small image thumbnails and this time they are gray icons only with the incorrect date under the icon. Is there another product I can use without spending money? These images I took in RAW were special and I don't want to lose them. Please help!
    Esther

    Hello, I was using only CS2 with my Olympus E-20n for 5 years, no problem. It just started acting up in RAW this year. I downloaded Picasa that same day and now it seems to be opening up all of my RAW files that didn't open the other day. So, I think Picasa installed a new plug-in adaption to CS2 because now all my RAW icons have a new logo on them, the same one that's in Picasa. Strange, but it works now and I am not complaining anymore. I love CS2 and the many ways I can adjust RAW files, so I am using it, Picasa is a sideline now that I can take a look at many thumbnails and it organized all my photo files by the year and folders. Amazing free software. I have probably 60,000 images in my computer and an external hard drive and Picasa picked them all up and made a library, cool.

  • Trying to download adobe program 'adobe p;hotshot CS5 Optional Automate Plug-ins' but get a message "does not contain valid signature"  Any ideas to get around that please.

    Trying to download adobe program  adobe photoshop CS5 Optional Automate Plug-ins, but get a message  that it does not contain valid signature and it won't install the app.  Can someone help with this please?  Trying to reach Adobe by phone is impossible.
    ev

    First, have you installed all the updates for photoshop cs5 by going to Help>Updates from within photoshop cs5?
    The automated installer only installs the following plugins:
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=4965
    The following plug-ins and associated files are available via an installer:
    Automate Plug-Ins:
    • Contact Sheet II 
    • Picture Package (ContactSheetII) 
    • Web Photo Gallery (WebContactSheetII) plus presets 
    • Script for Layer Comps to Web Photo Gallery
    Other Optional Plug-Ins:
    • TWAIN
    Other plugins including the pattern maker plugin need to be installed manually using this download:
    http://www.adobe.com/support/downloads/detail.jsp?ftpID=4964

  • Can no longer save edited photos. get messages - "Nothing was imported" "The file or folders selected to import did not contain supported file type.

    Can someone help. I use Photoshop Elements 13. I can no longer save edited photos. get messages - "Nothing was imported" "The file or folders selected to import did not contain supported file type. It started this a couple of weeks ago and I had a friend come fix it just 2 days ago. It took him several hours and I lost all tags I had on over 10,000 pictures. Now it has done it again. I'm so upset. I lost a lot of stuff. I don't want to keep bothering him with this. Please Help.

    How did you import the files to your computer?
    What model  number camera?

  • UTF-8 characters not displaying in IE6

    Dear Sirs,
    I have an issue in displaying UTF-8 characters in Internet explorer 6.
    I set up my all jsp pages encoding as UTF-8.
    Any language characters(like chinese,tamil etc) perfectly dispaying in firebox browser.
    But in internet explorer, the characters are not displaying.it displays like ?! ..
    Could any body help me out?
    Thanks
    mulaimaran

    Thanks Viravan,
    But, I have added this line in my jsp before html tag.
    <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
    After html tag,i added this meta tag.
    <META http-equiv="Content-Type" content="text/html;charset=UTF-8">
    So, the UTF-8 encoding is capable to show different language characters in firebox browser.
    But In Internet Explorer 6 other language characters not displaying..
    > jsp sends out the UTF-8 BOM (hex: EF BB BF) before
    the HTML tag.I cant understand this line.I m new one to java.
    So ,please help me out.
    Thanks
    mullaimaran

  • Getting error "Cannot create a BACPAC from a file that does not contain exported data." from SqlManagementClient.Dac.ImportAsync

    We're trying to import a dacpac to azure via the new SqlManagementClient DacOperations ImportAsync api I get an exception with the error: "Cannot create a BACPAC from a file that does not contain exported data."
    This same dacpac imports fine using an alternate but less friendly API from sql server's tooling. We'd like to use the new management SDK instead for various reasons.

    Hi Kyle A Wilt,
    I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated.
    Thank you for your understanding and support.
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Not Getting Rows With No Date Match

    I have SQL 2012 and am trying to use a CTE to get patient meal calendar rows even if the row does not match a given date range. We use a Calendar table that has 1 row for each date in the year so I wanted it to drive the results so that when I ask for a
    week date range I will get rows even if the patient does not have a meal or snack scheduled for that date.  My CTE code is below and it gives me the correct data but only if the patient has a meal or snack scheduled for that date (this is like a weekly
    meal menu). Any help is appreciated.
    ALTER PROCEDURE [dbo].[kd_selMealPlannerMatrix]
    @PatientID int,
    @StartDate smalldatetime,
    @EndDate smalldatetime = null
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    IF @EndDate IS NULL
    BEGIN
    SET @EndDate = DATEADD(day,6,@StartDate);
    END
    ;WITH client_meals AS (
    SELECT DATEPART(dw, dbo.tblMealCalendar.MealDate) AS PrintDate,
    dbo.tlkpMealCodes.MealCode,
    CASE WHEN dbo.tblMealCalendar.MealID <> 0 THEN dbo.tblActualMeals.MealName + N' - ' + CONVERT(nvarchar, dbo.tblActualMeals.MealNumber)
    WHEN dbo.tblMealCalendar.SnackID <> 0 THEN dbo.tblActualSnacks.SnackName + N' - ' + CONVERT(nvarchar, dbo.tblActualSnacks.SnackNumber)
    ELSE NULL
    END AS PrintMeal,
    dbo.tblMealCalendar.PatientID,
    dbo.tblMealCalendar.MealDate,
    dbo.tblMealCalendar.CalendarID,
    dbo.tlkpMealCodes.MealCodeSort,
    dbo.tblActualMeals.MealID,
    dbo.tblActualSnacks.SnackID,
    dbo.tblMealCalendar.MealCodeID
    FROM dbo.tblMealCalendar LEFT OUTER JOIN
    dbo.tblActualMeals ON dbo.tblMealCalendar.MealID = dbo.tblActualMeals.MealID LEFT OUTER JOIN
    dbo.tblActualSnacks ON dbo.tblMealCalendar.SnackID = dbo.tblActualSnacks.SnackID LEFT OUTER JOIN
    dbo.tlkpMealCodes ON dbo.tblMealCalendar.MealCodeID = dbo.tlkpMealCodes.MealCodeID
    WHERE (dbo.tblActualSnacks.Verified IS NULL OR dbo.tblActualSnacks.Verified <> 0)
    AND (dbo.tblActualMeals.Verified IS NULL OR dbo.tblActualMeals.Verified <> 0)
    AND (dbo.tblMealCalendar.PatientID = @PatientID)
    ), dt_range AS (
    SELECT dt, DW
    FROM dbo.Calendar
    WHERE dt BETWEEN @StartDate AND @EndDate
    SELECT
    MAX(M.MealDate) AS MealDate,
    MAX(M.PrintDate) AS PrintDay,
    MAX(D.DW) AS WkDay,
    MAX(CASE WHEN MealCode = 'AM Meal' THEN PrintMeal
    ELSE NULL
    END) AS AMMeal,
    MAX(CASE WHEN MealCode = 'AM Meal' THEN MealID
    ELSE 0
    END) AS AMMealID,
    MAX(CASE WHEN MealCode = 'AM Snack' THEN PrintMeal
    ELSE NULL
    END) AS AMSnack,
    MAX(CASE WHEN MealCode = 'AM Snack' THEN SnackID
    ELSE 0
    END) AS AMSnackID,
    MAX(CASE WHEN MealCode = 'Mid-Day' THEN PrintMeal
    ELSE NULL
    END) AS MidDay,
    MAX(CASE WHEN MealCode = 'Mid-Day' THEN MealID
    ELSE 0
    END) AS MidDayMealID,
    MAX(CASE WHEN MealCode = 'PM Snack' THEN PrintMeal
    ELSE NULL
    END) AS PMSnack,
    MAX(CASE WHEN MealCode = 'PM Snack' THEN SnackID
    ELSE 0
    END) AS PMSnackID,
    MAX(CASE WHEN MealCode = 'PM Meal' THEN PrintMeal
    ELSE NULL
    END) AS PMMeal,
    MAX(CASE WHEN MealCode = 'PM Meal' THEN MealID
    ELSE 0
    END) AS PMMealID,
    MAX(CASE WHEN MealCode = 'Evening Snack' THEN PrintMeal
    ELSE NULL
    END) AS EveningSnack,
    MAX(CASE WHEN MealCode = 'Evening Snack' THEN SnackID
    ELSE 0
    END) AS EveningSnackID,
    MAX(CASE WHEN MealCode = '4th Meal' THEN PrintMeal
    ELSE NULL
    END) AS FourthMeal,
    MAX(CASE WHEN MealCode = '4th Meal' THEN MealID
    ELSE 0
    END) AS FourthMealID
    FROM dt_range AS D RIGHT OUTER JOIN
    client_meals AS M ON D.dt = M.MealDate
    GROUP BY D.dt
    HAVING (D.dt BETWEEN @StartDate AND @EndDate)
    ORDER BY D.dt;
    END

    I tried to keep this as close to what we know as I could. Here's an example of making it work as you're asking:
    DECLARE @tinyCalendar table (date date)
    DECLARE @i INT = 0
    WHILE @i < 10
    BEGIN
    INSERT INTO @tinyCalendar (date)
    VALUES (DATEADD(DAY,-@i,GETDATE()))
    SET @i = @i + 1
    END
    DECLARE @patients TABLE (id INT IDENTITY, name VARCHAR(20))
    INSERT INTO @patients (name)
    VALUES ('John'),('Paul'),('George'),('Ringo')
    DECLARE @mealSelections TABLE (patientID INT, mealID INT, mealCode VARCHAR(8), DATE DATE)
    INSERT INTO @mealSelections (patientID, mealID, mealCode, date)
    VALUES
    (1,1,'1st Meal','2014-08-12'),(1,2,'1st Meal','2014-08-13'),(1,3,'1st Meal','2014-08-14'),(1,4,'1st Meal','2014-08-15'),(2,1,'1st Meal','2014-08-12'),(2,2,'1st Meal','2014-08-13'),(2,3,'1st Meal','2014-08-14'),(2,4,'1st Meal','2014-08-15'),(3,1,'1st Meal','2014-08-12'),(3,2,'1st Meal','2014-08-13'),(3,3,'1st Meal','2014-08-14'),(3,4,'1st Meal','2014-08-15'),(4,1,'1st Meal','2014-08-12'),(4,2,'1st Meal','2014-08-13'),(4,3,'1st Meal','2014-08-14'),(4,4,'1st Meal','2014-08-15'),
    (1,1,'1st Meal','2014-08-16'),(1,2,'1st Meal','2014-08-17'),(1,3,'1st Meal','2014-08-18'),(1,4,'1st Meal','2014-08-19'),(2,1,'1st Meal','2014-08-16'),(2,2,'1st Meal','2014-08-17'),(2,3,'1st Meal','2014-08-18'),(2,4,'1st Meal','2014-08-19'),(3,1,'1st Meal','2014-08-16'),(3,2,'1st Meal','2014-08-17'),(3,3,'1st Meal','2014-08-18'),(3,4,'1st Meal','2014-08-19'),(4,1,'1st Meal','2014-08-16'),(4,2,'1st Meal','2014-08-17'),(4,3,'1st Meal','2014-08-18'),(4,4,'1st Meal','2014-08-19'),
    (1,1,'2nd Meal','2014-08-12'),(1,2,'2nd Meal','2014-08-13'),(1,3,'2nd Meal','2014-08-14'),(1,4,'2nd Meal','2014-08-15'),(2,1,'2nd Meal','2014-08-12'),(2,2,'2nd Meal','2014-08-13'),(2,3,'2nd Meal','2014-08-14'),(2,4,'2nd Meal','2014-08-15'),(3,1,'2nd Meal','2014-08-12'),(3,2,'2nd Meal','2014-08-13'),(3,3,'2nd Meal','2014-08-14'),(3,4,'2nd Meal','2014-08-15'),(4,1,'2nd Meal','2014-08-12'),(4,2,'2nd Meal','2014-08-13'),(4,3,'2nd Meal','2014-08-14'),(4,4,'2nd Meal','2014-08-15'),
    (1,1,'2nd Meal','2014-08-16'),(1,2,'2nd Meal','2014-08-17'),(1,3,'2nd Meal','2014-08-18'),(1,4,'2nd Meal','2014-08-19'),(2,1,'2nd Meal','2014-08-16'),(2,2,'2nd Meal','2014-08-17'),(2,3,'2nd Meal','2014-08-18'),(2,4,'2nd Meal','2014-08-19'),(3,1,'2nd Meal','2014-08-16'),(3,2,'2nd Meal','2014-08-17'),(3,3,'2nd Meal','2014-08-18'),(3,4,'2nd Meal','2014-08-19'),(4,1,'2nd Meal','2014-08-16'),(4,2,'2nd Meal','2014-08-17'),(4,3,'2nd Meal','2014-08-18'),(4,4,'2nd Meal','2014-08-19'),
    (1,1,'3rd Meal','2014-08-12'),(1,2,'3rd Meal','2014-08-13'),(1,3,'3rd Meal','2014-08-14'),(1,4,'3rd Meal','2014-08-15'),(2,1,'3rd Meal','2014-08-12'),(2,2,'3rd Meal','2014-08-13'),(2,3,'3rd Meal','2014-08-14'),(2,4,'3rd Meal','2014-08-15'),(3,1,'3rd Meal','2014-08-12'),(3,2,'3rd Meal','2014-08-13'),(3,3,'3rd Meal','2014-08-14'),(3,4,'3rd Meal','2014-08-15'),(4,1,'3rd Meal','2014-08-12'),(4,2,'3rd Meal','2014-08-13'),(4,3,'3rd Meal','2014-08-14'),(4,4,'3rd Meal','2014-08-15'),
    (1,1,'3rd Meal','2014-08-16'),(1,2,'3rd Meal','2014-08-17'),(1,3,'3rd Meal','2014-08-18'),(1,4,'3rd Meal','2014-08-19'),(2,1,'3rd Meal','2014-08-16'),(2,2,'3rd Meal','2014-08-17'),(2,3,'3rd Meal','2014-08-18'),(2,4,'3rd Meal','2014-08-19'),(3,1,'3rd Meal','2014-08-16'),(3,2,'3rd Meal','2014-08-17'),(3,3,'3rd Meal','2014-08-18'),(3,4,'3rd Meal','2014-08-19'),(4,1,'3rd Meal','2014-08-16'),(4,2,'3rd Meal','2014-08-17'),(4,3,'3rd Meal','2014-08-18'),(4,4,'3rd Meal','2014-08-19'),
    (1,1,'4th Meal','2014-08-12'),(1,2,'4th Meal','2014-08-13'),(1,3,'4th Meal','2014-08-14'),(1,4,'4th Meal','2014-08-15'),(2,1,'4th Meal','2014-08-12'),(2,2,'4th Meal','2014-08-13'),(2,3,'4th Meal','2014-08-14'),(2,4,'4th Meal','2014-08-15'),(3,1,'4th Meal','2014-08-12'),(3,2,'4th Meal','2014-08-13'),(3,3,'4th Meal','2014-08-14'),(3,4,'4th Meal','2014-08-15'),(4,1,'4th Meal','2014-08-12'),(4,2,'4th Meal','2014-08-13'),(4,3,'4th Meal','2014-08-14'),(4,4,'4th Meal','2014-08-15'),
    (1,1,'4th Meal','2014-08-16'),(1,2,'4th Meal','2014-08-17'),(1,3,'4th Meal','2014-08-18'),(1,4,'4th Meal','2014-08-19'),(2,1,'4th Meal','2014-08-16'),(2,2,'4th Meal','2014-08-17'),(2,3,'4th Meal','2014-08-18'),(2,4,'4th Meal','2014-08-19'),(3,1,'4th Meal','2014-08-16'),(3,2,'4th Meal','2014-08-17'),(3,3,'4th Meal','2014-08-18'),(3,4,'4th Meal','2014-08-19'),(4,1,'4th Meal','2014-08-16'),(4,2,'4th Meal','2014-08-17'),(4,3,'4th Meal','2014-08-18'),(4,4,'4th Meal','2014-08-19')
    SELECT p.id, p.name, c.date,
    Max(CASE WHEN mealCode = '1st Meal' THEN mealID END) AS FirstMeal,
    Max(CASE WHEN mealCode = '2nd Meal' THEN mealID END) AS SecondMeal,
    Max(CASE WHEN mealCode = '3rd Meal' THEN mealID END) AS ThirdMeal,
    Max(CASE WHEN mealCode = '4th Meal' THEN mealID END) AS FourthMeal
    FROM @patients p
    INNER JOIN @tinyCalendar c
    ON p.id = p.id
    LEFT OUTER JOIN @mealSelections m
    ON p.id = m.patientID
    AND m.date = c.date
    GROUP BY p.id, p.name, c.date
    ORDER BY c.date

Maybe you are looking for

  • Problem when load more swf files work with xml files into my movie

    hi ; I have one flash file & more of swf files which work with xml files . when I load one swf file into my flash file  and remove it and load anther one on the same movieclip in my flash file it load the old swf file. when i load one on movieclip an

  • Bell character (^G or "\a") not producing audible beep

    The subject says it all. Well, almost all. I wanted irssi (I'm using it in conjunction with bitlbee) to beep audibly, but all I was getting was a visual bell. That was in GNU screen, but I tried 'echo ^G' in screen, a plain xterm, and vc/1 directly b

  • Authenticating off the network?!?!?!

    I have a couple users that for some reason when they disconnect from the network they are unable authenticate on their local machines. While on the network they authenticate through open directory just fine. What am I missing? What can I look at? I a

  • Asking help for patch

    Hi, Could some body please help me!! I need patch for installing oracle under Redhat Enterprise3 and dont have an account to login to oracle metalink. could some body send me the patch?? ( i need p3119415_9203_LINUX.zip and opatch Release 2.2.0 (p261

  • Job role design - transaction role and auth object role

    Hi all, please kindly comment following job role design: (1) transaction role: Keep transactions in single job role to represent business processes in different application areas, e.g.MM: maintain PR, PO, OA.   CO: maintain cost center, internal orde