Search Postgresql Archives

postgres pg_bulkload c filter function in c programming

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gurus,

Reading the data from file and loading it using pg_bulkload- C filter. As
per documentation, C filter is much faster than SQL filter.

I'm new to C. Gone through this documentation. Not clear, how to start.
https://www.postgresql.org/docs/current/static/xfunc-c.html.

Can someone kindly guide me to create C code, so that it can be called in
postgres function?

Here is the sample data.File has no header.

    Sample Data:
    ABC|20170101|DEF ||GHIJ|KLM

    Target Table Definition:
    COLA numeric(5,0)
    COLB date
    COLC text
    COLD text
    COLE text

    First column should be mapped to COLA
    Second column should be mapped to COLB
    Third column should be mapped to COLD
    Fourth column should be mapped to COLC
    Fifth column should be mapped to Some default value(column is not
present in source) 

    Transformation:
    a)First column should be mapped to COLA. It is numeric in target table.
If any alpha-characters were present, default this column with '0'.
Otherwise, source value should be moved to table.
    b)Second column should be mapped to COLB. TO_DATE function from text
format. File will have date format as YYYYMMDD. It should be converted to
date.
    c)Third column should be mapped to COLD.Need to Trim both leading and
trailing spaces.
    d)Fourth column should be mapped to COLC. If it NULL, some value should
be defaulted.
    e)Only few columns from source file should be loaded. In this case, only
first four columns should be loaded.
    f)Different ordering in source files & target columns.In this case,
            Third column should be mapped to COLD
            Fourth column should be mapped to COLC
    g)COLE should be loaded with default value. This column is not present
in source file.

These transformations, can be handled with query after loading all the data
as varchar and nullable. But we need to handle this before loading as like
we do in Oracle.

Do you think, these functionalities can be accomplished using C programming?
Some standard syntax for writing these functionalities would be greatly
helpful.

Thanks




--
View this message in context: http://postgresql.nabble.com/postgres-pg-bulkload-c-filter-function-in-c-programming-tp5936651.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux