I'm supposed to show someone how to use Run Sql Scripts this afternoon
to replace a process where they run a command that creates a file and
they then pull that into excel. I can run the query without any issues
if I put the date range in the where clause, but I want this to be at
least easier than the command is. I'm trying to set some variables at
the top of the script so that they don't have to go down and change the
values in the where clause every time. We are at V7R1 TR11. So far
nothing I've tried works, and I can't find any good examples of how to
do this anywhere. If I just declare and set the variable in the script,
when it gets down to the where cause it says that it can't find it. If I
put a begin/end around the script, it gives me invalid token errors. My
google-fu is failing me today and I can't seem to find what I'm missing.
Ugly 10 year old sql script follows. If I wrap it with a begin/end, I
get an invalid token ':' error.
-- CHGAPPFILE by period.
SET SCHEMA = mpms04;
SET PATH = *LIBL;
CREATE OR REPLACE VARIABLE @STARTPERIOD INTEGER DEFAULT 201701;
CREATE OR REPLACE VARIABLE @ENDPERIOD INTEGER DEFAULT 201702;
SELECT HCPTNO AS ACCOUNT,
PTCHRT AS CHART,
TRIM(PTPLN) CONCAT ', ' CONCAT TRIM(PTPFN) AS NAME,
COALESCE(PPPADR, PTGADR) AS ADDRESS,
COALESCE(PPPCTY, PTGCTY) AS CITY,
COALESCE(PPPST, PTGST) AS STATE,
SUBSTR(CHAR(COALESCE(PPPZIP, PTGZIP)), 1, 5) AS
ZIP_CODE,
This mailing list archive is Copyright 1997-2025 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.