This conversion is not very common. For some IIF expressions, You need to convert them to the formats supported by SQL Server. After debugging, you can support nested calls. /**/ /// <Summary>
/// IIF statement in the conversion string
/// </Summary>
/// <Param name = "? "> </Param>
/// <Returns> </returns>
Static Public String Changeiif ( String Oldstr)
{
String Str = Oldstr;
Str. Trim ();
Int P0 = Oldstr. indexof ( " IIF " );
If (P0 =- 1 ) Return Oldstr;
Int P1 = Str. indexof ( " ( " , P0 );
// Eliminate intermediate () Interference
Int L = 0 ; // Recorded (
Int P2 = P1 + 1 ;
For (; P2 < Str. length; p2 ++ )
{
If (L = 0 && Str. substring (P2, 1 ) = " , " ) Break ;
If (Str. substring (P2, 1 ) = " ( " ) L ++ ; // Each time one (, l plus 1) is added
If (Str. substring (P2, 1 ) = " ) " ) L -- ; // Each time one (, l plus 1) is added
}
If (P2 = Str. length) Return "" ; // Unexpected
// Int P2 = Str. indexof (",", P1 );
L = 0 ; // Recorded (
Int P3 = P2 + 1 ;
For (; P3 < Str. length; p3 ++ )
{
If (L = 0 && Str. substring (P3, 1 ) = " , " ) Break ;
If (Str. substring (P3, 1 ) = " ( " ) L ++ ; // Each time one (, l plus 1) is added
If (Str. substring (P3, 1 ) = " ) " ) L -- ; // Each time one (, l plus 1) is added
}
If (P3 = Str. length) Return "" ; // Unexpected
// Int P3 = Str. indexof (",", p2 + 1 ); // The second ","
// To eliminate the interference ().
L = 0 ; // Recorded (
Int P4 = P3 + 1 ;
For (; P4 < Str. length; P4 ++ )
{
If (L = 0 && Str. substring (P4, 1 ) = " ) " ) Break ;
If (Str. substring (P4, 1 ) = " ( " ) L ++ ; // Each time one (, l plus 1) is added
If (Str. substring (P4, 1 ) = " ) " ) L -- ; // Each time one (, l plus 1) is added
}
// Int P4 = Str. Length-1;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.