Do you need double quotes in certain places?
SET VAR vamp_dateCol_min TEXT = ('(MIN('' + .vcol_date + ''))')
Or instead of using literal parens and quotes, do the ASCII codes work in certain places?
(  = (CHAR(40))
)  = (CHAR(41))
'  = (CHAR(39))

SET VAR vamp_dateCol_min TEXT = +
 ('(MIN(+(CHAR(39)) + .vcol_date + (CHAR(39))+))')

I've only skimmed the code and haven't test this; your mileage may vary, past performance does guarantee future results, some assembly required.
Doug

On 12/10/2021 7:08 PM, Bruce Chitiea wrote:
Razzak: Thank you.

If I understand your sample, my code should read:

  SET VAR vcol_date TEXT = 'cpoDate'
  SET VAR vtableName TEXT = 'cpoHeader'
  SET VAR vamp_dateCol_min TEXT = ('(MIN(' + .vcol_date + '))')
  SET VAR vamp_dateCol_iyr4 TEXT = ('(IYR4(' + .vcol_date + '))')

  SET VAR vstring TEXT = +
  ('SELECT *&vamp_dateCol_min* INTO vfts_dateStart INDICATOR vind1 FROM' & *.vtableName* & 'WHERE *&vamp_dateCol_iyr4* = .vyearStart')

  &vstring

...which returns the error: "Column or variable MIN not found (2515)"

Perplexing.  But! Progress. By defining the "vamp_" variables in your correct syntax (as shown and run above), this code now works:

  SELECT *&vamp_dateCol_min* INTO vfts_dateStart INDICATOR vind1  +
    FROM *&vtableName* WHERE *&vamp_dateCol_iyr4* = .vyearStart

Sadly, if I insert this code into parens as the vstring definition, the error: "Syntax is incorrect for the command SELECT (2045)" is returned.

So, still one level of mystery remains.

Best wishes, Bruce

Bruce A. Chitiea | SafeSectors, Inc.
112 Harvard Ave #272 | Claremont CA 91711-4716 | USA
/rby...@safesectors.com/ | +011 (909) 238-9012 c | +011 (909) 912-8678 f

------ Original Message ------
From: "A. Razzak Memon" <raz...@rbase.com>
To: rbase-l@googlegroups.com
Sent: 12/10/2021 1:41:19 PM
Subject: Re: [RBASE-L] - Ampersanding in the Dark

Bruce,
Try this very simple approach to form a command with correct syntax to execute.
SET VAR vTableName TEXT = 'cPOHeader'
SET VAR vString TEXT = ('SELECT ... FROM'&.vTableName)
&vString
See how the variable "vString" is executed.
Have fun!
Razzak
At 04:21 PM 12/10/2021, Bruce Chitiea wrote:
Gurus and Gurettes:
My greatest coding challenge remains the use of ampersand variables. I get the concept, but my execution ... hoo boy.
So here's what works:
  SELECT (MIN(cpoDate)) INTO vdateStart INDIC vind1 +
   FROM cpoHeader WHERE (IYR4(cpoDate)) = .vyearStart
But I need to sub-out the table name, and column name 'cpoDate' with the likes of 'invDate', 'shipDate', etc.Â
This does the trick for the column name:
  SET VAR vcol_date TEXT = 'cpoDate'
  SET VAR vamp_dateCol_min TEXT = '(MIN(&vcol_date))'
  SET VAR vamp_dateCol_iyr4 TEXT = '(IYR4(&vcol_date))'
  SELECT &vamp_dateCol_min INTO vfts_dateStart INDICATOR vind1 +
   FROM cpoHeader WHERE &vamp_dateCol_iyr4 = .vyearStart
... but only so long as the literal tablename 'cpoHeader' is included in the FROM clause.
This returns a syntax error:
  SET VAR vtableName TEXT = 'cpoHeader'
  SELECT ... FROM .vtableName ...
... as does this:
  SET VAR vtableName TEXT = 'cpoHeader'
  SELECT ... FROM &vtableName ...
... as does this:
  SET VAR vtableName TEXT = 'cpoHeader'
  SET VAR vamp_from_tablename TEXT = 'FROM .vtableName'
  SELECT ... &vamp_from_tableName ...
... as does this
  SET VAR vtableName TEXT = 'cpoHeader'
  SET VAR vamp_from_tablename TEXT = 'FROM &vtableName'
  SELECT ... &vamp_from_tableName ...
Clearly, I'm flailing. Any assistance much appreciated!Â
Bruce
Bruce A. Chitiea |Â SafeSectors, Inc.
112 Harvard Ave #272 |Â Claremont CA 91711-4716 |Â USA
rby...@safesectors.com | +011 (909) 238-9012 c | +011 (909) 912-8678 f
--
For group guidelines, visit <http://www.rbase.com/support/usersgroup_guidelines.php>http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to <mailto:rbase-l+unsubscr...@googlegroups.com>rbase-l+unsubscr...@googlegroups.com. To view this discussion on the web visit <https://groups.google.com/d/msgid/rbase-l/emefc63529-209a-44f7-a4c9-390b1f709fa9%40pathfinder?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/rbase-l/emefc63529-209a-44f7-a4c9-390b1f709fa9%40pathfinder?utm_medium=email&utm_source=footer>>https://groups.google.com/d/msgid/rbase-l/emefc63529-209a-44f7-a4c9-390b1f709fa9%40pathfinder.
-- For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php --- You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to rbase-l+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/1MTisb-1n7aFe3sNR-00U4Df%40mrelay.perfora.net.
--
For group guidelines, visit http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups "RBASE-L" group. To unsubscribe from this group and stop receiving emails from it, send an email to rbase-l+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rbase-l/em69075add-1a16-48d4-8b1b-b0f7e51c4b4c%40pathfinder <https://groups.google.com/d/msgid/rbase-l/em69075add-1a16-48d4-8b1b-b0f7e51c4b4c%40pathfinder?utm_medium=email&utm_source=footer>.


--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- You received this message because you are subscribed to the Google Groups "RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rbase-l+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rbase-l/27ebfd44-3b54-7009-d7d5-ef0340817606%40wi.rr.com.

Reply via email to