Login | |
|
 |
RE: replace parameters in text file - 6/16/2008 8:23:48 PM
|
|
 |
|
| |
avipenina
Posts: 101
Score: 0
Joined: 4/24/2006
Status: offline
|
i couldn't figure out how to set it to my file. my main file select pilot.dbo.CUSTOMERS.CUSTNAME , case when ( ( coalesce( pilot.dbo.NSCUST.CUSTDES , '''' ) = rtrim(ltrim(reverse( @P1 ))) ) ) then ( pilot.dbo.CUSTOMERS.CUSTDES ) else ( coalesce( pilot.dbo.NSCUST.CUSTDES , '''' ) ) end , pilot.dbo.ORDERS.CURDATE , pilot.dbo.ORDERS.ORDNAME , pilot.dbo.ORDERS.BOOKNUM , pilot.dbo.DOCUMENTS.DOCNO , pilot.dbo.ORDSTATUS.ORDSTATUSDES , pilot.dbo.ORDSTATUS.XVR_GRADING , case when ( ( pilot.dbo.ORDERS.CLOSED = @P2 ) ) then ( @P3 ) else ( @P4 ) end , case when ( ( pilot.dbo.ORDERS.PCLOSED = @P5 ) ) then ( @P6 ) else ( @P7 ) end , pilot.dbo.CPROF.CPROFNUM , pilot.dbo.DEAL.ORDNAME , pilot.dbo.ORDERS.DETAILS , pilot.dbo.ORDERS.REFERENCE , (0.0 + ( convert(decimal(19,2), pilot.dbo.ORDERS.QPRICE) )) the input file ,'','C','Y',' ','C','Y',' ' this is only partial main file and input file
< Message edited by avipenina -- 6/16/2008 8:43:04 PM >
|
|
| |
|
|
|
 |
RE: replace parameters in text file - 6/16/2008 10:03:30 PM
|
|
 |
|
| |
avipenina
Posts: 101
Score: 0
Joined: 4/24/2006
Status: offline
|
this syntax has about 58 of that @P1,@P2,@P3 until @P58 i need to replace each @P with the first replacement like that @P1 = '' @P2 = 'C' @P3 = 'Y' etc until @P58 replacements '','C','Y',' ','C','Y',' ' ,etc yes it should look like your code. example select pilot.dbo.CUSTOMERS.CUSTNAME , case when ( ( coalesce( pilot.dbo.NSCUST.CUSTDES , '''' ) = rtrim(ltrim(reverse( ''))) ) ) then ( pilot.dbo.CUSTOMERS.CUSTDES ) else ( coalesce( pilot.dbo.NSCUST.CUSTDES , '''' ) ) end , pilot.dbo.ORDERS.CURDATE , pilot.dbo.ORDERS.ORDNAME , pilot.dbo.ORDERS.BOOKNUM , pilot.dbo.DOCUMENTS.DOCNO , pilot.dbo.ORDSTATUS.ORDSTATUSDES , pilot.dbo.ORDSTATUS.XVR_GRADING , case when ( ( pilot.dbo.ORDERS.CLOSED = 'C') ) then ( 'Y') else ( ' ') end , case when ( ( pilot.dbo.ORDERS.PCLOSED = 'C') ) then ( 'Y') else ( ' ') end , pilot.dbo.CPROF.CPROFNUM , pilot.dbo.DEAL.ORDNAME , pilot.dbo.ORDERS.DETAILS , pilot.dbo.ORDERS.REFERENCE , (0.0 + ( convert(decimal(19,2), pilot.dbo.ORDERS.QPRICE) )) the input file ,'','C','Y',' ','C','Y',' ' i've 58 @P and 58 replacements
< Message edited by avipenina -- 6/16/2008 10:08:21 PM >
|
|
| |
|
|
|
 |
RE: replace parameters in text file - 6/17/2008 5:18:57 AM
|
|
 |
|
| |
ehvbs
Posts: 2065
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
|
Hi avipenina, ok, because it was my error and I can't/won't force you to do something you don't like: Looping thru the placeholders "@P1", .. "@P10", .. "@P58" in that order by starting the loop like For nIdx = 0 To UBound( aRpl ) was a very bad idea: Given that sFrom is "@P1", the replacement in sMain = Replace( sMain, sFrom, sTo ) will affect "@P1", "@P10", "@P11", ... "@P19" (that is why I use placeholders like "@xxx@", if I have the choice). The remedy is to loop the other way around: For nIdx = UBound( aRpl ) To 0 Step -1 so that the bigger markers will be replaced first ("@P58" can't affect "@P5"). Regards ehvbs
|
|
| |
|
|
|
|
|