in reply to Re: Dynamic query generation
in thread Dynamic query generation
Is it possible to build the query using the above code or is there any other better approach.%ORA_MAPPING = ( 'Data_id' => 'Ticket_Data_seq.nextval', 'Action' => "Problem Submit", 'Cust_Ticket_Number' => "", 'Our_Ticket_Number' => "$data->{'TicketNumber'}", 'msg_id' => "", 'time_stamp' => "", 'Description' => "", 'EL_Edesc' => "", 'prov_id' => "EECO::UTN::BPL", 'provclientid' => "BPC::123", 'prov_client_org' => "", 'prov_client_buz' => "", 'prov_schema_type' => "" ); my $query = "INSERT INTO Ticket_Data ("; if ($action eq 'Problem Submit') for $key ( keys %ORA_MAPPING ) { $value = $ORA_MAPPING{$key}; next if $key eq "Data_id"; $query .=" $key, "; } $query .= " ) VALUES ($ORA_MAPPING{$_} )"; } elsif ($action eq 'Update') { ... }
|
|---|