Skip to main content
Question

Use a variable with INLINE QUERY


Forum|alt.badge.img

Hello, I need to use a variable in INLINE QUERIER

This is valid SQL but I can't get it to run in FME. The print is just for testing. I would ultimately use the variable as a concatenation string.

 

DECLARE @ccount as varchar(20)

 

set @ccount = (select top 1(CYCLE) from CYCLE)

 

print @ccount

 

6 replies

dustin
Influencer
Forum|alt.badge.img+30
  • Influencer
  • January 6, 2023

Is there a reason you are wanting to use InlineQuerier for this, instead of perhaps the Sampler to return the 1st record?


david_r
Evangelist
  • January 9, 2023

I suspect you need to use a SELECT statement to return the value of the variable.


Forum|alt.badge.img

Yes, I need to use the value in the variable as a prefix for another column

 

DECLARE @ccount as varchar(20)

 

set @ccount = (select top 1(CYCLE) from CYCLE)

select Asset_ID, @ccount + '-' + formation from TABLE

 

just a simple multi line SQL statement .


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • January 9, 2023
fizquierdo1973 wrote:

Yes, I need to use the value in the variable as a prefix for another column

 

DECLARE @ccount as varchar(20)

 

set @ccount = (select top 1(CYCLE) from CYCLE)

select Asset_ID, @ccount + '-' + formation from TABLE

 

just a simple multi line SQL statement .

The InlineQuerier is based on SQLLite so any SQL needs to be compatible, I don't know anything about variables but select top1 i don't think is valid SQL for SQLLite for a start.

 

Perhaps if you could explain a bit more about what you are trying to do there may be alternatives?


Forum|alt.badge.img
ebygomm wrote:

The InlineQuerier is based on SQLLite so any SQL needs to be compatible, I don't know anything about variables but select top1 i don't think is valid SQL for SQLLite for a start.

 

Perhaps if you could explain a bit more about what you are trying to do there may be alternatives?

I need a single attribute value.. '_2003_date' appended to an attribute in a SQL table. I think the issue is a multiline statement in Inline query.

 

So if I can pass an attribute or scalar value to inline query. I can then use it to concatenate to other columns.

 

for example. this statement in my query works.

 

select Asset_ID, SPUD_DATE, 'test_append' + Type_Curve from AllASSETS.

 

I need the value 'test_append' to be read in and not hard coded.


Forum|alt.badge.img+2
  • January 9, 2023

@fizquierdo1973​ Test you SQL in DB Browser for SQLite. As @ebygomm​ suggests, InlineQuerier is based on SQLite so the SQL must be SQLite compatible. SQLite Tutorial is also a great resource for understanding the nuances of SQLite's SQL.

I don't think SQLite supports declared variables


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings