Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: help me!!! how can I insert data(pro*c)?
A copy of this was sent to kyutae lim <ktlim_at_lgtel.co.kr>
(if that email address didn't require changing)
On Tue, 05 Jan 1999 21:41:55 +0900, you wrote:
>hi , there.
>
>I have a big problem in pro*c program.
>this is sample program and table layout.
>I found ora-1400 error.
>hw can I insert '1 byte space charactor' in not null column?
>-----------------------------------------------------
>exec sql include sqlca.h;
>typedef char char1;
>EXEC SQL TYPE char1 IS char(1);
>static char1 sql_dr_acc_type;
>main()
>{
> char username[10], password[10];
>
> strcpy(username, "SCOTT");
> strcpy(password, "TIGER");
> exec sql connect :username identified by :password;
> sql_dr_acc_type = ' ';
> exec sql insert into a (b) values (:sql_dr_acc_type);
> printf("code :%c:%d:\n", sql_dr_acc_type,sqlca.sqlcode);
> exec sql commit;
>}
>--------------------------------------------------------
>table layout
>table a (b char(1) not null)
> ^^^^^^
Here are 2 ways to do this:
static void process( void )
{
typedef char char1[2];
EXEC SQL TYPE char1 IS STRING(2);
char1 sql_dr_acc_type;
EXEC SQL WHENEVER SQLERROR DO sqlerror_hard(); strcpy(sql_dr_acc_type, " ");
exec sql insert into a (b) values (:sql_dr_acc_type);
exec sql commit;
}
or
static void process( void )
{
varchar sql_dr_acc_type[1];
EXEC SQL WHENEVER SQLERROR DO sqlerror_hard();
sql_dr_acc_type.arr[0] = ' ';
sql_dr_acc_type.len = 1;
exec sql insert into a (b) values (:sql_dr_acc_type);
exec sql commit;
}
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA
--
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Tue Jan 05 1999 - 09:46:35 CST
![]() |
![]() |