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 7067673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:13:51+00:00 2026-05-28T05:13:51+00:00

I am using in insert statement to convert BDE table (source) to a Firebird

  • 0

I am using in insert statement to convert BDE table (source) to a Firebird table (destination) using IB Datapump. So the INSERT statement is fed by source table values via parameters. One of the source field parameters is alphanum (SOURCECHAR10 char(10), holds mostly integers and needs to be converted to integer in the (integer type) destination column NEWINTFLD. If SOURCECHAR10 is not numeric, I want to assign 0 to NEWINTFLD.

I use IIF and SIMILAR to to test whether the string is numeric, and assign 0 if not numeric as follows:

INSERT INTO "DEST_TABLE" (......,  "NEWINTFLD",.....)          
VALUES(..., IIF( :"SOURCECHAR10" SIMILAR TO '[[:DIGIT:]]*', :"SOURCECHAR10", 0),..)

For every non numeric string however, I still get conversion errors (DSQL error code = -303).

I tested with only constants in the IIF result fields like SOURCECHAR10" SIMILAR TO '[[:DIGIT:]]*', 1, 0) and that works fine so somehow the :SOURCECHAR10 in the true result field of the IIF generates the error.
Any ideas how to get around this?

  • 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. Editorial Team
    Editorial Team
    2026-05-28T05:13:52+00:00Added an answer on May 28, 2026 at 5:13 am

    When your query is executed, the parser will notice that second use of :"SOURCECHAR10" is used in a place where an integer is expected. Therefor it will always convert the contents of :SOURCECHAR10 into an integer for that position, even though it is not used if the string is non-integer.

    In reality Firebird does not use :"SOURCECHAR10" as parameters, but your connection library will convert it to two separate parameter placeholders ? and the type of the second placeholder will be INTEGER. So the conversion happens before the actual query is executed.

    The solution is probably (I didn’t test it, might contain syntax errors) to use something like (NOTE: see second example for correct solution):

    CASE 
       WHEN :"SOURCECHAR10" SIMILAR TO '[[:DIGIT:]]*' 
          THEN CAST(:"SOURCECHAR10" AS INTEGER) 
       ELSE 0 
    END
    

    This doesn’t work as this is interpreted as a cast of the parameter itself, see CAST() item ‘Casting input fields’

    If this does not work, you could also attempt to add an explicit cast to VARCHAR around :"SOURCECHAR10" to make sure the parameter is correctly identified as being VARCHAR:

    CASE 
       WHEN :"SOURCECHAR10" SIMILAR TO '[[:DIGIT:]]*' 
          THEN CAST(CAST(:"SOURCECHAR10" AS VARCHAR(10) AS INTEGER) 
       ELSE 0 
    END
    

    Here the inner cast is applied to the parameter itself, the outer cast is applied when the CASE expression is evaluated to true

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using INSERT INTO to copy rows of data from one table to another:
I am using mysqli_stmt_bind_param() to create an INSERT statement. For some reason I am
Using only MySQL , I'm seeing if it's possible run an insert statement ONLY
I know that I can insert multiple rows using a single statement, if I
iam using a simple insert script function to pass the values from registration html
I'm using a SELECT statement in T-SQL on a table similar to this: SELECT
The INSERT syntax I've been using is this INSERT INTO TableName VALUES (...) The
I want to insert values that are stored in a dictionary into a table.
I'm trying to do a basic insert statement using a parameterized query. My problem
i am trying to an insert statement using last_insert_id() , i want to take

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.