Hello, first posting:
I am using bcp_sendrow to INSERT data from program variables into the
database.
I am sending less columns than the database contains, because new
columns need to be added to the tables before the program is changed.
However, despite the fact that the unspecified columns have default
values associated with them, I still get the error message:
"Not enough columns bound"
every time I attempt to insert a line. It does not matter if the
column is NULLable or not, I have determined that it will fail if the
unspecified columns are at the end of the table. Unspecified columns
in the middle of the table automatically get populated with the default
value or NULL.
Has anyone else come across this problem? Is there some sort of switch
I can use to make this work? The only solution I have come up with is
to insert new columns in the middle of the table, which I shouldn't
have to do (and it's slow at that).
Thanks in advance,
RobBind all columns and set the columns to ignore as NULL like this:
r = bcp_bind(hdbc, /* Database Handle */
(const LPCBYTE)"", /* Empty String */
0, /* 0 prefix len */
SQL_NULL_DATA, /* length of -1 = set column to NULL */
(const LPCBYTE)"", /* Terminator Char */
1, /* Terminator Length = 1 for \0x00 */
SQLCHARACTER, /* Column type */
Col_Num /* Column Number */
);
"Robert B" <rob@.automatedfinancial.com> wrote in message
news:1148604213.015728.148440@.38g2000cwa.googlegroups.com...
> Hello, first posting:
> I am using bcp_sendrow to INSERT data from program variables into the
> database.
> I am sending less columns than the database contains, because new
> columns need to be added to the tables before the program is changed.
> However, despite the fact that the unspecified columns have default
> values associated with them, I still get the error message:
> "Not enough columns bound"
> every time I attempt to insert a line. It does not matter if the
> column is NULLable or not, I have determined that it will fail if the
> unspecified columns are at the end of the table. Unspecified columns
> in the middle of the table automatically get populated with the default
> value or NULL.
> Has anyone else come across this problem? Is there some sort of switch
> I can use to make this work? The only solution I have come up with is
> to insert new columns in the middle of the table, which I shouldn't
> have to do (and it's slow at that).
>
> Thanks in advance,
> Rob
>|||Thanks, Mike,
I have no problem binding to a column and inserting NULL data. My
problem is that my program will fail with "not enough columns bound" as
soon as a new column is added to the table, even if the new column is
set to NULL, default NULL. I need to maintain some sort of
backwards-compatibility where the program will continue to work even
though I have not specified all the columns.
Rob|||I'm working on a similar problem myself right now. The fix I'm looking at
is to grab the column information from the table ahead of time and bind the
columns dynamically using that information. The info is available in the
INFORMATION_SCHEMA views, and I'm also testing a couple of other methods
myself. It's definitely more work, but definitely necessary in my case.
"Robert B" <rob@.automatedfinancial.com> wrote in message
news:1148659354.289141.188110@.j55g2000cwa.googlegroups.com...
> Thanks, Mike,
> I have no problem binding to a column and inserting NULL data. My
> problem is that my program will fail with "not enough columns bound" as
> soon as a new column is added to the table, even if the new column is
> set to NULL, default NULL. I need to maintain some sort of
> backwards-compatibility where the program will continue to work even
> though I have not specified all the columns.
> Rob
>
订阅:
博文评论 (Atom)
没有评论:
发表评论