Modifying the structure with code.

Lee Hinde (5/23/14 12:41PM)
Randy Engle (5/23/14 12:57PM)
Lee Hinde (5/23/14 1:14PM)
Randy Engle (5/23/14 4:50PM)
Timothy Penner (5/23/14 11:34PM)
Timothy Penner (5/23/14 11:41PM)
Arnaud de Montard (5/24/14 12:09AM)
Lee Hinde (5/28/14 6:51PM)


Lee Hinde (5/23/14 12:41 PM)

<CA+ePoMyJC-L4P_RS-ES6yDCOudc+sPTWeqkLepTiheL3QR7_uw@...

Thanks! ?I'll take a look.

In my case I don't need the uuid to be a primary key, I have a longint
for
that... I think what I'm wanting is a UUID formated Alpha field.

On Fri, May 23, 2014 at 11:26 AM, Randy Engle <4d.list@... wrote:

color><param>00000,0000,DDEE/param>LLee,

There's something in the docs about this also:

http://doc.4d.com/4D-SQL-Reference-13.4/SQL-Commands/ALTER-TABLE.300-12256
29.en.html

Though I can't say that I've added a UUID field with it.

Randy Engle

/color>

Randy Engle (5/23/14 12:57 PM)

<<!&!AAAAAAAAAAAYAAAAAAAAAHuqyL9BU7RPvZs4aFc5Q6XCgAAAEAAAAN16XVqH8JxLibRYX
tr7oesBAAAAAA==3D@xc2.us>


Lee,

In the docs, it talks about using "ENABLE AUTO_GENERATE" with SQL Code

But I've not been able to figure out how to do it.

It would be great to see and example

Randy Engle

Lee Hinde (5/23/14 1:14 PM)

<CA+ePoMw9+dTj-Cj9AVs_deEPX77ECbFqPTEW3rz+gkFHFutUOw@...

I don't see a way to assign formatting attributes via the alter table
command.

On Fri, May 23, 2014 at 12:57 PM, Randy Engle <4d.list@... wrote:

color><param>00000,0000,DDEE/param>LLee,

In the docs, it talks about using "ENABLE AUTO_GENERATE" with SQL Code

But I've not been able to figure out how to do it.

It would be great to see and example

Randy Engle

/color>

Randy Engle (5/23/14 4:50 PM)

<<!&!AAAAAAAAAAAYAAAAAAAAAHuqyL9BU7RPvZs4aFc5Q6XCgAAAEAAAAFbDFTajVFFNhFGKJ
2FTf/sBAAAAAA==3D@xc2.us>


Arnaud

Many thanks for passing this along!

Randy Engle

color><param>00000,0000,DDEE/param>------Original Message-----
From: 4d_tech-bounces@... [mailto:4d_tech-
bounces@... On Behalf Of Arnaud de Montard
Sent: Friday, May 23, 2014 3:10 PM

Le 23 mai 2014 ?=A0 21:57, Randy Engle a ?=A9crit :

/color><color><param>8826F,0000,8219/param>LLee,

In the docs, it talks about using "ENABLE AUTO_GENERATE" with SQL Code

But I've not been able to figure out how to do it.

It would be great to see and example
/color><color><param>00000,0000,DDEE/param>
for a longint primary key I use this:

CREATE TABLE User
(
user_PK INT32 NOT NULL AUTO_INCREMENT,
name VARCHAR(80),
firstname VARCHAR(80),
PRIMARY KEY (user_PK)
);

so I'd try something like:

CREATE TABLE User
(
user_PK UUID NOT NULL AUTO_GENERATE,
name VARCHAR(80),
firstname VARCHAR(80),
PRIMARY KEY (user_PK)
);

--
Arnaud de Montard
/color>

Timothy Penner (5/23/14 11:34 PM)

Hi Randy,

For UUID formatted Alpha fields:

Here is an example of enabling auto_generate for [Table_1]uid
?=A0?ALTER TABLE Table_1 MODIFY uid ENABLE AUTO_GENERATE;

Here is an example of disabling auto_generate for [Table_1]uid
?=A0?ALTER TABLE Table_1 MODIFY uid DISABLE AUTO_GENERATE;

For Long Integer fields:

Here is an example of enabling auto_increment for [Table_1]id
?=A0ALTER TABLE Table_1 MODIFY id ENABLE AUTO_INCREMENT;

Here is an example of disabling auto_increment for [Table_1]id
?=A0ALTER TABLE Table_1 MODIFY id DISABLE AUTO_INCREMENT;

Kind Regards,

Tim PENNER

-----Original Message-----
From: 4d_tech-bounces@...
[mailto:4d_tech-bounces@... On Behalf Of Randy Engle
Sent: Friday, May 23, 2014 12:58 PM

Lee,

In the docs, it talks about using "ENABLE AUTO_GENERATE" with SQL Code

But I've not been able to figure out how to do it.

It would be great to see and example

Randy Engle

Timothy Penner (5/23/14 11:41 PM)

Hi Lee,

Have a look at:
http://kb.4d.com/assetid=76991

If all you want is a UUID field added, with auto_generate, but not to
be set as primary key I think this would do it:

Begin SQL
?=A0?ALTER TABLE Table_1 ADD myUUID UUID AUTO_GENERATE;
End SQL

The last example from the 76991 tech tip could be modified (remove
'PRIMARY KEY' from $statement_t) then ran to add a UUID field named
myUUID to all tables. Is that what you are looking for?

Hope that helps,

-Tim

-----Original Message-----
From: 4d_tech-bounces@...
[mailto:4d_tech-bounces@... On Behalf Of Lee Hinde
Sent: Friday, May 23, 2014 12:42 PM

In my case I don't need the uuid to be a primary key, I have a longint
for that... I think what I'm wanting is a UUID formated Alpha field.

Arnaud de Montard (5/24/14 12:09 AM)

Le 23 mai 2014 &yacute; 21:57, Randy Engle a &Egrave;crit :

color><param>00000,0000,DDEE/param>LLee,

In the docs, it talks about using "ENABLE AUTO_GENERATE" with SQL Code

But I've not been able to figure out how to do it.

It would be great to see and example
/color>
for a longint primary key I use this:

CREATE TABLE User
(
user_PK INT32 NOT NULL AUTO_INCREMENT,
name VARCHAR(80),
firstname VARCHAR(80),
PRIMARY KEY (user_PK)
);

so I'd try something like:

CREATE TABLE User
(
user_PK UUID NOT NULL AUTO_GENERATE,
name VARCHAR(80),
firstname VARCHAR(80),
PRIMARY KEY (user_PK)
);

--
Arnaud de Montard

Lee Hinde (5/28/14 6:51 PM)

<CA+ePoMy9fo5QK=1jhRUcuqs-mAXW4dCoJUotgtg8Mei18xSp0Q@mail.gmail.com>

I did this and it seems to be working.

What's slightly weird is that after running the code to create the uuid
fields each field was appended to the end of the table in the
structure.
After relaunching the database, the fields appear in different relative
locations. that is, rather than being the last field in the list in the
structure editor, it's the next to last, or some higher position. I'd
guess
that's because I had holes in the field list that were filled, but why
the
field wasn't placed there in the first place....

Right now I'm iterating through the data set to assign real uuids to
the
fields, rather than the phantoms that were initially displayed.

On Mon, May 26, 2014 at 9:36 AM, Lee Hinde <leehinde@... wrote:

color><param>00000,0000,DDEE/param>TThanks!

On Fri, May 23, 2014 at 2:41 PM, Timothy Penner <tpenner@...
wrote:

/color><color><param>8826F,0000,8219/param>HHi Lee,

Have a look at:
http://kb.4d.com/assetid=76991

If all you want is a UUID field added, with auto_generate, but not to
be
set as primary key I think this would do it:

Begin SQL
?=A0?ALTER TABLE Table_1 ADD myUUID UUID AUTO_GENERATE;
End SQL

The last example from the 76991 tech tip could be modified (remove
'PRIMARY KEY' from $statement_t) then ran to add a UUID field named
myUUID
to all tables. Is that what you are looking for?

Hope that helps,

-Tim

-----Original Message-----
From: 4d_tech-bounces@...
[mailto:4d_tech-bounces@...
On Behalf Of Lee Hinde
Sent: Friday, May 23, 2014 12:42 PM

In my case I don't need the uuid to be a primary key, I have a longint
for that... I think what I'm wanting is a UUID formated Alpha field.

/color><color><param>00000,0000,DDEE/param>
/color>

Reply to this message

Summary created 5/29/14 at 6:25AM by Intellex Corporation

Comments welcome at: feedback@intellexcorp.com