我们可以解析来自第三方的逗号分隔字符串并移动到SQLRPGLE中文件的多个列 假设我们有一个包含MFG,9876,0001,123435到多列的字段Site = MFG,Parent Item = 9876,revision ='',sequence = 0001,component Item = 12345等?
答案 0 :(得分:0)
收到CSV文件后,将其存储在IFS中。然后,使用import android.Manifest;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import java.util.List;
import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.AppSettingsDialog;
import pub.devrel.easypermissions.EasyPermissions;
public class MainActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks {
private static final String TAG = "MainActivity";
private static final String[] LOCATION_AND_CONTACTS =
{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_CONTACTS};
private static final int RC_CAMERA_PERM = 123;
private static final int RC_LOCATION_CONTACTS_PERM = 124;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Button click listener that will request one permission.
findViewById(R.id.button_camera).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cameraTask();
}
});
// Button click listener that will request two permissions.
findViewById(R.id.button_location_and_contacts).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
locationAndContactsTask();
}
});
}
private boolean hasCameraPermission() {
return EasyPermissions.hasPermissions(this, Manifest.permission.CAMERA);
}
private boolean hasLocationAndContactsPermissions() {
return EasyPermissions.hasPermissions(this, LOCATION_AND_CONTACTS);
}
private boolean hasSmsPermission() {
return EasyPermissions.hasPermissions(this, Manifest.permission.READ_SMS);
}
@AfterPermissionGranted(RC_CAMERA_PERM)
public void cameraTask() {
if (hasCameraPermission()) {
// Have permission, do the thing!
Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show();
} else {
// Ask for one permission
EasyPermissions.requestPermissions(
this,
getString(R.string.rationale_camera),
RC_CAMERA_PERM,
Manifest.permission.CAMERA);
}
}
@AfterPermissionGranted(RC_LOCATION_CONTACTS_PERM)
public void locationAndContactsTask() {
if (hasLocationAndContactsPermissions()) {
// Have permissions, do the thing!
Toast.makeText(this, "TODO: Location and Contacts things", Toast.LENGTH_LONG).show();
} else {
// Ask for both permissions
EasyPermissions.requestPermissions(
this,
getString(R.string.rationale_location_contacts),
RC_LOCATION_CONTACTS_PERM,
LOCATION_AND_CONTACTS);
}
}
@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
// EasyPermissions handles the request result.
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}
@Override
public void onPermissionsGranted(int requestCode, List<String> perms) {
Log.d(TAG, "onPermissionsGranted:" + requestCode + ":" + perms.size());
}
@Override
public void onPermissionsDenied(int requestCode, List<String> perms) {
Log.d(TAG, "onPermissionsDenied:" + requestCode + ":" + perms.size());
// (Optional) Check whether the user denied any permissions and checked "NEVER ASK AGAIN."
// This will display a dialog directing them to enable the permission in app settings.
if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
new AppSettingsDialog.Builder(this).build().show();
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == AppSettingsDialog.DEFAULT_SETTINGS_REQ_CODE) {
String yes = getString(R.string.yes);
String no = getString(R.string.no);
// Do something after user returned from app settings screen, like showing a Toast.
Toast.makeText(
this,
getString(R.string.returned_from_app_settings_to_activity,
hasCameraPermission() ? yes : no,
hasLocationAndContactsPermissions() ? yes : no,
hasSmsPermission() ? yes : no),
Toast.LENGTH_LONG)
.show();
}
}
}
命令将文件加载到数据库文件中是一个简单的操作。
答案 1 :(得分:-3)
使用SQL将CSV插入表中。 创建字符串并立即执行。
mstring = 'insert into mytable (col1, col2 , col3) values (' + mydata + ')';
exec immediate :mystring;