I was going to suggest something similar Greg's recommendation but it seems to me Duane wants to skip FTP which I'm assuming the data transfer to IBM I tool does use to take pc .txt files to the IBM's(IFS in QSYS.LIB). Seems like he wants to use SQL to extract data directly out of a text file on a PC or windows network. But I think Buc explain to be able to use SQL the data must reside in a relational database management system like DB2, MYSQL, SQL Server, etc. As far as I'm aware of you can't directly use SQL on text files without being in a RDMS.
I would think you have to use FTP to get the text file to the IBM I's RDMS which could be automated or you can use RDi to manually copy text files from your PC by browsing Remote System Explorer and then paste files into the IFS by also using RDi to browse to the correct path but then you'll probably have to still use something CPYFRMIMPF.
I'm guessing this doesn't help because I'm confused now but hope someone else shares a good solution.
-----Original Message-----
From: WDSCI-L [mailto:wdsci-l-bounces@xxxxxxxxxxxx] On Behalf Of Duane Scott
Sent: Tuesday, August 30, 2016 2:16 PM
To: Rational Developer for IBM i / Websphere Development Studio Client for System i & iSeries
Subject: Re: [WDSCI-L] Making the most, or over-thinking it - SQL for uploads
Greg,
You are probably correct in this being overkill. I tend to do that, especially in the beginning of learning how to do something.
However, using your method is a bit of overkill too, if seen in the light of having to deal with all the data from a file for which only a small portion is desired. And, it's again, then a two-step process where it might not be otherwise had SQL been able to open and read a PC based .txt file.
I use CPYFRMIMPF in many programs that are part of our nightly routines. And being a long-time program, it's welcome in many situations.
duane
-----Original Message-----
From: WDSCI-L [mailto:wdsci-l-bounces@xxxxxxxxxxxx] On Behalf Of Greg Wilburn
Sent: Tuesday, August 30, 2016 1:24 PM
To: Rational Developer for IBM i / Websphere Development Studio Client for System i & iSeries <wdsci-l@xxxxxxxxxxxx>
Subject: Re: [WDSCI-L] Making the most, or over-thinking it - SQL for uploads
IMHO this is overkill... If I understand what Duane is really asking for, we do this all day long.
If the file is text-delimited (tab, comma, etc.) I often use CPYFRMIMPF.
1. Save the text file on IFS (usually brought to our system via FTP 2. CPYFRMIMPF to a database file
We use this so much that I've written a program that I can call and pass the file extension, path, database file, delimiter, etc. It reads the entire folder and copies each text file with the given extension using CPYFRMIMPF, then (when successful) moves the file to a "history" folder.
The other method I use is a service pgm from Scott Klement called CSVR4. This helps you read the delimited file from the IFS directly in RPG - field by field, row by row (even though it's one long string). This is helpful when each "row" may not be the same.
The CPYFRMIMPF is usually my preferred method. I would be glad to share my code.
Greg
-----Original Message-----
From: WDSCI-L [mailto:wdsci-l-bounces@xxxxxxxxxxxx] On Behalf Of Vernon Hamberg
Sent: Tuesday, August 30, 2016 12:14 PM
To: Rational Developer for IBM i / Websphere Development Studio Client for System i & iSeries <wdsci-l@xxxxxxxxxxxx>
Subject: Re: [WDSCI-L] Making the most, or over-thinking it - SQL for uploads
LOL
Duane - it's not due to any lack on your part - as Buck is sayin, text files are unstructured things.
Now if you have SQL Server, or MySQL, it is probably possible to have a link or some such that can pull stuff out of the text fiel - assuming it is either delimited or fixed-length data.
This just doesn't feel "convenient"! Have the text file saved or otherwise delivered to an IFS directory and have a regular job that imports it to a holding file, then run SQL on the i that does does the WHERE stuff for you.
Easy? Yep! At least IMHO
Vern
On 8/30/2016 11:03 AM, Duane Scott wrote:
Thanks for the responses.
Vern - Not necessarily a one-time task as importing data from PC to DB2 is done constantly, and there are many ways to do so. However, using SQL is my FIRST thought over most of the tools that we have access to, simply because of its convenience. At least perceived convenience. As to the method that I used to get the data this time, I used Access Client Solutions Data Transfer. But doing so forced me to load the entire record to a DB2 data file from which I used interactive SQL from an IBM i ACS emulation session to INSERT my selected fields. Note: my first transfer using ACS was not exactly easy until I figured out how different it was from the old Client Access. But I endured and achieved the success I needed to "get 'er done".
Buck - I figured as much since I couldn't find much in the way of assistance through Google or WDSCI-L. But I wasn't sure I had used the correct terminology in my search. I am fairly certain that I have access to MySQL or SQL server, because I've toyed with it on non-IBM i projects. Very briefly. And the files I used were already structured for use with the access. But I'm not familiar with setting up the PC to interact. Thus the request for a primer, which was basically a shot in the dark. I think I understand what you are saying about it being a part of a MySQL schema already set up, which it is not.
I really just figured that I could access text files similar to accessing them as done on IBM i. I also figured that it was my own lack of experience and knowledge of setting up the PC that caused the inability to just find the file and open it up.
duane
-----Original Message-----
From: WDSCI-L [mailto:wdsci-l-bounces@xxxxxxxxxxxx] On Behalf Of Buck
Calabro
Sent: Tuesday, August 30, 2016 11:40 AM
To: wdsci-l@xxxxxxxxxxxx
Subject: Re: [WDSCI-L] Making the most, or over-thinking it - SQL for
uploads
On 8/30/2016 11:15 AM, Duane Scott wrote:
I can access my DB2 files on the IBM I and display data, but haven't figured out the set up to access text files on a PC (using SQL).
Generally speaking, you can't.
Think of SQL as a client-server relationship.
There's a client, which accepts SQL statements like SELECT COLUMN FROM TABLE, and there's a server which the client connects to, and acts upon that statement.
On a typical Windows PC, there's no server to handle the SQL statement.
So if you're talking about a regular .txt file which you can edit with Notepad, you aren't going to use SQL to do anything with it.
On the other hand, if you have DB2 or MySQL or SQL Server loaded and running on that PC, and the file is part of a schema inside the database, you can connect to it if you have the appropriate JDBC driver.
What's the setup on the PC?
--
--buck
Visit wiki.midrange.com and register for an account. Edit a page that helps you, and because it's public, you'll help someone else, too!
--
This is the Rational Developer for IBM i / Websphere Development
Studio Client for System i & iSeries (WDSCI-L) mailing list To post a
message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: http://lists.midrange.com/mailman/listinfo/wdsci-l
or email: WDSCI-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/wdsci-l.
________________________________
________________________________
CONFIDENTIALITY NOTICE: This electronic message transmission is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. If you have received this transmission, but are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this information is strictly prohibited. If you have received this e-mail in error, please contact NALC Health Benefit Plan at 703-729-4677 and delete and destroy the original message and all copies.
--
This is the Rational Developer for IBM i / Websphere Development Studio Client for System i & iSeries (WDSCI-L) mailing list To post a message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/wdsci-l
or email: WDSCI-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/wdsci-l.
--
This is the Rational Developer for IBM i / Websphere Development Studio Client for System i & iSeries (WDSCI-L) mailing list To post a message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/wdsci-l
or email: WDSCI-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/wdsci-l.
________________________________
________________________________
CONFIDENTIALITY NOTICE: This electronic message transmission is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. If you have received this transmission, but are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this information is strictly prohibited. If you have received this e-mail in error, please contact NALC Health Benefit Plan at 703-729-4677 and delete and destroy the original message and all copies.
--
This is the Rational Developer for IBM i / Websphere Development Studio Client for System i & iSeries (WDSCI-L) mailing list To post a message email: WDSCI-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/wdsci-l
or email: WDSCI-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/wdsci-l.
As an Amazon Associate we earn from qualifying purchases.