Subject | Re: [firebird-support] Execute Statement problem with timestamp |
---|---|
Author | Helen Borrie |
Post date | 2011-11-24T19:09:51Z |
At 12:18 PM 24/11/2011, you wrote:
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
>I've a little problem with a sql statement:Two problems here:
>
>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 test
>it with quotest '''', but it does not work.
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