× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I guess I should explain that a little

INSERT INTO File1 SELECT * FROM File2

You just doing a INSERT into a file using a SELECT on another.  You can add
your WHERE statements too.

Michael Schutte
Work 614-492-7419
email  michael_schutte@xxxxxxxxxxxx


                                                                           
             "Jeff Crosby"                                                 
             <jlcrosby@dilgard                                             
             foods.com>                                                 To 
             Sent by:                  "'Midrange Systems Technical        
             midrange-l-bounce         Discussion'"                        
             s@xxxxxxxxxxxx            <midrange-l@xxxxxxxxxxxx>           
                                                                        cc 
                                                                           
             03/17/2006 01:47                                      Subject 
             PM                        SQL file output (newbie)            
                                                                           
                                                                           
             Please respond to                                             
             Midrange Systems                                              
                 Technical                                                 
                Discussion                                                 
             <midrange-l@midra                                             
                 nge.com>                                                  
                                                                           
                                                                           




I need to create an output file with selected records from an input file,
but the records to select depend on a date range from a related file.  This
sounded to me like an ideal thing for SQL.

Looking up online how to do it, I found the SELECT INTO with examples of
creating an output table, so I thought I'd try it:

SELECT * INTO qtemp/ordtlhst FROM dbmstf/ordtlhst WHERE onrcu IN (SELECT
onrcu FROM dbmstf/orhdrhst WHERE shpdtiso >= '2006-03-13' AND shpdtiso <=
'2006-03-17')

That doesn't work, however, because the i5 is expecting a host variable, I
think, after the SELECT INTO.  Must be that different versions of SQL want
different things.

I found, in the archives, this way to do it:

CREATE TABLE qtemp/ordtlhst AS (Select * FROM dbmstf/ordtlhst WHERE onrcu
IN
(SELECT onrcu FROM dbmstf/orhdrhst WHERE shpdtiso >= '2006-03-13' AND
shpdtiso <= '2006-03-17')) WITH DATA

That worked!  Id this the 'proper' SQL statement to do this?  I'm
ultimately
going to be passing the dates in as parms.

Thanks!

--
Jeff Crosby
Dilgard Frozen Foods, Inc.
P.O. Box 13369
Ft. Wayne, IN 46868-3369
260-422-7531

The opinions expressed are my own and not necessarily the opinion of my
company.  Unless I say so.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.