Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DEFINE DEFAULT VALUE IN sql/4gl STATEMENT 1

Status
Not open for further replies.

ziguy

Programmer
May 13, 2004
4
FR
Hello,

I really need to know how to use a default value in a sql/4gl statement. With dbaccess I can do:

CREATE TABLE table_name (
Col1 smallint NOT NULL DEFAULT 10 ,
Col2 char(10) );

But when in a 4gl prog. the compiler crash and say error 4373 like this :

Col1 smallint NOT NULL DEFAULT 10
---------------------------------^
error 4373 ....

Is there a solution to use DEFAULT in sql\4gl statement.


Thank you very much !!
 
CREATE TABLE table_name
(
col1 SMALLINT DEFAULT 10 NOT NULL,
col2 CHAR(10)
);
 
Thank you for your reply but it doesn't work .

this my 4gl prog:

DATABASE mercure
MAIN
DEFINE TOTO SMALLINT
LET TOTO = 0
CREATE TEMP TABLE nico3
(
COL1 SMALLINT DEFAULT 10 NOT NULL ,
COL2 CHAR(10)
)

but I've got the same probleme when compiling :
CREATE TEMP TABLE nico3 (
COL1 SMALLINT DEFAULT 10 NOT NULL )
|_______________________^
|
| A grammatical error has been found on line 8, character 25.
| The construct is not understandable in its context.
| See error number -4373.


could you help me more please ?




 
Hi ziguy,

I think there is a bug in the 4GL compiler for the DEFAULT keyword specification. I found out a workaround as below:

DATABASE mercure
MAIN

DEFINE TOTO SMALLINT, cmd CHAR(900)
LET TOTO = 0
LET cmd=
"CREATE TEMP TABLE nico3 ",
"( ",
"col1 SMALLINT DEFAULT 10 NOT NULL , ",
"col2 CHAR(10) ",
") "
PREPARE id1 FROM cmd
EXECUTE id1

INSERT INTO nico3 VALUES (5,7);
INSERT INTO nico3 VALUES (15,17);
INSERT INTO nico3 (col2) VALUES (666);

UNLOAD TO 'x.x' select * FROM nico3

END MAIN

Regards,
Shriyan
 
Thank a lot for your help. Effectivly, it's work going like that. I can't understand why it wasn't working initialy ... but here compiler are really special with patch and patch of patch .. etc ...

whatever thank !!! I give you the star of the week !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top