Its only the first compile that fails that is the most difficult with RPG *joke.
but to your original problem, I don't see a way to do that from SQL itself , not even if one wraps a Stored Proc. Could a great IBM Idea though for enhancement in my opinion.
------------------------------
Marius le Roux theIBMiGuy
Owner , IBM i Modernization and Integration Consultant
MLR Consulting
------------------------------
Original Message:
Sent: Tue October 21, 2025 09:23 AM
From: Tim Fathers
Subject: Setting headers and cookies when using IWS with SQL
Many thanks for the reply. Yes, I saw that but as it appears to only support static values, it's not very useful unfortunately. I'd like to avoid going down the RPG route if I can help it.
Tim.
------------------------------
Tim Fathers
Original Message:
Sent: Tue October 21, 2025 09:03 AM
From: Marius le Roux
Subject: Setting headers and cookies when using IWS with SQL
Ok I now follow:
On this link, yes it refers to that its possible :https://www.ibm.com/support/pages/node/6173517/
See on point number (2): 

Its specified in the format of case-insensitive name followed by a colon ':' and its value.
Quote from the help text : HTTP header information: Specify any HTTP headers the resource method will return. Each header must be specified on a separate line. An HTTP header consists of a case-insensitive name followed by a colon ':' and its value.
Though I do not see a way that you can return this based on a runtime value if you do choose the SQL route - this looks static. in RPGLE though, its just a matter of defining the parameter in an array and mapping that during the Service creation.
@Nadir K Amra can perhaps guide or correct my reasoning here.
HTH
------------------------------
Marius le Roux theIBMiGuy
Owner , IBM i Modernization and Integration Consultant
MLR Consulting
Original Message:
Sent: Tue October 21, 2025 05:50 AM
From: Tim Fathers
Subject: Setting headers and cookies when using IWS with SQL
We currently wrap stored procedures with a REST API using an internal framework we wrote years ago, which works very much like the Web Services Server as far as I can tell. One of the shortcomings of our existing framework is that it doesn't pass headers or cookies through and I was wondering if the IWS was able to do that when configured to use an SQL backend. I can see that individual request headers can be passed in but I can't see a way for response headers to be returned. I was also wondering if all request headers can be wrapped and passed in as a JSON structure, without having to specify a parameter for each one.
We wouldn't be calling SQL statements directly - only via a SP or UDF.
Tim
------------------------------
Tim Fathers
Original Message:
Sent: Tue October 21, 2025 05:18 AM
From: Marius le Roux
Subject: Setting headers and cookies when using IWS with SQL
Tim,
Are you "wrapping" a SQL Statment or Stored Procedure through IWS and then calling this service outside?
------------------------------
Marius le Roux theIBMiGuy
Owner , IBM i Modernization and Integration Consultant
MLR Consulting
Original Message:
Sent: Mon October 20, 2025 09:27 AM
From: Tim Fathers
Subject: Setting headers and cookies when using IWS with SQL
Hello all,
Is there a way for SQL functions or stored procedures called via a REST service on the IWS to set headers and cookies? Also, is there a way to wrap all headers into an input parameter?
Many thanks,
Tim.
------------------------------
Tim Fathers
------------------------------