0

Is there a way for an alias to have a name associated with the string name passed?

i.e.

SELECT COUNT(*) as $1 
FROM TABLE orders...

The reason I want something like this is because I am calling this SELECT statement 40 times and am passing different variable values each time. So, I would like for this SELECT statement to display the name of the parameter passed with an actual COUNT.

My script calls counting.sql:

@/D2RQ/counting.sql 'Parameter' 'CLIENT'
@/D2RQ/counting.sql 'Line' 'CLIENT'
@/D2RQ/counting.sql 'Setting' 'CLIENT'
@/D2RQ/counting.sql 'Protocol' 'CLIENT'
.
.
.

Here is my counting.sql:

SELECT COUNT(*) as Total_Number_of_Triples
FROM TABLE(SEM_MATCH(
'{
        ?s rdf:type :&1 .
        ?s ?p ?o
}',SEM_Models('&2'),NULL,
SEM_ALIASES(SEM_ALIAS('','http://DataSource/SEMANTIC#')),NULL));

Alex solved it:

define MY_ALIAS = &1
define MY_MODEL = &2

SELECT COUNT(*) as &MY_ALIAS
FROM TABLE(SEM_MATCH(
'{
        ?s rdf:type :ProcessSpec .
        ?s ?p ?o
}',SEM_Models('&MY_MODEL'),NULL,
SEM_ALIASES(SEM_ALIAS('','http://VISION/DataSource/SEMANTIC_CACHE#')),NULL));

This works

Angelina
  • 2,175
  • 10
  • 42
  • 82

1 Answers1

0

Just select the variable as a literal to echo it back out in the result:

SELECT '$1', COUNT(*) as count
FROM TABLE orders...

This won't affect the calculation of count(*)

Bohemian
  • 412,405
  • 93
  • 575
  • 722