-3

Here is my php code with laravel framework below:

 $migrationData = array(
    'po_code' => 184,
    'mnyr' => "06/2022",
    'dist_code' => $request->district_code[$i],
    'thana_code' => $request->thana_code[$i],
    'loan_code' => $request->loan_code[$i],
    'cum_disb' => $request->cum_disb[$i] ?? 0,
    'member' => $request->member[$i] ?? 0,
    'borrower' => $request->borrower[$i] ?? 0,
    'loan_fy' => $request->loan_fy[$i] ?? 0,
    'cum_borr' => $request->cum_borr[$i] ?? 0,
);

$findRecord =  array(
    'po_code'                   => 123,
    'mnyr'                      => "06/2022",
    'dist_code'                 =>  $request->district_code[$i],
    'thana_code'                => $request->thana_code[$i],
    'loan_code'                 => $request->loan_code[$i],
);

DB::connection('oracle')->table('PRA_LN_DIST_WISE_DISB')
    ->updateOrInsert(
        $findRecord,
        $migrationData
    );

Here is table structer:

create table PRA_LN_DIST_WISE_DISB
(
  po_code      VARCHAR2(4) not null,
  mnyr         VARCHAR2(7) not null,
  dist_code    VARCHAR2(4) not null,
  thana_code   VARCHAR2(6) not null,
  loan_code    VARCHAR2(7) not null,
  cum_disb     NUMBER(17,2),
  member       NUMBER(17,2),
  borrower     NUMBER(17,2),
  loan_fy      NUMBER(17,2),
  cum_borr     NUMBER(17,2),
  ins_user     VARCHAR2(50),
  ins_date     DATE,
  upd_user     VARCHAR2(50),
  upd_date     DATE,
  posting_flag VARCHAR2(3),
  status_date  DATE
);
alter table PRA_LN_DIST_WISE_DISB
  add constraint PK_PRA_LN_DIST_WISE_DISB primary key (PO_CODE, MNYR, DIST_CODE, THANA_CODE, LOAN_CODE);

When I am trying to do Insert/Update this Error is being thrown:

/home/microfinplus/public_html/dus/vendor/laravel/framework/src/Illuminate/Database/Connection.php 647 Error Code : 904 Error Message : ORA-00904: "member": invalid identifier Position : 142 Statement : update "PRA_LN_DIST_WISE_DISB" set "PO_CODE" = :p0, "MNYR" = :p1, "DIST_CODE" = :p2, "THANA_CODE" = :p3, "LOAN_CODE" = :p4, "CUM_DISB" = :p5, "member" = :p6, "BORROWER" = :p7, "LOAN_FY" = :p8, "CUM_BORR" = :p9 where ("PO_CODE" = :p10 and "MNYR" = :p11 and "DIST_CODE" = :p12 and "THANA_CODE" = :p13 and "LOAN_CODE" = :p14) Bindings : [184,06/2022,1009,100965,038,326286984,1473,1108,37558000,8606,184,06/2022,1009,100965,038] (SQL: update "PRA_LN_DIST_WISE_DISB" set "PO_CODE" = 184, "MNYR" = 06/2022, "DIST_CODE" = 1009, "THANA_CODE" = 100965, "LOAN_CODE" = 038, "CUM_DISB" = 326286984, "member" = 1473, "BORROWER" = 1108, "LOAN_FY" = 37558000, "CUM_BORR" = 8606 where ("PO_CODE" = 184 and "MNYR" = 06/2022 and "DIST_CODE" = 1009 and "THANA_CODE" = 100965 and "LOAN_CODE" = 038))

Now what should I do?

ADyson
  • 57,178
  • 14
  • 51
  • 63
  • presumably then your dataase table doesn't have a column called "member". Have you checked the database? Maybe there's a difference between the live environment and wherever you tested this. – ADyson Aug 31 '22 at 12:21
  • Does this answer your question? [ORA-00904: invalid identifier](https://stackoverflow.com/questions/6027961/ora-00904-invalid-identifier) – ADyson Aug 31 '22 at 12:21
  • 2
    Laravel seems to be converting the array keys to quoted uppercase column names; but for some reason not for `member` - not sure if that's because it's a keyword. Does it work if you make it `'MEMBER'` in the array assignment? – Alex Poole Aug 31 '22 at 12:41
  • @ADyson "member" column is exist. i add table structure above. please see this. – MD Shoaib Hossain Sep 01 '22 at 04:34
  • @AlexPoole I change 'member' to 'MEMBER'. But it does not work. – MD Shoaib Hossain Sep 01 '22 at 04:35

1 Answers1

0

hope this helps Why do I have ORA-00904 even when the column is present?

TL:DR Oracle database queries, if enclosed with double-quotes becomes case-sensitive. Please check the database and make sure your member column is spelled and cased correctly.