Subject | Re: Substring function not working? |
---|---|
Author | alexandermezhov |
Post date | 2013-03-01T04:12:43Z |
I found resolution:
command.CommandText = @"select * from ""TESTENTITY"" where substring(""NAME"" from cast(@p0 as Integer) for 4) = 'Item'";
command.Parameters.Add(new FbParameter("p0", 1));
You need to cast parameter @p0 to Integer.
P.s.
If the parameter @p0 can be 0, then you need to do a check for NULL:
command.CommandText = @"select * from ""TESTENTITY"" where substring(""NAME"" from cast(coalesce(@p0+1, 1) as Integer) for 4) = 'Item'";
command.Parameters.Add(new FbParameter("p0", 0));
command.CommandText = @"select * from ""TESTENTITY"" where substring(""NAME"" from cast(@p0 as Integer) for 4) = 'Item'";
command.Parameters.Add(new FbParameter("p0", 1));
You need to cast parameter @p0 to Integer.
P.s.
If the parameter @p0 can be 0, then you need to do a check for NULL:
command.CommandText = @"select * from ""TESTENTITY"" where substring(""NAME"" from cast(coalesce(@p0+1, 1) as Integer) for 4) = 'Item'";
command.Parameters.Add(new FbParameter("p0", 0));