Re: Version hell on Mac

2016-10-06 Thread Charles Miller
On Tue, Oct 4, 2016 at 10:52 AM, Peter Jakobsson 
wrote:

> C_LONGINT($i;$P_SIZE)
> C_TEXT($tableName_t)
>
> $fieldName:="pkUUID"
>
> $P_SIZE:=Get last table number
>
> For ($i;1;$P_SIZE)
> If (Is table number valid($i))
>
> $tableName_t:=Table name($i)
> $statement_t:="ALTER TABLE ["+$tableName_t+"] ADD "+$fieldName+" UUID
> AUTO_GENERATE PRIMARY KEY;"
>
> Begin SQL
> EXECUTE IMMEDIATE:$statement_t;
> End SQL
>
> End if
> End for
>

No this is not enough, you need to check to make sure that the table in
question does not have a primary key already. This code will do that.
For ($TableNumber_L;1;Get last table number)
If (Is table number valid($TableNumber_L))
Begin SQL

SELECT CONSTRAINT_ID
FROM _USER_CONSTRAINTS
WHERE TABLE_ID = :$TableNumber_L AND CONSTRAINT_TYPE = 'P'
INTO :$ConstraintID_txt;

SELECT COLUMN_ID
FROM _USER_CONS_COLUMNS
WHERE CONSTRAINT_ID = :$ConstraintID_txt
INTO :$Primary_key_field_id_L;
End SQL
End if
If ($Primary_key_field_id_L#0)
$tableName_t:=Table name($i)
$statement_t:="ALTER TABLE ["+$tableName_t+"] ADD "+$fieldName+" UUID
AUTO_GENERATE PRIMARY KEY;"

Begin SQL
EXECUTE IMMEDIATE:$statement_t;
End SQL

end if
end for
Also you should do this with an empty data file and then when you open a
real data file, the UUID fields will be populated  and validated

You also need to set index to true
The code I used created a document with alter commands etc


  //
  //User name (OS): administrator
  //Date and time: 09/01/15, 13:29:23
  //
  //Method: ut_CreatePrimaryKeyDoc
  //Description
  //
  // Parameters
  // 
If (False)
Mods_2015_08_bug   //
  //Modified by: administrator (9/1/15 13:29:25)

End if
C_LONGINT($Primary_key_field_id_L)
C_TEXT($TableName_txt;$KeyName_txt)
C_TEXT($OUTPUT_txt;$Output1_txt)

C_TEXT($ConstraintID_txt)
C_LONGINT($TableNumber_L)
For ($TableNumber_L;1;Get last table number)
If (Is table number valid($TableNumber_L))
Begin SQL

SELECT CONSTRAINT_ID
FROM _USER_CONSTRAINTS
WHERE TABLE_ID = :$TableNumber_L AND CONSTRAINT_TYPE = 'P'
INTO :$ConstraintID_txt;

SELECT COLUMN_ID
FROM _USER_CONS_COLUMNS
WHERE CONSTRAINT_ID = :$ConstraintID_txt
INTO :$Primary_key_field_id_L;
End SQL
End if
If ($Primary_key_field_id_L#0)
ALERT("Table named "+Table name($TableNumber_L)+" has a primary key named
"+Field name($TableNumber_L;$Primary_key_field_id_L))
Else
$TableName_txt:=Table name($TableNumber_L)
$KeyName_txt:=Substring($TableName_txt;1;21)+"_UUIDKey_s"
$KeyName_txt:=replace string($KeyName_txt;" ";"_";)
$OUTPUT_txt:=$OUTPUT_txt+"Begin SQL"+Char(Carriage return)+"ALTER TABLE
["+$TableName_txt+"] ADD "+$KeyName_txt+" UUID AUTO_GENERATE PRIMARY
KEY;"+Char(Carriage return)+"End SQL"+Char(Carriage return)
$Output1_txt:=$Output1_txt+"EXECUTE FORMULA("+Char(Double quote)+"SET
INDEX(["+$TableName_txt+"]"+$KeyName_txt+";true)"+Char(Double
quote)+")"+Char(Carriage return)

End if
End for
C_TIME($Doc_tm)
$Doc_tm:=Create document("")
SEND PACKET($Doc_tm;$OUTPUT_txt)
SEND PACKET($Doc_tm;$Output1_txt)

CLOSE DOCUMENT($Doc_tm)

  //End ut_CreatePrimaryKeyDoc

Hope this helps

Chuck
-- 
-
 Chuck Miller Voice: (617) 739-0306 Fax: (617) 232-1064
 Informed Solutions, Inc.
 Brookline, MA 02446 USA Registered 4D Developer
   Providers of 4D, Sybase & SQL Sever connectivity
  http://www.informed-solutions.com
-
This message and any attached documents contain information which may be
confidential, subject to privilege or exempt from disclosure under
applicable law.  These materials are intended only for the use of the
intended recipient. If you are not the intended recipient of this
transmission, you are hereby notified that any distribution, disclosure,
printing, copying, storage, modification or the taking of any action in
reliance upon this transmission is strictly prohibited.  Delivery of this
message to any person other than the intended recipient shall not
compromise or waive such confidentiality, privilege or exemption
from disclosure as to this communication.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Version hell on Mac

2016-10-04 Thread Peter Jakobsson

On 4 Oct 2016, at 20:18, Benedict, Tom  wrote:

> Do you happen to know whether this will cause the On Saving Existing Record 
> Event Trigger Event to occur?

I’m afraid I don’t - good question.

I would imagine not. If it ran trigger code it could screw everything so I 
presume 4D makes it run at a lower level.

Peter

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Version hell on Mac

2016-10-04 Thread Benedict, Tom
Peter Jakobsson writes:

>Paul, here's that code snippet. I found it.

>  // Ortwin Zilgen code for instantly upgrading primary keys in a post v13 
> database (Works !)
>
>C_LONGINT($i;$P_SIZE)
>C_TEXT($tableName_t)
>
>$fieldName:="pkUUID"
>
>$P_SIZE:=Get last table number
>
>For ($i;1;$P_SIZE)
>If (Is table number valid($i))
>
>$tableName_t:=Table name($i)
>$statement_t:="ALTER TABLE ["+$tableName_t+"] ADD "+$fieldName+" UUID 
>AUTO_GENERATE PRIMARY KEY;"
>
>Begin SQL
>EXECUTE IMMEDIATE:$statement_t;
>End SQL

>End if
>End for

Do you happen to know whether this will cause the On Saving Existing Record 
Event Trigger Event to occur?

Tom Benedict
Optum
This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Version hell on Mac

2016-10-04 Thread Ortwin Zillgen
> Paul, here’s that code snippet. I found it.
> 
>  // Ortwin Zillgen code for instantly upgrading primary keys in a post 
> v13 database (Works !)
> 
> C_LONGINT($i;$P_SIZE)
> C_TEXT($tableName_t)

it was already common sense to proceed like that, at least with the 
die4Dwerkstatt-people. Then I wrote this article 
 to 
emphasise:
ADD THE UUID-FIELD BEFORE CONVERTING TO V14 AND MAKE THIS PRIMARY KEY
Sorry for shouting here, but it still seems not to be common sense.

I had to follow-up with this article, for those being perplexed by V13-behaviour


Peter, always a pleasure


Regards
O r t w i n  Z i l l g e n
-
   
 
member of developer-network 

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Version hell on Mac

2016-10-04 Thread Randy Jaynes
This is the track I took as well because being an OEM database, I don’t want to 
have to deal with mapping every single 4DD file I open up.

I’d be interested in seeing the SQL code as well, but your #2 is the best piece 
of advice I could offer as well.

Randy

--
Randy Jaynes
Senior Programmer and Customer Support

http://printpoint.com • (845) 359-0298 • PrintPoint, Inc • 57 Ludlow Lane • 
Palisades, NY 10964 


 

> On Oct 4, 2016, at 10:49 AM, Peter Jakobsson  wrote:
> 
> 
> 
>> We’ve seen with v15 the biggest thing seems to be the unique keys, 
>> presumably with uuids. How did you handle that? Did you just have uuids 
>> added onto all your tables?
> 
> Ah !
> 
> Well you can either spend 2 days doing it (as I did once)……or you can get 
> hold of a bit of SQL code originally posted by Ortwin Zilgen and do it in 
> about 20 seconds.
> 
> The general consensus is:
> 
> [1] - forget trying to map your old primary keys (IDs) to new ones. Keep all 
> your code as it is and IDs as they are
> 
> [2] - create new UUID primary keys for every table and let 4D have control of 
> them. You keep control of the old ones (which are now demoted to ‘business 
> logic’ layer primary keys)
> 
> In principle therefore, the new UUIDs basically work like the old record 
> numbers except they’e now just saved into the record. I’ve done this in a few 
> databases and it’s the most transparent way - basically no thought required 
> and lets you sleep well.
> 
> I’ll see if I can dig out that piece of SQL code…
> 
> Peter
> 
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Version hell on Mac

2016-10-04 Thread Peter Jakobsson

Paul, here’s that code snippet. I found it.


  // Ortwin Zilgen code for instantly upgrading primary keys in a post v13 
database (Works !)

C_LONGINT($i;$P_SIZE)
C_TEXT($tableName_t)

$fieldName:="pkUUID"

$P_SIZE:=Get last table number

For ($i;1;$P_SIZE)
If (Is table number valid($i))

$tableName_t:=Table name($i)
$statement_t:="ALTER TABLE ["+$tableName_t+"] ADD "+$fieldName+" UUID 
AUTO_GENERATE PRIMARY KEY;"

Begin SQL
EXECUTE IMMEDIATE:$statement_t;
End SQL

End if 
End for 


**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Version hell on Mac

2016-10-04 Thread Peter Jakobsson


> We’ve seen with v15 the biggest thing seems to be the unique keys, presumably 
> with uuids. How did you handle that? Did you just have uuids added onto all 
> your tables?

Ah !

Well you can either spend 2 days doing it (as I did once)……or you can get hold 
of a bit of SQL code originally posted by Ortwin Zilgen and do it in about 20 
seconds.

The general consensus is:

[1] - forget trying to map your old primary keys (IDs) to new ones. Keep all 
your code as it is and IDs as they are

[2] - create new UUID primary keys for every table and let 4D have control of 
them. You keep control of the old ones (which are now demoted to ‘business 
logic’ layer primary keys)

In principle therefore, the new UUIDs basically work like the old record 
numbers except they’e now just saved into the record. I’ve done this in a few 
databases and it’s the most transparent way - basically no thought required and 
lets you sleep well.

I’ll see if I can dig out that piece of SQL code…

Peter


**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Version hell on Mac

2016-10-04 Thread Paul Lovejoy
Peter,

Thanks for your input. 

When you made the transition, what were the biggest pitfalls?

We prepared a move from v12 to v13. A big job was to convert lots of grouped 
scrollable areas to listboxes. We had tons of those in the app.

We’ve seen with v15 the biggest thing seems to be the unique keys, presumably 
with uuids. How did you handle that? Did you just have uuids added onto all 
your tables?


Thanks,

Paul


> On 03 Oct 2016, at 15:25, Peter Jakobsson  wrote:
> 
> 
>> Is anyone else in a similar situation? What did you do / are you doing?
> 
> I took one straight from v11 to v15 (on installation was Windows, one was 
> Mac). Same reason as you - had to get to El Capitan comfort zone.
> 
> It wasn’t a big multinational but it was a complex database dealing with 
> money and running about 12 business in total. It has triggers all over the 
> place, 4D Write, usual mix of UI forms including widgets, lots of reports, 
> PDF printing and and included areas etc. It’s more stable now than it was in 
> v11.
> 
> Plugins are AealistPro and 4D Write.
> 
> I’d say you’ll have more problems staggering your upgrade than going straight 
> to v15. I know what you mean about “transiting through the intermediates” and 
> I used to think that too but now I’d say go direct to a “safe zone” without 
> transiting through the “danger zone”.
> 
> Just my 2 pence, of course. All structures are different and take all advice 
> that comes !
> 
> Best Regards
> 
> Peter
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Version hell on Mac

2016-10-03 Thread e...@mac-cafe.com
Actually I  end to blame the software developers for no keeping up with the 
system. If 4d wanted to they could back port fixes for the last version or two 
to the newest system. But instead 4d just says use the latest and forget about 
anything else. At least Apple continues to maintain 2 versions back. Apple also 
tells developers about things they should be doing and not doing. Quite often 
developers ignore the do not do things until it bites them. They they complain 
about and blame Apple for breaking their system. The short answer is make the 
jump to 15. But since they have not said anything I have seen about sierra 
support for either 15 or anything also I would not deploy sierra for anything 
running 4d yet.

Sent from my iPad

> On Oct 3, 2016, at 9:25 AM, Peter Jakobsson  wrote:
> 
> 
>> Is anyone else in a similar situation? What did you do / are you doing?
> 
> I took one straight from v11 to v15 (on installation was Windows, one was 
> Mac). Same reason as you - had to get to El Capitan comfort zone.
> 
> It wasn’t a big multinational but it was a complex database dealing with 
> money and running about 12 business in total. It has triggers all over the 
> place, 4D Write, usual mix of UI forms including widgets, lots of reports, 
> PDF printing and and included areas etc. It’s more stable now than it was in 
> v11.
> 
> Plugins are AealistPro and 4D Write.
> 
> I’d say you’ll have more problems staggering your upgrade than going straight 
> to v15. I know what you mean about “transiting through the intermediates” and 
> I used to think that too but now I’d say go direct to a “safe zone” without 
> transiting through the “danger zone”.
> 
> Just my 2 pence, of course. All structures are different and take all advice 
> that comes !
> 
> Best Regards
> 
> Peter
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**