Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert null into a field (type of date) of externall table will insert '17.11.1858' [CORE3804] #4147

Closed
firebird-automations opened this issue Mar 30, 2012 · 8 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Yakushev.Y (yyy)

Test case:

CREATE TABLE ET EXTERNAL 'E:\FBEXTERNAL\ET.DAT' (
ID INTEGER,
DATE_FIELD DATE
);

insert into et (id,date_field) values (1,null)

select * from et

      ID  DATE\_FIELD

============ ===========
1 17-NOV-1858

Is this a bug ?

@firebird-automations
Copy link
Collaborator Author

Modified by: Yakushev.Y (yyy)

summary: Insert null into a field of externall table will insert '17.11.1858' => Insert null into a field (type of date) of externall table will insert '17.11.1858'

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

NULLs are not supported for external tables. However, I'd rather prefer to see an error raised in this case.

@firebird-automations
Copy link
Collaborator Author

Commented by: Yakushev.Y (yyy)

It'a a pity. :(
External tables is a flexiable and comfortable way to import data from external systems.
As for example I can convert various dbf data and load it into database using stored procedures.

I also tried to use it in order to transfer big amount of data across databases, as the fastest way to load data is to export table in a copy of it in external table and then insert it like this.

{{{
begin
select list(' declare variable '||field_name||' '||meta_type,';') /*list_of_vars*/, list(':'||field_name) /*list_of_params*/, list (field_name) /*list_of_fields*/
from META_ET_TABLE_field_types (:source,'-1')
where meta_type not containing 'BLOB' or 1=:ext into :list_of_vars,:list_of_params,list_of_fields;
end
/* Если роль не REPL, то REPL$ID и REPL$GRPID не копируются */
if (:srole <> 'REPL') then
begin
select list(' declare variable '||field_name||' '||meta_type,';') /*list_of_vars*/, list(':'||field_name) /*list_of_params*/, list (field_name) /*list_of_fields*/
from META_ET_TABLE_field_types (:source,'-1')
where (meta_type not containing 'BLOB' or 1=:ext) and field_name not starting with 'REPL$' into :list_of_vars,:list_of_params,list_of_fields;
end

/* формируем начало для скрипта копирования таблицы */
copysql = 'execute block returns (counter integer) as '||:list_of_vars||'; begin counter=0; for select '||:list_of_fields||' from '||:source||' ' ||:customwhere||' into '||:list_of_params||' do begin'||
' begin update or insert into '||:target||' ('||:list_of_fields||') values ('||:list_of_params
||'); end counter=:counter+1; /*suspend;*/ end'||' end ';

/* получаем данные для SQL */
execute statement copysql as USER :SUSER PASSWORD :SPASSWORD ROLE :SROLE ;
}}

Error won't help me, I'll treat '17.11.1858' as null.

@firebird-automations
Copy link
Collaborator Author

Commented by: @krilbe

You could import/export date data as varchar and use cast in select/insert. In that case you could use empty string or some marker, e.g. '<NULL>' for nulls.

@firebird-automations
Copy link
Collaborator Author

Commented by: Yakushev.Y (yyy)

That what I'll do.

Issue is closed.

But may be FB team will think of adding support for NULLs in external tables.

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

See CORE2198 and CORE3438.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant