on 12-12-2016 6:53 PM
Hi,
I want to know if we can pass multiple aggregation functions values to variables in a single SELECT statement.
Here's a sample code on a test table, similar to the actual code that fails with the same error,
insert into <table> values(11,'lox');
insert into <table> values(12,'pox');
insert into <table> values(13,'sox');
DO (OUT mini INT => ?, OUT maxi INT => ?)
BEGIN
Select MIN("id") into mini, MAX("id") into maxi from "PUBLIC"."HEADERTAB";
END
Error: Could not execute 'DO (OUT mini INT => ?, OUT maxi INT => ?) BEGIN Select MIN("id") into mini, MAX("id") into maxi ...' in 3 ms 688 µs . SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near "(": line 3 col 30 (at pos 81)
But the below statement works:
Select MIN("id") as "mini", MAX("id") as "maxi" from "PUBLIC"."HEADERTAB"
I am doing this in a procedure and trying to pass the minimum and maximum values into a variable. Right now I am doing at two separate SELECTs.
Thank You,
Benedict
You have to use just one "into" clause.
SELECT min("id"), max("id") INTO mini, maxi from "PUBLIC"."HEADERTAB";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.