Replies

have a look at the documentation here is the patial link       csp/docbook/DocBook.UI.Page.cls?KEY=EDTL_sql  the sql has to be something like this

  SELECT Name INTO :target.Name
  FROM MainFrame.EmployeeRecord
  WHERE SSN = :source.SSN AND City = :source.Home.City

This will do exactly what you want any problems give us shout

ClassMethod ImpCSV(fileName As %String = "C:\filepath where csv file is")
{
	;;Refresh globals data at the begin of proecess
	;;globals hold the file being written to data and the count of lines each file has 
	k ^ufile,^ufile2,^counter,^counter2
	set Reader =##class(%Stream.FileCharacter).%New() 
	
	;;link to the file to read	 
	set status=Reader.LinkToFile(fileName)
		
   if $$$ISERR(status)
	{
		do $System.Status.DisplayError(status)
	}
	;;initialise the counter for the file lines to write to one file	 
	set ^counter =0
	set ^counter2 =0	
	set ^ufile=""
	set ^ufile2=""
    
    ;;the count for the lines read in
	set lineCount=0
	;;start process the lines
	while 'Reader.AtEnd
	{
		;;read the incoming file
		set line=Reader.ReadLine()
		;;increment the line count by one as you read the next line
		set lineCount=lineCount+1		
	
	    ;;piece the column to check
	    ;;one is for the first column and so on
	    ;;string at after the equal sign is the value to check for 
		if ($piece(line,",",1)="Religion")
		{
			;;increment count for this file
			 set ^counter=^counter+1
			  ;;the counter is at one to assign the file path to write to
			   if (^counter=1)
				{
					;;set the file name to write to the global
					set ^ufile=..writeFileOut("fileone",".csv",line,,^counter)
				}
				else
				{
					;;check the count has no reached the limit for the number of lines to write to
					if (^counter=51)
					{
						;;reset the count if limit reach
						set ^counter=1
					    ;;new file
					    set ^ufile =..writeFileOut("fileone",".csv",line,,^counter)
					    }
					    else
					    {
						    ;;use the current file
						    do ..writeFileOut(,,line,,^counter,"REG")
						 }
					}			
		  }
		  ;;second check for the next set of data if you have more than 
		  ;;two to check for copy the below and change accordingly to accommodate the next check
		  ;;same as above
		  if ($piece(line,",",1)="description")
		  {
			  ;;set attributes for the second file to write to
			   set ^counter2=^counter2+1
			   if (^counter2=1)
			   {
					set ^ufile2=..writeFileOut("fileTwo",".csv",line,,^counter2)
				}else
				{
					if (^counter2=51)
					{
						set ^counter2=1
						;;new file
						set ^ufile2= ..writeFileOut("fileTwo",".csv",line,,^counter2)
					}else
					{
						do ..writeFileOut(,,line,,^counter2,"DESC")
					}
				}				 			
	}
		  
}

 kill ^ufile,^ufile2
}

ClassMethod writeFileOut(filename, fileext As %String, line As %String, directory = "C:\directory to store files", linecount As %Integer, FileToUse)
{
	set oLF = ##class(%Library.File).%New()
	if (linecount=1)
	{
		
	    Set filenam=directory_filename_$i(^timmmy)_fileext
	    set oLF.Name=filenam
	    if (oLF.Open("wns"))
	    {
		    set linecount=linecount+1
		    do oLF.WriteLine(line)
		    do oLF.Close()
		    ;;w oLF.Name
		    quit oLF.Name	
	   }
	}else
	{
		if (FileToUse="DESC")
		{
		     if (^ufile2'="")
		     {
		         set oLF.Name=^ufile2
			}
		}elseif(FileToUse="REG")
		{
		     if (^ufile'="")
			 {
			     set oLF.Name=^ufile
			  }
		}
	    If (##class(%File).Exists(oLF.Name))
	     {
		     
		     Do oLF.Open("EWA")
		     if (linecount'=51)
		     {
			     set linecount=linecount+1
		         do oLF.WriteLine(line)
		         do oLF.Close()
		          quit oLF.Name
		     }
		 }
	}
}

Hi Jenna Poindexter

Yes %Populate exists but that's not what I am referring to the above is the correct answer  by Alexander Koblov. I was referring to this class %Library.CachePopulate not what you are pointing me to

@Tomáš Vaverka 
Yes that right but I know that the question may be was not clear I have an object class which has two properties one a string and a stream and was trying to pass that object ,all I could do was pass a string and an empty stream  but I have read around the stream and found out that I can pass a stream as a stream but not inside an object thanks again

@Hansel Gaete 
Was wondering did you get this problem solved I also have an object with a stream property that I am trying to return in a soap response and is blank but in the trace on the production is populated  any help appreciated