473,385 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Host Variable, SELECT INTO


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
3 6791
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
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
Thank you, problem solved.

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris | last post by:
I have tableA, defined as: field1 varchar2(10), field2 varchar2(10), field3 varchar2(10) I have host variables defined as: v1 pic x(10) varying v2 pic x(10) varying
4
by: Tim.D | last post by:
People, I've ventured into the wonderful world of Stored Procedures. My first experience has been relatively successful however I am stuck on using host variables to specifiy actualy table or...
2
by: Jeff | last post by:
I have an ASP.NET web page accessing a SQL database. I've used VS to build the app and stored it in the eNPTest02 directory of my localhost on my development machine. The database is on the web. ...
4
by: 4.spam | last post by:
Hello. UDB DB2 v8.2.1 for LUW. Why this function can't be compiled? --- CREATE FUNCTION MYLIKE(NM VARCHAR(128)) LANGUAGE SQL RETURNS INTEGER BEGIN ATOMIC RETURN
2
by: Frank Swarbrick | last post by:
I'm just learning about embedded SQL, so be gentle... My basic question is, if I use a fixed length host variable for a column defined as VARCHAR, will trailing spaces be removed (or not) upon...
5
by: Patrick | last post by:
Hi all, In my SQL procedures in DB2 8.2, I current declare several cursors that return select statements with 10 columns in it. As a result, assigning host variables becomes a coding mess, as...
1
by: young | last post by:
Hello all, I tried to do a sqc program with a "SELECT column INTO :host_variable FROM table" statement and got an error SQL4942N="The statement selects an incompatible data type into host...
0
by: rsilvers | last post by:
what type of overhead will this select statement cause to db2 on z/os mainframe ? This is an imbedded SQL in COBOL Declare cursor C1 for select number, key1, key2 from table where type =...
0
by: msmithuk | last post by:
Hi, Can anyone help on why I am getting this SQL Pre processor error. This is a function that receives a pointer to pre-allocated storage. However I think DB2 is complaining because my host...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.