Sponsored Content
Top Forums Shell Programming and Scripting Script to ingest a csv, validate data and insert into Oracle Post 302955943 by jim mcnamara on Wednesday 23rd of September 2015 11:43:51 PM
Old 09-24-2015
This transcends "a few unix commands."


The only place where a simple command might work is to use oracle sqlldr, which requires a prewritten .ctl file to do the work of inserting.

Validation is generally not simple at all. Validating file names requires - usually - regular expressions. Validating data types can also be tricky - everyday users can 'out-stupid' most coding attempts to correct input - getting good results requires lots of work.

Please post the code you have tried so far.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

unix script to export data from csv file to oracle database

Hello people, Need favour. The problem I have is that, I need to develop a unix shell script that performs recurring exports of data from a csv file to an oracle database. Basically, the csv file contains just the first name and last name will be dumped to an Unix server. The data from these... (3 Replies)
Discussion started by: vinayagan
3 Replies

2. Shell Programming and Scripting

Validate Variables insert from user

Hi Can you help me validate 2 variables?The first is an input date from the user and should be like this (yyyy-mm-dd). The second variable is an input time from the user and should be like this(hh:mm).When the input is wrong i want to give the chance to the user to insert again the date or time... (8 Replies)
Discussion started by: DDoS
8 Replies

3. Shell Programming and Scripting

shell script - insert oracle

Hi Frnds, in shell script I have one problem while inserting into oracle table . my script #! /usr/bin/sh while read record do echo $record X=`sqlplus -s STN/errrmddb20@MAHFDR <<eof insert into STN.STN_ERROR_TABLE values($record); eof`... (12 Replies)
Discussion started by: Gopal_Engg
12 Replies

4. Shell Programming and Scripting

select data from oracle table and save the output as csv file

Hi I need to execute a select statement in a solaris environment with oracle database. The select statement returns number of rows of data. I need the data to be inserted into a CSV file with proper format. For that we normally use "You have to select all your columns as one big string,... (2 Replies)
Discussion started by: rdhanek
2 Replies

5. Shell Programming and Scripting

insert data into specific lines of a CSV

So I work in a 1 to 1 laptop deployment and sometimes we need to mass order parts. The vendor will send us a text file and we have to manually input serial numbers. Well I have a full blown web based inventory system which I can pull serial number reports from. I then have to input the part... (4 Replies)
Discussion started by: tlarkin
4 Replies

6. Shell Programming and Scripting

Korn shell program to parse CSV text file and insert values into Oracle database

Enclosed is comma separated text file. I need to write a korn shell program that will parse the text file and insert the values into Oracle database. I need to write the korn shell program on Red Hat Enterprise Linux server. Oracle database is 10g. (15 Replies)
Discussion started by: shellguy
15 Replies

7. Shell Programming and Scripting

Insert script result into Oracle Table

Hi All, I want to insert STAT and ENDTIME values for each job in joblist into TBL_DAILY_STATUS table. Eg: insert into tbl_daily_status values(STAT,ENDTIME); Please help me on this. #!/bin/ksh joblist="com_abc_job com_abc_dot_job com_abc_seq com_abc_det" for i in $joblist do... (8 Replies)
Discussion started by: vichuelaa
8 Replies

8. Shell Programming and Scripting

Need a ready Shell script to validate a high volume data file

Hi, I am looking for a ready shell script that can help in loading and validating a high volume (around 4 GB) .Dat file . The data in the file has to be validated at each of its column, like the data constraint on each of the data type on each of its 60 columns and also a few other constraints... (2 Replies)
Discussion started by: Guruprasad
2 Replies

9. UNIX for Beginners Questions & Answers

Help on Oracle insert from shell script

Hi All I am trying to create a shell script to insert in to oracle table so far insert happens with out an issue, but i cant pass message variable to sqlplus script insert. i have highlighted the variable in red. Please help. thanks in advance. #!/bin/sh df -H | grep -vE... (3 Replies)
Discussion started by: LPK
3 Replies

10. Shell Programming and Scripting

Script to validate header in a csv file

Hi All; I am struggling to write a script that validates file header. Header file would be like below with TAB separated TRX # TYPE REF # Source Piece Code Destination Piece Code every time I need to check the txt file if the header was same as above fields if validation success... (6 Replies)
Discussion started by: heye18
6 Replies
PROP_INGEST(3)						   BSD Library Functions Manual 					    PROP_INGEST(3)

NAME
prop_ingest_context_alloc, prop_ingest_context_free, prop_ingest_context_error, prop_ingest_context_type, prop_ingest_context_key, prop_ingest_context_private, prop_dictionary_ingest -- Ingest a dictionary into an arbitrary binary format SYNOPSIS
#include <prop/proplib.h> prop_ingest_context_t prop_ingest_context_alloc(void *private); void prop_ingest_context_free(prop_ingest_context_t ctx); prop_ingest_error_t prop_ingest_context_error(prop_ingest_context_t ctx); prop_type_t prop_ingest_context_type(prop_ingest_context_t ctx); const char * prop_ingest_context_key(prop_ingest_context_t ctx); void * prop_ingest_context_private(prop_ingest_context_t ctx); bool prop_dictionary_ingest(prop_dictionary_t dict, const prop_ingest_table_entry rules[], prop_ingest_context_t ctx); typedef bool (*prop_ingest_handler_t)(prop_ingest_context_t, prop_object_t); DESCRIPTION
The prop_dictionary_ingest function provides a convenient way to convert a property list into an arbitrary binary format or to extract values from dictionaries in a way that is convenient to an application (for configuration files, for example). prop_dictionary_ingest is driven by a table of rules provided by the application. Each rule consists of three items: o A C string containing a key to be looked up in the dictionary. o The expected property type of the object associated with the key (or PROP_TYPE_UNKNOWN to specify that any type is allowed). o A callback function of type prop_ingest_handler_t that will perform the translation for the application. The table is constructed using a series of macros as follows: static const prop_ingest_table_entry ingest_rules[] = { PROP_INGEST("file-name", PROP_TYPE_STRING, ingest_filename), PROP_INGEST("count", PROP_TYPE_NUMBER, ingest_count), PROP_INGEST_OPTIONAL("required", PROP_TYPE_BOOL, ingest_required), PROP_INGEST_OPTIONAL("extra", PROP_TYPE_UNKNOWN, ingest_extra), PROP_INGEST_END }; The PROP_INGEST macro specifies that the key is required to be present in the dictionary. The PROP_INGEST_OPTIONAL macro specifies that the presence of the key in the dictionary is optional. The PROP_INGEST_END macro marks the end of the rules table. In each case, prop_dictionary_ingest looks up the rule's key in the dictionary. If an object is present in the dictionary at that key, its type is checked against the type specified in the rule. A type specification of PROP_TYPE_UNKNOWN allows the object to be of any type. If the object does not exist and the rule is not marked as optional, then an error is returned. Otherwise, the handler specified in the rule is invoked with the ingest context and the object (or NULL if the key does not exist in the dictionary). The handler should return false if the value of the object is invalid to indicate failure and true otherwise. The ingest context contains several pieces of information that are useful during the ingest process. The context also provides specific error information should the ingest fail. prop_ingest_context_alloc(void *private) Allocate an ingest context. The argument private may be used to pass application-specific context to the ingest handlers. Note that an ingest context can be re-used to perform multiple ingests. Returns NULL on failure. prop_ingest_context_free(prop_ingest_context_t ctx) Free an ingest context. prop_ingest_context_error(prop_ingest_context_t ctx) Returns the code indicating the error encountered during ingest. The following error codes are defined: PROP_INGEST_ERROR_NO_ERROR No error was encountered during ingest. PROP_INGEST_ERROR_NO_KEY A non-optional key was not found in the dictionary. PROP_INGEST_ERROR_WRONG_TYPE An object in the dictionary was not the same type specified in the rules. PROP_INGEST_ERROR_HANDLER_FAILED An object's handler returned false. prop_ingest_context_type(prop_ingest_context_t ctx) Returns the type of the last object visited during an ingest. When called by an ingest handler, it returns the type of the object currently being processed. prop_ingest_context_key(prop_ingest_context_t ctx) Returns the last dictionary key looked up during an ingest. When called by an ingest handler, it returns the dictionary key corre- sponding to the object currently being processed. prop_ingest_context_private(prop_ingest_context_t ctx) Returns the private data set when the context was allocated with prop_ingest_context_alloc(). SEE ALSO
prop_dictionary(3), proplib(3) HISTORY
The proplib property container object library first appeared in NetBSD 4.0. BSD
January 21, 2008 BSD
All times are GMT -4. The time now is 03:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy