pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedNULLs in ecpg
6+ messages / 3 participants
[nested] [flat]
* NULLs in ecpg
@ 2004-07-16 15:50 wespvp@syntegra.com
2004-07-16 16:11 ` Re: NULLs in ecpg Edmund Bacon <ebacon@onesystem.com>
0 siblings, 1 reply; 6+ messages in thread
From: wespvp@syntegra.com @ 2004-07-16 15:50 UTC (permalink / raw)
To: pgsql-interfaces
I couldn't find this in the archives... In an ecpg program, given the
statement (taken from the manual):
EXEC SQL INSERT INTO sometable VALUES (:v1, ¹foo¹, :v2);
Is there a way to create the record where ':v1' is NULL - as with indicators
in a FETCH? Or, do I have to generate different SQL statements in the C
program?
Wes
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: NULLs in ecpg
2004-07-16 15:50 NULLs in ecpg wespvp@syntegra.com
@ 2004-07-16 16:11 ` Edmund Bacon <ebacon@onesystem.com>
2004-07-16 16:25 ` Re: NULLs in ecpg wespvp@syntegra.com
0 siblings, 1 reply; 6+ messages in thread
From: Edmund Bacon @ 2004-07-16 16:11 UTC (permalink / raw)
To: wespvp@syntegra.com; +Cc: pgsql-interfaces
wespvp@syntegra.com wrote:
> I couldn't find this in the archives... In an ecpg program, given the
> statement (taken from the manual):
>
> EXEC SQL INSERT INTO sometable VALUES (:v1, 'foo', :v2);
Indicators works as expected. e.g.:
EXEC SQL INSERT INTO sometable
VALUES (:v1 :v1_ind, 'foo', :v2 :v2_ind);
>
> Is there a way to create the record where ':v1' is NULL - as with indicators
> in a FETCH? Or, do I have to generate different SQL statements in the C
> program?
>
> Wes
>
--
Edmund Bacon <ebacon@onesystem.com>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: NULLs in ecpg
2004-07-16 15:50 NULLs in ecpg wespvp@syntegra.com
2004-07-16 16:11 ` Re: NULLs in ecpg Edmund Bacon <ebacon@onesystem.com>
@ 2004-07-16 16:25 ` wespvp@syntegra.com
2004-07-16 16:39 ` Re: NULLs in ecpg Edmund Bacon <ebacon@onesystem.com>
0 siblings, 1 reply; 6+ messages in thread
From: wespvp@syntegra.com @ 2004-07-16 16:25 UTC (permalink / raw)
To: Edmund Bacon <ebacon@onesystem.com>; +Cc: pgsql-interfaces
On 7/16/04 11:11 AM, "Edmund Bacon" <ebacon@onesystem.com> wrote:
> Indicators works as expected. e.g.:
>
> EXEC SQL INSERT INTO sometable
> VALUES (:v1 :v1_ind, 'foo', :v2 :v2_ind);
Hmm. I tried that. Just tried it again and it worked. Must have had a
typo before. Sorry.
What about if I have something like:
... VALUES (TO_TIMESTAMP(:expirationDate, 'YYYYMMDDHH24MISS'), 'foo', :v2)
How can I insert NULLS for expirationDate when there's a function in the
way? Using
... VALUES (TO_TIMESTAMP(:expirationDate, 'YYYYMMDDHH24MISS') :ind1, ...
won't work.
Wes
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: NULLs in ecpg
2004-07-16 15:50 NULLs in ecpg wespvp@syntegra.com
2004-07-16 16:11 ` Re: NULLs in ecpg Edmund Bacon <ebacon@onesystem.com>
2004-07-16 16:25 ` Re: NULLs in ecpg wespvp@syntegra.com
@ 2004-07-16 16:39 ` Edmund Bacon <ebacon@onesystem.com>
2004-07-22 17:29 ` Re: NULLs in ecpg wespvp@syntegra.com
0 siblings, 1 reply; 6+ messages in thread
From: Edmund Bacon @ 2004-07-16 16:39 UTC (permalink / raw)
To: wespvp@syntegra.com; +Cc: pgsql-interfaces
wespvp@syntegra.com wrote:
> On 7/16/04 11:11 AM, "Edmund Bacon" <ebacon@onesystem.com> wrote:
>
>
>>Indicators works as expected. e.g.:
>>
>>EXEC SQL INSERT INTO sometable
>> VALUES (:v1 :v1_ind, 'foo', :v2 :v2_ind);
>
>
> Hmm. I tried that. Just tried it again and it worked. Must have had a
> typo before. Sorry.
>
> What about if I have something like:
>
> ... VALUES (TO_TIMESTAMP(:expirationDate, 'YYYYMMDDHH24MISS'), 'foo', :v2)
>
> How can I insert NULLS for expirationDate when there's a function in the
> way? Using
>
> ... VALUES (TO_TIMESTAMP(:expirationDate, 'YYYYMMDDHH24MISS') :ind1, ...
>
> won't work.
No, but
... VALUES (TO_TIMESTAMP(:expirationDate :ind1, 'YYYYMMDDHH24MISS'), ..
should
--
Edmund Bacon <ebacon@onesystem.com>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: NULLs in ecpg
2004-07-16 15:50 NULLs in ecpg wespvp@syntegra.com
2004-07-16 16:11 ` Re: NULLs in ecpg Edmund Bacon <ebacon@onesystem.com>
2004-07-16 16:25 ` Re: NULLs in ecpg wespvp@syntegra.com
2004-07-16 16:39 ` Re: NULLs in ecpg Edmund Bacon <ebacon@onesystem.com>
@ 2004-07-22 17:29 ` wespvp@syntegra.com
2004-07-22 17:51 ` Re: NULLs in ecpg Peter Eisentraut <peter_e@gmx.net>
0 siblings, 1 reply; 6+ messages in thread
From: wespvp@syntegra.com @ 2004-07-22 17:29 UTC (permalink / raw)
To: pgsql-interfaces
What is the scope of a BEGIN or an implicit transaction in ECPG? Is it a
physical subroutine, or can it span functions containing EXEC SQL
statements?
For example, if I have:
void a (xxx)
{
EXEC SQL SELECT ... for UPDATE;
EXEC SQL UPDATE ...
}
void b (xxx)
{
EXEC SQL begin;
a(xxxx);
a(yyyy);
EXEC SQL COMMIT;
}
Do the multiple calls to 'a' remain in the same transaction?
Wes
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: NULLs in ecpg
2004-07-16 15:50 NULLs in ecpg wespvp@syntegra.com
2004-07-16 16:11 ` Re: NULLs in ecpg Edmund Bacon <ebacon@onesystem.com>
2004-07-16 16:25 ` Re: NULLs in ecpg wespvp@syntegra.com
2004-07-16 16:39 ` Re: NULLs in ecpg Edmund Bacon <ebacon@onesystem.com>
2004-07-22 17:29 ` Re: NULLs in ecpg wespvp@syntegra.com
@ 2004-07-22 17:51 ` Peter Eisentraut <peter_e@gmx.net>
0 siblings, 0 replies; 6+ messages in thread
From: Peter Eisentraut @ 2004-07-22 17:51 UTC (permalink / raw)
To: wespvp@syntegra.com; pgsql-interfaces
wespvp@syntegra.com wrote:
> What is the scope of a BEGIN or an implicit transaction in ECPG? Is
> it a physical subroutine, or can it span functions containing EXEC
> SQL statements?
It is independent of the control flow of your C program. Only the order
of the actually executed SQL statements matters.
> For example, if I have:
>
>
> void a (xxx)
> {
> EXEC SQL SELECT ... for UPDATE;
> EXEC SQL UPDATE ...
> }
>
> void b (xxx)
> {
> EXEC SQL begin;
>
> a(xxxx);
>
> a(yyyy);
>
> EXEC SQL COMMIT;
> }
>
>
> Do the multiple calls to 'a' remain in the same transaction?
Indeed
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2004-07-22 17:51 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-07-16 15:50 NULLs in ecpg wespvp@syntegra.com
2004-07-16 16:11 ` Edmund Bacon <ebacon@onesystem.com>
2004-07-16 16:25 ` wespvp@syntegra.com
2004-07-16 16:39 ` Edmund Bacon <ebacon@onesystem.com>
2004-07-22 17:29 ` wespvp@syntegra.com
2004-07-22 17:51 ` Peter Eisentraut <peter_e@gmx.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox