MySQL Forums
Forum List  »  Stored Procedures

Re: Parse a Text file and store it in a table
Posted by: Mano Publico
Date: March 13, 2016 06:22AM

Here is the scenario I'm considering.

---------------

A) Environment preparation:

a.1) Manually create 2 tables: Table 1 with just one column where each row will contain a line coming from the text file, and Table 2 with as many column as required to store data extracted from Table 1

a.2) The master application (BPM application) will upload the text file into Table 1 (i.e. this is a features that has already been designed in the application), then the application will call some stored routines (to be developed) in order to parse Table 1, extract useful data and store them in Table 2

B) Data extraction routine:

Here is what I think should be the pseudo-code.

FOR each row in Table 1

IF row starts with a specific string (e.g. "Code 1")
THEN keep this string in memory (e.g. Field 1)
THEN extract from the same row another data located at a specific position, keep it in memory (e.g. Field 2)
END IF

IF row starts with a specific string (e.g. "Code 2")
THEN keep this string in memory (e.g. Field 3)
THEN extract from the same row some data located at a specific position, keep them in memory (e.g. Field 4 and Field 5)
THEN insert one row in Table 2 made of Field 1, Field 2, Field 3, Field 4 and Field 5
END IF

END FOR

---------------

Question: How to translate this into MySQL Stored routine language?

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Parse a Text file and store it in a table
1161
March 13, 2016 06:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.