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

  • SEARCH
  • Home
  • 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 767801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:04:58+00:00 2026-05-14T18:04:58+00:00

The always interesting issue of NULL Vs Blank is driving me bit crazy now.

  • 0

The always interesting issue of NULL Vs Blank is driving me bit crazy now.

I have two ESQL/C structures that represent two tables. I’m fetching a row from
one table in a cursor. Using the values of two fields from this fetch, I will retrieve
a row from another table. I know before hand the second fetch will definitely return one row.

Now, second table can have blank values. By blank, I mean values like ”. When I do a unload
these characters show up as ‘\ ‘. But within the C program, these are not getting fetched, I believe.

Alternatively, I’m not able to see if these values are present. Assuming I fetch the values in the
char *value,

if (value[0] == ‘\0’) or
if (value[0] == ‘ ‘)

doesn’t work. gdb shows something like
value = “\000”, ‘ ‘ . But I’m not able to verify this from the C code.

I manually loaded the table through a pipe delimited file. For inserting the blank, I typed
|\ |.

Can anyone please let me know where I’m wrong.

  • 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-14T18:04:59+00:00Added an answer on May 14, 2026 at 6:04 pm

    You should be using a join to collect the data from the two tables in one operation. DBMS are very good at doing joins; when you do joins manually in the application, you slow things down, usually dramatically.

    Data types are critical – and unspecified in the question.

    SQL Types

    • VARCHAR(n) – trailing blanks are significant; the zero length string is not NULL.
    • CHAR(n) – trailing blanks are added by the DBMS and can be removed by applications.

    ESQL/C Types:

    • char – for CHAR data; blank padded to full length with NUL ‘\0’ terminator.
    • fixchar – for CHAR data; blank padded to full length without NUL ‘\0’ terminator.
    • varchar – for VARCHAR data; not blank padded.
    • Pointers to these types can also be used, complicating matters again (the compiler doesn’t know how big the space is that the pointer points at).

    You also mention using ‘\‘ to load data. That is a special notation used with zero-length non-null VARCHAR fields to indicate that value; the empty field indicates a NULL value in the unload format. (On disk, an empty non-null VARCHAR occupies one byte, value 0x00 for length zero; a NULL VARCHAR occupies two bytes, values 0x01 0x00 for a length of 1 and a NULL (or NUL) value.)

    Judging from what you say, you have possibly empty (but not NULL) VARCHAR(n) values in the second table. Those should show up as string values where the first byte is NUL ‘\0’ in your C code – regardless of which of the variable types you use. The output from GDB is consistent with that; the first byte is ‘\0’ (or ‘\000’); the rest is irrelevant.

    You may want to look up indicator variables; these tell you about whether a particular value selected from the DB is NULL or not.

    If you still have problems, post the code (preferably a very small compilable program that shows the problem – say up to 50 lines or so; or a small fragment of the code – say 20 lines or so).

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

Sidebar

Related Questions

I have an interesting issue where a class inherits from a class that implements
I have encountered an interesting issue in which I have my master trying to
I've always found it interesting that in JavaScript you can actually extend functions into
I have the following interesting problem. I've created a secondary login form. From that
So I have an interesting question that I am not sure is considered a
I've got an interesting (well, to me at least) issue: I have a notification
I am having an interesting issue with SSRS and security settings. I have 2008
I always have found the open source space interesting but have never actually participated
Fundamental question: Why aren't @Embedded objects always instantiated? The interesting observation is that Ebean
I always read that one reason to chose a RESTful architecture is (among others)

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.