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.

--
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.

Reply via email to