Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Failed to write output data to ORACLE date type field #2414

Closed
vicochan opened this issue Mar 5, 2024 · 1 comment
Closed

Failed to write output data to ORACLE date type field #2414

vicochan opened this issue Mar 5, 2024 · 1 comment

Comments

@vicochan
Copy link

vicochan commented Mar 5, 2024

I have an example of writing output data to an ORALCE table,

the table structure is as follows

create table GZ_MIGRATE_HISTORICAL_30_TEST
(
snap_time DATE,
city VARCHAR2(20),
population_total NUMBER,
migrate_total NUMBER,
createon DATE default sysdate
)
The following table describes the YAML configuration:

pipeline:
  processors:
    - bloblang: |
        root.arr = content().split(",")
        root.snap_time = root.arr.index(0).string().ts_parse("20060102").ts_format("2006-01-02")
        root.city = root.arr.index(1).string()
        root.population_total = root.arr.index(2).int32()
        root.migrate_total = root.arr.index(3).int32()
        root.createon = now()
    - catch:
      - log:
          message: "Processing failed due to: ${!error()}"
output:
  sql_insert:
    driver: oracle
    dsn: oracle://user:password@192.168.1.1:1521/dbname
    table: GZ_MIGRATE_HISTORICAL_30_TEST
    columns:
      - snap_time
      - city
      - population_total
      - migrate_total
      - createon
    args_mapping:
      root = [ this.createon.ts_strftime("%Y-%b-%d %H:%M:%S"),this.city,this.population_total,this.migrate_total,this.createon.ts_strftime("%Y-%b-%d %H:%M:%S")] 

The error message is as follows:

level=error msg="Failed to send message to sql_insert: ORA-01861: literal does not match format string\n" @service=stc label="" path=root.output

Another way to write it

output:
  sql_raw:
    driver: oracle
    dsn: oracle://user:password@192.168.1.1:1521/dbname
    query: |
      INSERT INTO GZ_MIGRATE_HISTORICAL_30_TEST1 (snap_time,city,population_total,migrate_total,createon) VALUES(to_date($1,'yyyy-mm-dd'),$2,$3,$4,to_date($5,'yyyy-mm-dd'));
    args_mapping: |
      root = [
      this.createon,
      this.city,
      this.population_total,
      this.migrate_total,
      this.createon,
      ]

I also want to use the same mistake in another way, what is the syntax for writing the date type field of ORALCE?

@Jeffail
Copy link
Collaborator

Jeffail commented Mar 6, 2024

Converting to a discussion as per #2026

@redpanda-data redpanda-data locked and limited conversation to collaborators Mar 6, 2024
@Jeffail Jeffail converted this issue into discussion #2415 Mar 6, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants