×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Auto IDs

Auto IDs

(OP)
Hello, again!

I have a table with your standard Update window and procedure that works fine.  When a new record is created, the ID field is incremented by one in the new record automatically.

Now I have some Embedded code trying to create a new record manually in the same table:

   TABLE1:Field1 = TABLE2:Field1
   ...
   ADD(TABLE)

I'm not specifying the TABLE:ID field assuming the system would increment the value automatically.  But, the new record is created and the assigned values are saved to each field -- except the ID field which is always 0.

I'm now assuming I have to specify TABLE:ID = -- but to what?

RE: Auto IDs

Hi

You may use this code  in place of add(<tableName>)
 

CODE

        Access:<tableName>.PrimeAutoInc()
        Access:<tableName>.Insert()

This should do it

Regards
 

RE: Auto IDs

(OP)
Hello,

That code looks odd to me.  I got 4 Syntax Errors when I compiled the program with those recommended changes.  

We have Clarion 5.  Is that code only supported in a higher version?

RE: Auto IDs

It should work with Clarion 4 and above , what are the errors you are getting ?

regards

 

 

RE: Auto IDs

Hi!

Just Access:<tableName>.Insert() should be enough as PrimeAutoInc might add a empty row/record.

Regards
 

RE: Auto IDs

(OP)
Okay, here's the code I used:
==============================================================================
! Create New Prospect
! First, check if not flagged Selected or flagged Ignore

IF CO:SalesProspectSelected = 0 OR CO:SalesProspectIgnore = 1
    MESSAGE('"' & CLIP(CO:CompanyNameLong) & '" is not flagged as SELECTED or flagged as IGNORE','ERROR: Cannot Create New Prospect')
ELSE
    ! Select Portfolio
    DO SyncWindow
    GlobalRequest = SelectRecord
    BrowsePortfolioNames
    LocalRequest = OriginalRequest
    DO RefreshWindow

    IF MESSAGE(CLIP(CO:CompanyNameLong) & ' to ' & CLIP(SPORT:Salesperson) & ' - ' & CLIP(SPORT:Name ) & '?','Assign...',ICON:Question,BUTTON:Yes+BUTTON:No,BUTTON:Yes) = BUTTON:Yes

        SLSPROSP:PortfolioID = SPORT:ID
        SLSPROSP:PortfolioName = SPORT:Name
        SLSPROSP:Salesperson = SPORT:Salesperson

        SLSPROSP:CompanyCode = CO:Company
        SLSPROSP:CompanyPriority = CO:CoPriority
        SLSPROSP:ClientRelationship = '

        SLSPROSP:DateAddedtoPortfolio = TODAY()
        SLSPROSP:AddedToPortfolioBy = Usr:UserName
        SLSPROSP:DateCreated = TODAY()

!        ADD(SALESProspects)
        Access:SLSPROSPECTS.Insert()


        ! Update Company, if no Error
        IF ERROR() = '
            CO:SalesProspectAssigned = 1
            CO:SalesProspectAdded = TODAY()
            PUT(COMPANY)
        END


    !    GlobalRequest = ChangeRecord
    !    UpdatePipelineOverview

        DISPLAY()
        ForceRefresh = True
        DO RefreshWindow
    END
END
==============================================================================

And here is the compile window results:

Making sales010.obj (sales 010.clw changed)
Making sales010.clw
(sales010.clw 316,37) Syntax error: Field not found:INSERT
(sales010.clw 316,17) Syntax error: Unknown procedure label

 

RE: Auto IDs

Hi!

You are using the LEGACY template - Access:<tableName>.Insert() is ABC.

Declare an ALIAS for the SALESProspects and use the ALIAS file to find the next ID. Do a loop check for duplicates in case two users are trying at the same time.

CODE

LOOP
   ADD(SALESProspects)

   IF ERRORCODE() = 43
      <IDColumn> += 1
      CYCLE
   ELSIF ERRORCODE()
      !handle error
   END
   BREAK
END

Regards
 

RE: Auto IDs

Hi!

Correction. It should be IF ERRORCODE() = 40 ! DupKeyErr ...

Regards
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close