Subject | SQL questions |
---|---|
Author | lobolo2000 |
Post date | 2001-06-28T04:55:57Z |
I have just begun programming using interbase SQL, and got several
questions, so please bear with me :o)
1- I have declared a variable in a stored procedure:
DECLARE VARIABLA EOL CHAR(2);
EOL=ASCII_CHAR(10)||ASCII_CHAR(13);
but i keep getting the message: 'Arithmetic exception, numeric overflow, or
string truncation'
Even using EOL=ASCII_CHAR(10); produces the error, which leads me to think
that the problem is with the ASCII_CHAR UDF. What could be wrong?
2- I have 2 tables as follows:
CREATE TABLE CURRENCIES (
ID INTEGER,
CURRENCY_NAME CHAR(30),
PRIMARY KEY(ID));
CREATE TABLE COUNTRIES (
ID INTEGER,
COUNTRY_NAME CHAR(30),
CURRENCY1 INTEGER,
CURRENCY2 INTEGER,
PRIMARY KEY(ID),
FOREIGN KEY (CURRENCY1) REFERENCES CURRENCIES (ID),
FOREIGN KEY (CURRENCY2) REFERENCES CURRENCIES (ID));
What's the correct SQL SELECT statement that will give me a list of
countries with the names of both currencies?
The statement:
SELECT C.COUNTRY_NAME, D.CURRENCY_NAME FROM COUNTRIES C, CURRENCIES D WHERE
C.CURRENCY1=D.ID;
lists the countries with the name of the 1st currency. How to go about
showing both names?
3- The CREATE TABLE statement supports an EXTERNAL FILE option. Is it
possible to set the external file name from a stored procedure at run-time?
4- The INSERT statement supports a SELECT clause such as:
INSERT INTO TABLE1 SELECT COL1 FROM TABLE2 WHERE COL2=0;
The above statement will copy COL1 from TABLE2 to TABLE1 for all rows in
TABLE2 where COL2=0. What's the best way to set COL2 to 1 for these records
(and only these records) which have been copied, noting that in the meantime
other users might be adding records to TABLE2?
TIA
_________________________________________________________
Do You Yahoo!?
Get your free @... address at http://mail.yahoo.com
questions, so please bear with me :o)
1- I have declared a variable in a stored procedure:
DECLARE VARIABLA EOL CHAR(2);
EOL=ASCII_CHAR(10)||ASCII_CHAR(13);
but i keep getting the message: 'Arithmetic exception, numeric overflow, or
string truncation'
Even using EOL=ASCII_CHAR(10); produces the error, which leads me to think
that the problem is with the ASCII_CHAR UDF. What could be wrong?
2- I have 2 tables as follows:
CREATE TABLE CURRENCIES (
ID INTEGER,
CURRENCY_NAME CHAR(30),
PRIMARY KEY(ID));
CREATE TABLE COUNTRIES (
ID INTEGER,
COUNTRY_NAME CHAR(30),
CURRENCY1 INTEGER,
CURRENCY2 INTEGER,
PRIMARY KEY(ID),
FOREIGN KEY (CURRENCY1) REFERENCES CURRENCIES (ID),
FOREIGN KEY (CURRENCY2) REFERENCES CURRENCIES (ID));
What's the correct SQL SELECT statement that will give me a list of
countries with the names of both currencies?
The statement:
SELECT C.COUNTRY_NAME, D.CURRENCY_NAME FROM COUNTRIES C, CURRENCIES D WHERE
C.CURRENCY1=D.ID;
lists the countries with the name of the 1st currency. How to go about
showing both names?
3- The CREATE TABLE statement supports an EXTERNAL FILE option. Is it
possible to set the external file name from a stored procedure at run-time?
4- The INSERT statement supports a SELECT clause such as:
INSERT INTO TABLE1 SELECT COL1 FROM TABLE2 WHERE COL2=0;
The above statement will copy COL1 from TABLE2 to TABLE1 for all rows in
TABLE2 where COL2=0. What's the best way to set COL2 to 1 for these records
(and only these records) which have been copied, noting that in the meantime
other users might be adding records to TABLE2?
TIA
_________________________________________________________
Do You Yahoo!?
Get your free @... address at http://mail.yahoo.com