ThomasRones
ThomasRones

Reputation: 683

Any way to cast a table with one value as a scalar type? (Integer, String, etc.)

Here is what I would like to do:

declare maxNum integer;    
maxNum = select MAX(rn) from :ColumnList;

The sql statement returns a table with one row/col (one value).

Is there an easy way to assign this value to a scalar variable?

Upvotes: 0

Views: 584

Answers (1)

ThomasRones
ThomasRones

Reputation: 683

The variable will be stored as an integer with this syntax.

declare maxNum integer;    
select MAX(rn) into maxNum from :ColumnList;

Edit: Thanks to Lars Br. for the explanation why this works.

Upvotes: 3

Related Questions