By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,564 Members | 810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,564 IT Pros & Developers. It's quick & easy.

Host Variable, SELECT INTO

P: n/a

Does the term 'host variable' cover a variable locally declared in a
SQL-PL stored procedure? [ I think SQL PL doesn't qualify as a 'host
language' in the sense of embedded sql. ]

I am asking this question in the context of the SELECT INTO statement.

Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The description of FETCH INTO also uses the term 'host variable', and
in the samples that come with DB2 I found

-- SQL-PL declarations for local variables, 'host variables':
DECLARE v_dept CHAR(3);
DECLARE v_deptname VARCHAR(29);
DECLARE v_admdept CHAR(3);

-- declare c1:
-- ...

-- use c1:
OPEN c1;
FETCH c1 INTO v_dept, v_deptname, v_admdept;

Therefore, SQL-PL-variables should qualify as 'host variables'. Also in
SELECT INTO. Right?

Nov 12 '05 #2

P: n/a
cl*********@abraxas.ch wrote:
Does the term 'host variable' cover a variable locally declared in a
SQL-PL stored procedure? [ I think SQL PL doesn't qualify as a 'host
language' in the sense of embedded sql. ]

I am asking this question in the context of the SELECT INTO statement.

Yes.. There is a general statement in "Identifiers" where SQL Variables
are defined:

"SQL-variable-name
The name of a local variable in an SQL procedure statement.
:=> SQL variable names can be used in other SQL statements where
:=> a host variable name is allowed.
The name can be qualified by the label of the compound statement that
declared the SQL variable."

Important not eon SELECT INTO and VALUES INTO:
These statements are allowed in SQL Procedures (SQL PL) but not in
Triggers and SQL Functions (inline SQL PL). For the later use the
(multicolumn) SET statement.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3

P: n/a
Thank you, problem solved.

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.