ODP: ODP: [firebird-support] substring similar - "Invalid SIMILARTOpattern"

2018-12-05 Thread Karol Bieniaszewski liviusliv...@poczta.onet.pl [firebird-support]
Thank you once again.

Now it is much clear that sql standard have more functions and much useful.
I will wait for future improvements in Firebird. I stay longer with udfs for 
now.

Regards,
Karol Bieniaszewski


Re: ODP: [firebird-support] substring similar - "Invalid SIMILAR TOpattern"

2018-12-05 Thread Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
On 5-12-2018 18:00, Karol Bieniaszewski liviusliv...@poczta.onet.pl 
[firebird-support] wrote:
> Is this sql standard concept that i must do this in this crap way?

Yes, it is specified in SQL:2016, section 6.32 ", 
"".

> SELECT substring('ab11c' similar '[[:ALPHA:]]+#"[0-9]+#"[[:ALPHA:]]+' 
> escape '#') FROM RDB$DATABASE
> 
> Also strange that i must consume whole string by reg expression not only 
> part of it.

The syntax defines which part you want to obtain in terms of its 
position in the rest of the string.

> This can be as an option but as default it is strange for me.
> 
> Why not simply do:
> 
> SELECT substring('ab11c12bcd' similar '[0-9]+' itemNumber 1) FROM 
> RDB$DATABASE
> 
> Will simply return „11”
> 
> SELECT substring('ab11c22bcd' similar '[0-9]+' itemNumber 2) FROM 
> RDB$DATABASE
> 
> Will simply return 22

"Why not simply" because that is not the behavior defined by the 
standard for this specific function.

The SQL:2016 standard also has "" 
(SUBSTRING_REGEX) and a number of related functions like LIKE_REGEX, 
OCCURRENCES_REGEX, TRANSLATE_REGEX and POSITION_REGEX, which use the 
XQuery fn:matches() regex syntax.

This function allows you to specify the occurrence and capturing group 
to return (and some more things like start position in string), but 
Firebird doesn't provide this yet.

> Now i have 2 udf like this:
> 
> REG_MATCH
> 
> REG_MATCH_COUNT
> 
> and i supposed that i can replace it with built in one, but i see that 
> this is really terrible.
> 
> Above udfs i can use in this way
> 
> SELECT REG_MATCH(‘ab11c22bcd’, ‘[0-9]+’, 1) FROM RDB$DATABASE
> 
> Return 11
> 
> SELECT REG_MATCH(‘ab11c22bcd’, ‘[0-9]+’, 2) FROM RDB$DATABASE
> 
> Return 22
> 
> SELECT REG_MATCH_COUNT(‘ab11c22bcd’, ‘[0-9]+’) FROM RDB$DATABASE
> 
> Return 2
> 
> I can use it in the where clause:
> 
> SELECT * FROM MY_TABLE T WHERE REG_MATCH_COUNT(T.FIELD, ‘[0-9]+’)>2
> 
> Or
> 
> SELECT * FROM MY_TABLE T WHERE REG_MATCH(T.FIELD, ‘[0-9]+’, 1)=’11’

If I understand the SQL:2016 SUBSTRING_REGEX correctly, the equivalent 
for that would be SUBSTRING_REGEX('[0-9]+' IN T.FIELD) or - explicitly 
specifying the occurrence - SUBSTRING_REGEX('[0-9]+' IN T.FIELD 
OCCURRENCE 1).

The equivalent of that REG_MATCH_COUNT would be 
OCCURRENCES_REGEX('[0-9]+' IN T.FIELD)

Unfortunately we don't have that yet in Firebird.

Mark
-- 
Mark Rotteveel


ODP: [firebird-support] substring similar - "Invalid SIMILAR TOpattern"

2018-12-05 Thread Karol Bieniaszewski liviusliv...@poczta.onet.pl [firebird-support]
Thank you very much Mark for detailed info but i have more questions.

I am really curious. 
Is this sql standard concept that i must do this in this crap way? 
SELECT substring('ab11c' similar '[[:ALPHA:]]+#"[0-9]+#"[[:ALPHA:]]+' escape 
'#') FROM RDB$DATABASE
Also strange that i must consume whole string by reg expression not only part 
of it. 
This can be as an option but as default it is strange for me.


Why not simply do:
SELECT substring('ab11c12bcd' similar '[0-9]+' itemNumber 1) FROM RDB$DATABASE
Will simply return „11”

SELECT substring('ab11c22bcd' similar '[0-9]+' itemNumber 2) FROM RDB$DATABASE
Will simply return 22


Now i have 2 udf like this: 
REG_MATCH
REG_MATCH_COUNT

and i supposed that i can replace it with built in one, but i see that this is 
really terrible.
Above udfs i can use in this way

SELECT REG_MATCH(‘ab11c22bcd’, ‘[0-9]+’, 1) FROM RDB$DATABASE
Return 11
SELECT REG_MATCH(‘ab11c22bcd’, ‘[0-9]+’, 2) FROM RDB$DATABASE
Return 22

SELECT REG_MATCH_COUNT(‘ab11c22bcd’, ‘[0-9]+’) FROM RDB$DATABASE
Return 2

I can use it in the where clause:
SELECT * FROM MY_TABLE T WHERE REG_MATCH_COUNT(T.FIELD, ‘[0-9]+’)>2
Or
SELECT * FROM MY_TABLE T WHERE REG_MATCH(T.FIELD, ‘[0-9]+’, 1)=’11’

regards,
Karol Bieniaszewski


Re: [firebird-support] substring similar - "Invalid SIMILAR TO pattern"

2018-12-04 Thread Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
On 3-12-2018 08:46, liviuslivius liviusliv...@poczta.onet.pl 
[firebird-support] wrote:
> Firebird 3
> can someone tell me how to work with substring similar?
> SELECT substring('abc' similar 'a' escape '#')  FROM RDB$DATABASE
> raise an error "Invalid SIMILAR TO pattern"
> SELECT substring('ab11c' similar '[0-9]+' escape '#')  FROM RDB$DATABASE
> raise an error "Invalid SIMILAR TO pattern"
> what i am doing wrong?
> how this pattern should looks like?

The release notes documentation is incomplete (and the described syntax 
is wrong: SIMILAR (as working and specified in SQL standard) vs SIMILAR 
TO (as documented)).

The problem is that you need to have a capturing group so Firebird knows 
which substring to return, this is missing from your example. See 
doc/sql.extensions/README.substring_similar.txt

Looking at the SQL standard the error reported by Firebird is wrong (it 
should report "data exception — invalid use of escape character." in 
this case, absence of a capturing group (or not exactly two instance of 
escape and ", in this case #")).

Eg to catch the initial a, you need to use

SELECT substring('abc' similar '#"a#"%' escape '#')  FROM RDB$DATABASE

Where # is the escape, and the pair of #" defines the capturing group, 
and % means zero or more character. Which means return an 'a' followed 
by 0 or more characters.

For the second example, you'd need to use (for example):

SELECT substring('ab11c' similar '[[:ALPHA:]]+#"[0-9]+#"[[:ALPHA:]]+' 
escape '#') FROM RDB$DATABASE

which means return 1 or more digits preceded by 1 or more 'alpha' (Latin 
letters a..z and A..Z) and followed by 1 or more 'alpha'.

Mark
-- 
Mark Rotteveel


[firebird-support] substring similar - "Invalid SIMILAR TO pattern"

2018-12-03 Thread liviuslivius liviusliv...@poczta.onet.pl [firebird-support]
Hi,
 
Firebird 3
 
can someone tell me how to work with substring similar?
 
SELECT substring('abc' similar 'a' escape '#')  FROM RDB$DATABASE
raise an error "Invalid SIMILAR TO pattern"
 
 
SELECT substring('ab11c' similar '[0-9]+' escape '#')  FROM RDB$DATABASE
raise an error "Invalid SIMILAR TO pattern"
 
what i am doing wrong?
how this pattern should looks like?
 
regards,
Karol Bieniaszewski

Re: [firebird-support] Substring and negative numbers

2016-09-06 Thread 'Jeremy Poppleton' jeremy.popple...@csy.co.uk [firebird-support]
Absolutely !

It seems that the mandatory postcode field has all kinds of non-postcode
stuff in it ! 

For anyone else with this issue the original error was:

 

Invalid length parameter -2 to SUBSTRING. Negative integers are not
allowed.

 

Changing the query to 

 

SELECT DISTINCT

left(c.addr_5, CHAR_LENGTH(c.addr_5)-3) as trimmed 

FROM vecusts c

where CHAR_LENGTH(c.addr_5) > 3

 

solves this issue and now only leaves what is left to be validated.

Thank you Helen J

 



Re: [firebird-support] Substring and negative numbers

2016-09-05 Thread Helen Borrie hele...@iinet.net.au [firebird-support]
Hello Jeremy,

Tuesday, September 6, 2016, 3:55:52 AM, you wrote:

> This simple query:

> SELECT left(c.addr_5, CHAR_LENGTH(c.addr_5)-3) as trimmed
> FROM vecusts c
>
> Produces this error

The list can't take attachments or embeds so you need to copy the
error message in text.
>
> Pressing OK I then get correct values in the trimmed column.

So you are using some GUI tool.  Some of them re-interpret Firebird's
error messages anyway...

> Can anyone assist  or tell me what I am doing wrong?

Remember that your SELECT statement is going to read all of the rows
in vecusts.  Any that have NULL or an empty string or a length shorter
than 3 characters in the addr_5 column are going to fail one way or
another in the expression.  You need to cover those situations.

Also, the parser or your query tool might want another set of brackets
around the value expression, viz.

SELECT left(c.addr_5, (CHAR_LENGTH(c.addr_5)-3)) as trimmed
FROM vecusts c

Helen



[firebird-support] Substring and negative numbers

2016-09-05 Thread 'Jeremy Poppleton' jeremy.popple...@csy.co.uk [firebird-support]
This simple query:


 


SELECT left(c.addr_5, CHAR_LENGTH(c.addr_5)-3) as trimmed


FROM vecusts c


 


Produces this error


 


 


 


Pressing OK I then get correct values in the trimmed column.


Can anyone assist  or tell me what I am doing wrong?


 


Many thanks


 


 






[Non-text portions of this message have been removed]




AW: AW: [firebird-support] substring

2014-07-21 Thread 'checkmail' check_m...@satron.de [firebird-support]
Hello

wrote:
> Hello Mark,
>
> Here the code of the sub-Procedure:
>
> create or alter procedure P_U_CN_TO_INT (
> CN_IN varchar(30))
> returns (
> INT_OUT integer,
> STATUS smallint)
> AS
> declare variable I_ISNUMERIC smallint;
> BEGIN
> select true_param from p_u_isnumeric(:cn_in) into :i_isnumeric;
> if(i_isnumeric = 1) then
> begin
> int_out = cast(cn_in as integer);
> status = 1;
> end
> else
> begin
> int_out = 0;
> status = 0;
> if(cn_in is null) then cn_in = 'NULL!';
> execute procedure p_db_ins_error('P_U_CN_TO_INT','CN_IN: '|| :cn_in,11);
> end
> SUSPEND;
> when any do
> begin
> execute procedure p_db_ins_error('P_U_CN_TO_INT','CN_IN: '|| :cn_in || '
> SQL-Fehler: ' || sqlcode ,10);
> status = 0;
> int_out = 0;
> suspend;
> end
> END
>
> If I call it with '1234', I get 1234 as integer. For example 'AB12' - and
I
> get as status 0 an not an integer value.
>
> Dat is a string with many digits. I would spit it. When I do it with:
> s_digits = substring(:dat from 1 for 4); and give the stored (sub)
procedure
> the :s_digits for input parameter, it works. Otherwise I give the stored
> (sub) procedure the substring... directly, I get a sql-error -802. But it
is
> the same content in the variable. And then I get not an integer value, for
> example 1234, it ends with this error.

-It looks like you register the actual value of cn_in before storing it, 
-what is the problematic value. Have you checked if that is actually the 
-value that you exepected? You might also want to consider removi-ng the 
-error handling from your stored procedure to check out if the error 
-message contains more information.

-You don't show p_u_isnumeric, have you checked if the error occurs there?

-Mark
-- 
-Mark Rotteveel

it looks like an conversation problem. If I call the stored procedure with
the input parameter (substring(:var from 1 for 4) it doesn't work, but If I
call it with (cast(substring(:var from 1 for 4)as varchar(20)) it does work!
The var is a char variable, the input var from the stored procedure an
varchar - can it be the problem?

 

Thanks a lot.





Re: AW: [firebird-support] substring

2014-07-19 Thread Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
On 18-7-2014 21:03, 'checkmail' check_m...@satron.de [firebird-support] 
wrote:
> Hello Mark,
>
> Here the code of the sub-Procedure:
>
> create or alter procedure P_U_CN_TO_INT (
>  CN_IN varchar(30))
> returns (
>  INT_OUT integer,
>  STATUS smallint)
> AS
> declare variable I_ISNUMERIC smallint;
> BEGIN
>select true_param from p_u_isnumeric(:cn_in) into :i_isnumeric;
>if(i_isnumeric = 1) then
>begin
>  int_out = cast(cn_in as integer);
>  status = 1;
>end
>else
>begin
>  int_out = 0;
>  status = 0;
>  if(cn_in is null) then cn_in = 'NULL!';
>  execute procedure p_db_ins_error('P_U_CN_TO_INT','CN_IN: '|| :cn_in,11);
>end
>SUSPEND;
>when any do
>begin
>  execute procedure p_db_ins_error('P_U_CN_TO_INT','CN_IN: '|| :cn_in || '
> SQL-Fehler: ' || sqlcode ,10);
>  status = 0;
>  int_out = 0;
>  suspend;
>end
> END
>
> If I call it with '1234', I get 1234 as integer. For example 'AB12' - and I
> get as status 0 an not an integer value.
>
> Dat is a string with many digits. I would spit it. When I do it with:
> s_digits = substring(:dat from 1 for 4); and give the stored (sub) procedure
> the :s_digits for input parameter, it works. Otherwise I give the stored
> (sub) procedure the substring... directly, I get a sql-error -802. But it is
> the same content in the variable. And then I get not an integer value, for
> example 1234, it ends with this error.

It looks like you register the actual value of cn_in before storing it, 
what is the problematic value. Have you checked if that is actually the 
value that you exepected? You might also want to consider removing the 
error handling from your stored procedure to check out if the error 
message contains more information.

You don't show p_u_isnumeric, have you checked if the error occurs there?

Mark
-- 
Mark Rotteveel


Re: [firebird-support] substring

2014-07-18 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
>Hello Mark,
>
>Here the code of the sub-Procedure:
>
>create or alter procedure P_U_CN_TO_INT (
>CN_IN varchar(30))
>returns (
>INT_OUT integer,
>STATUS smallint)
>AS
>declare variable I_ISNUMERIC smallint;
>BEGIN
>  select true_param from p_u_isnumeric(:cn_in) into :i_isnumeric;
>  if(i_isnumeric = 1) then
>  begin
>int_out = cast(cn_in as integer);
>status = 1;
>  end
>  else
>  begin
>int_out = 0;
>status = 0;
>if(cn_in is null) then cn_in = 'NULL!';
>execute procedure p_db_ins_error('P_U_CN_TO_INT','CN_IN: '|| :cn_in,11);
>  end
>  SUSPEND;
>  when any do
>  begin
>execute procedure p_db_ins_error('P_U_CN_TO_INT','CN_IN: '|| :cn_in || '
>SQL-Fehler: ' || sqlcode ,10);
>status = 0;
>int_out = 0;
>suspend;
>  end
>END
>
>If I call it with '1234', I get 1234 as integer. For example 'AB12' - and I
>get as status 0 an not an integer value.
>
>Dat is a string with many digits. I would spit it. When I do it with:
>s_digits = substring(:dat from 1 for 4); and give the stored (sub) procedure
>the :s_digits for input parameter, it works. Otherwise I give the stored
>(sub) procedure the substring... directly, I get a sql-error -802. But it is
>the same content in the variable. And then I get not an integer value, for
>example 1234, it ends with this error.

I wrote two tiny stored procedures without noticing the problem you are 
mentioning, that is, one stored procedure contained a substring when calling 
the other stored procedure. However, it was very basic procedures (no tables 
involved, nor conversion to numbers), so it could just be that my test doesn't 
cover your situation. What Firebird version are you using and how are you 
determining there is an error (e.g. I know that IB Expert and Hopper has some 
kind of stored procedure emulation, and errors in emulating Firebird is not the 
same as an error in Firebird)? Do you get the same error when using isql, 
IB_SQL or FlameRobin?

Set

AW: [firebird-support] substring

2014-07-18 Thread 'checkmail' check_m...@satron.de [firebird-support]
Hello Mark,

Here the code of the sub-Procedure:

create or alter procedure P_U_CN_TO_INT (
CN_IN varchar(30))
returns (
INT_OUT integer,
STATUS smallint)
AS
declare variable I_ISNUMERIC smallint;
BEGIN
  select true_param from p_u_isnumeric(:cn_in) into :i_isnumeric;
  if(i_isnumeric = 1) then
  begin
int_out = cast(cn_in as integer);
status = 1;
  end
  else
  begin
int_out = 0;
status = 0;
if(cn_in is null) then cn_in = 'NULL!';
execute procedure p_db_ins_error('P_U_CN_TO_INT','CN_IN: '|| :cn_in,11);
  end
  SUSPEND;
  when any do
  begin
execute procedure p_db_ins_error('P_U_CN_TO_INT','CN_IN: '|| :cn_in || '
SQL-Fehler: ' || sqlcode ,10);
status = 0;
int_out = 0;
suspend;
  end
END

If I call it with '1234', I get 1234 as integer. For example 'AB12' - and I
get as status 0 an not an integer value.

Dat is a string with many digits. I would spit it. When I do it with:
s_digits = substring(:dat from 1 for 4); and give the stored (sub) procedure
the :s_digits for input parameter, it works. Otherwise I give the stored
(sub) procedure the substring... directly, I get a sql-error -802. But it is
the same content in the variable. And then I get not an integer value, for
example 1234, it ends with this error.

Thanks in Advance.

Best regards

Olaf

-Ursprüngliche Nachricht-
Von: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] 
Gesendet: Freitag, 18. Juli 2014 14:33
An: firebird-support@yahoogroups.com
Betreff: Re: [firebird-support] substring

On 18-7-2014 14:00, 'checkmail' check_m...@satron.de [firebird-support]
wrote:
> If I use the following code to extract a part of a string, it works fine:
>
> s_datum = substring(:dat from 13 for 4); s_datum = char(4)
>
> Now I would give the same a stored procedure, the first input 
> parameter is XXX varchar(30), it returns me the integer-value and the 
> status (passed or not)
>
> select int_out, status from P_u_cn_to_int(substring(:dat from 13 for 
> 4)) into :i_z1,  i_status1;
>
> The second thing – it does not work – why? If I set the 
> input-parameter to ‘1234’, it works, but the substring?

"It does not work" is a bit vague. What is the value of dat, and what is the
result of the substring? Does it match the expectations of the stored
procedure?

Mark
--
Mark Rotteveel






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu
there.

Also search the knowledgebases at
http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links





Re: [firebird-support] substring

2014-07-18 Thread Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
On 18-7-2014 14:00, 'checkmail' check_m...@satron.de [firebird-support] 
wrote:
> If I use the following code to extract a part of a string, it works fine:
>
> s_datum = substring(:dat from 13 for 4);
> s_datum = char(4)
>
> Now I would give the same a stored procedure, the first input parameter
> is XXX varchar(30), it returns me the integer-value and the status
> (passed or not)
>
> select int_out, status from P_u_cn_to_int(substring(:dat from 13 for 4))
> into :i_z1,  i_status1;
>
> The second thing – it does not work – why? If I set the input-parameter
> to ‘1234’, it works, but the substring?

"It does not work" is a bit vague. What is the value of dat, and what is 
the result of the substring? Does it match the expectations of the 
stored procedure?

Mark
-- 
Mark Rotteveel






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



[firebird-support] substring

2014-07-18 Thread 'checkmail' check_m...@satron.de [firebird-support]
Hello,

 

If I use the following code to extract a part of a string, it works fine:

 

s_datum = substring(:dat from 13 for 4);

s_datum = char(4)

 

Now I would give the same a stored procedure, the first input parameter is
XXX varchar(30), it returns me the integer-value and the status (passed or
not)

select int_out, status from P_u_cn_to_int(substring(:dat from 13 for 4))
into :i_z1,  i_status1;

 

The second thing - it does not work - why? If I set the input-parameter to
'1234', it works, but the substring?

 

Thanks in Advance

 

Best regards

 

Olaf

 

 



[firebird-support] Substring search problem observed with UTF8 / UNICODE_CI_AI

2013-10-18 Thread caroline.d.beltran
I have a database with approx 10k records which I just converted from charset & 
collation 'none' to UTF8 and UNICODE_CI_AI.

Yes, I understand that substring searches are not optimizable, but with 10k 
records searching a varchar field with a size of 80 used to take milliseconds 
and use zero noticable CPU whereas it now takes approx. 4 seconds and consumes 
an entire CPU until done.

This is a huge difference

The following may be of interest to those with C/C++ knowledge:

I was reading about how some programmers use different philosophies when 
dealing with UTF-8 internally (which in our case would be the actual memory 
allocated by the firebird server when using the UTF-8 character set).

Some programmers allocate two bytes for every single UTF-8 character which 
supposedly means at least double work. Internally, they are working with UTF-16 
code points.

Alternatively, other programmers allocate 1 byte for ASCII characters (0-127) 
and two bytes for less commonly used characters such as latin / european 
characters. Asian characters are allocated three bytes per character.  This 
means that commonly used ASCII characters translate to less work for the system 
while asian characters have the disadvantage.

Here is a good article that talks about this in further detail: 
http://www.utf8everywhere.org/

[firebird-support] Substring function not working?

2013-02-28 Thread alexandermezhov
Hello!

I use FirebirdClient ADO.NET   Data Provider (v 3.0.2)
and try to execute query that look like this:

select * from "SomeTable" where substring("SomeColumn" from @p0 for 4) =
'SomeString'
where @p0 - query parameter. As a result, I get an exception:

FirebirdSql.Data.FirebirdClient.FbException (0x80004005): expression
evaluation not supported ---> expression evaluation not supported   at
FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior
be havior) in
c:\Users\Jiri\Documents\devel\NETProvider\working\trunk\NETProvider\sour\
ce\FirebirdSql\Data\FirebirdClient\FbCommand.cs:line 554   at
FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader() in
c:\Users\Jiri\Documents\devel\NETProvider\working\trunk\NETProvider\sour\
ce\FirebirdSql\Data\FirebirdClient\FbCommand.cs:line 538
However if the parameter @p0 is replace by a constant value everything
works fine:

select * from "SomeTable" where substring("SomeColumn" from 1 for 4) =
'SomeString'
My code:

class Program
{
 static void Main()
 {
 var connectionString = new FbConnectionStringBuilder
 {
 DataSource = "localhost",
 Database =
Path.GetFullPath(@"..\..\..\Data\TestDatabase.fdb"),
 ServerType =
FbServerType.Default,
 UserID = "SYSDBA",
 Password = "masterkey",
 Charset = "UTF8",
 }.ToString();
 try
 {
 using (var connection = new FbConnection(connectionString))
 {
 using (var command = connection.CreateCommand())
 {
 command.CommandText = @"select * from ""TESTENTITY""
where substring(""NAME"" from @p0 for 4) = 'Item'";
 command.Parameters.Add(new FbParameter("p0", 1));
 connection.Open();
 using (var reader = command.ExecuteReader()) // The
exception occurs here!
 {
 while (reader.Read())
 {
 Console.WriteLine("{0}", reader["NAME"]);
 }
 }
 }
 }
 }
 catch (Exception error)
 {
 Console.WriteLine(error);
 }
 Console.ReadLine();
 }
}
You can download project here  .

Please tell me what I'm doing wrong?


[Non-text portions of this message have been removed]



[firebird-support] substring

2012-05-07 Thread Mahesh Pratihari
Hi , 

 

Could you please help me how to get the reverse substring in Firebird
like in SQL

 

SELECT SUBSTRING('Mahesh/pra',9,1)

 

Which will returns 'r' in SQL , but in firebird in is returning null
values, Please help me

 

 

Thanks,

Mahesh Pratihari

Sonata Software Limited 

Phone   : +91 80 3097 1527

Mobile  : +91 99808 37446

www.sonata-software.com  

 

Please don't print this email unless you really need to. This will
preserve trees on our planet.

 



[Non-text portions of this message have been removed]