Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 105187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:23:59+00:00 2026-05-11T01:23:59+00:00

I have a query in Delphi using DBExpress TSQLQuery that looks like so ActiveSQL.sql.add(‘SELECT

  • 0

I have a query in Delphi using DBExpress TSQLQuery that looks like so

ActiveSQL.sql.add('SELECT * FROM MYTABLE where MYFIELD=(:AMYFIELD) ');  ActiveSQL.ParamByName('AMYFIELD').AsString    := 'Some random string that is to long for the field';  ActiveSQL.Open; 

If I run it, when it executes the open command I get the following exception

in class TDBXError with message ‘arithmetic exception, numeric overflow or string truncation’.

This is caused by the string in AMYFIELD been longer then the tables field length, MYFIELD is Varchar(10), If I trim it down to a shorter string it works OK, and if I add the string directly into the SQL like so

  ActiveSQL.sql.add('SELECT * FROM MYTABLE where MYFIELD='Some random string that is to long for the field' '); 

it works OK, i.e. does not complain about the truncation, now if this was an insert/update I would want to know about the truncation , but as its just been used for a search I would like to stop it.

Is there any way I can tell DBExpress that it is OK to truncate my strings? or is there a workable work around for this

I would like to avoid having to add something like

l_input := copy(l_input,0,fieldLength-1);

as looks messy and would make maintaining the code harder.

I am using Delphi 2007 with Firebird 2 via the interbase driver if that helps?

UPDATE:

@Erick Sasse it looks like your right, I found the error message on the firebird FAQ site http://www.firebirdfaq.org/faq79/

@inzKulozik the LeftStr works fine, although I cannot get ActiveSQL.ParamByName(‘AMYFIELD’).Size to work , but this still seams messy to me, and harder to maintain.

I have also seen a method that adds substr to the SQL: something like

select * from mytable where myname = substr(:MYNAME,0,10) 

Again looks harder to maintain, Ideally I would like a Firebird/ DBExpress config setting that fixes this problem, but until I can find one I’ll go with inzKulozik’s solution and hope the table structure does not change to much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:23:59+00:00Added an answer on May 11, 2026 at 1:23 am
    l_input := copy(l_input,**0**,fieldLength-1); 

    You can’t copy substring from position 0!

    Try this:

    l_input := LeftStr(l_input, fieldLength); 

    or

    ActiveSQL.ParamByName('AMYFIELD').AsString := LeftStr('Some random string that is to long for the field', ActiveSQL.ParamByName('AMYFIELD').Size); 

    or

    with ActiveSQL.ParamByName('AMYFIELD') do   AsString := LeftStr('Some random string that is to long for the field', Size); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 88k
  • Answers 88k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think I have the solution. Since we know the… May 11, 2026 at 5:40 pm
  • Editorial Team
    Editorial Team added an answer Gecko-based browsers support a tag attribute called "autocomplete". So in… May 11, 2026 at 5:40 pm
  • Editorial Team
    Editorial Team added an answer You can use serialization to make the copy pretty easily… May 11, 2026 at 5:40 pm

Related Questions

I have a query in Delphi using DBExpress TSQLQuery that looks like so ActiveSQL.sql.add('SELECT
I have a Delphi application which hits a database (usually MySql) every 60 seconds
SOLVED I am using delphi 2009. My program listens for usb drives being connected
I am developing a web application, in which I have the following type of
I have a paradox table from a legacy system I need to run a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.