Subject | AW: [firebird-support] Execute Statement problem with timestamp |
---|---|
Author | Olaf Kluge |
Post date | 2011-11-25T06:19:18Z |
Hello Helen,
Thank you very much.
Best regards.
Olaf
1. Don't use the colon prefix when attempting to concatenate a variable in
an exe-string. The colon is to be used when the variable is passed in a
direct SQL statement ONLY.
2. When passing an apostrophe as a literal you have to "escape" it with
another apostrophe. That is, two single quote characters.
Try this:
s_stmmain = 'insert into ' || s_stmtable || ' (kd_id, fnr, fbeginn, fende)
values (''' <--- 3 apostrophes
|| t_timestamp
|| ''', ' <--- 3 apostrophes + comma + 1 apostrophe
|| cast(i_fnr as varchar(4))
|| ','
|| '1111'
|| ', '
|| '2222' || ')';
./heLen
[Non-text portions of this message have been removed]
Thank you very much.
Best regards.
Olaf
>I've a little problem with a sql statement:test
>
>s_stmmain = 'insert into ' || :s_stmtable || '(kd_id, fnr, fbeginn, fende)
>values ('
>
> || :t_timestamp || ',' || cast(:i_fnr as varchar(4)) || ','
>
> || '1111' || ',' || '2222' || ')';
>
> execute statement s_stmmain;
>
>t_timestamp is a timestamp value and has a blank character. Now, I have
>it with quotest '''', but it does not work.Two problems here:
1. Don't use the colon prefix when attempting to concatenate a variable in
an exe-string. The colon is to be used when the variable is passed in a
direct SQL statement ONLY.
2. When passing an apostrophe as a literal you have to "escape" it with
another apostrophe. That is, two single quote characters.
Try this:
s_stmmain = 'insert into ' || s_stmtable || ' (kd_id, fnr, fbeginn, fende)
values (''' <--- 3 apostrophes
|| t_timestamp
|| ''', ' <--- 3 apostrophes + comma + 1 apostrophe
|| cast(i_fnr as varchar(4))
|| ','
|| '1111'
|| ', '
|| '2222' || ')';
./heLen
[Non-text portions of this message have been removed]