RE: select error with null string -- error code -209

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: "'HYip'" <hualinyip(at)earthlink(dot)net>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: RE: select error with null string -- error code -209
Date: 2001-05-07 13:56:34
Message-ID: 01C0D6DB.FFE7FF30.mascarm@mascari.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Have a look at the COALESCE() function. You may want to wirte your
query as:

SELECT accountname, COALESCE(account, '') FROM
Account WHERE AccountID = %d

Hope that helps,

Mike Mascari
mascarm(at)mascari(dot)com

-----Original Message-----
From: HYip [SMTP:hualinyip(at)earthlink(dot)net]
Sent: Friday, May 04, 2001 11:48 AM
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] select error with null string -- error code -209

I am using following codes to get the accountname, and account from
the
Table Account;
accountname, and account are varchar(30) and it can be null.
The code has no problem when both accountname, and account are not
null. It gives me an errror code of -209 when the account is null.
Anyone has any idea of fixing it.

the output looks like :
error in fetch -209

Thanks,

EXEC SQL BEGIN DECLARE SECTION;
char query_string[256];
char name[30];
char account[30];
EXEC SQL END DECLARE SECTION;

EXEC SQL CONNECT TO :dbname user :userid/:passwd;
if(sqlca.sqlcode) {
printf("error in connect\n");
return FALSE;
}
sprintf(query_string, "SELECT accountname, account FROM Account
where
AccountID = %d", customerId);

EXEC SQL PREPARE sql_command FROM :query_string;
EXEC SQL DECLARE c_cursor2 CURSOR FOR sql_command;/* DECLARE a
cursor
*/
EXEC SQL OPEN c_cursor2;
if(sqlca.sqlcode) {
printf("error in cursor\n");
return FALSE;
}
EXEC SQL FETCH c_cursor2 INTO :name, :account;
if(sqlca.sqlcode) {
printf("error in fetch %d\n", sqlca.sqlcode);
return FALSE;
}

---------------------------(end of
broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2001-05-07 13:58:00 Re: PostgreSQL vs. Interbase
Previous Message Lieven Van Acker 2001-05-07 12:58:54 views & triggers