Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Simple SQL question

Featured Replies

I am starting to use simple SQL commands to create new records and cannot find a way to return the primary key from the record that was created.

Is there a combination of INSERT/SELECT that will do this for me?

Thanks

Tim

You will need to send two command lines:

One to insert the record

"INSERT INTO TABLENAME"

and

Another one to retrieve the zkp

"SELECT MAX (ID) FROM TABLENAME"

the latest will give you the MAX of the ID.

  • Author

Great thanks Andries, will try it.

You will need to send two command lines:

One to insert the record

"INSERT INTO TABLENAME"

and

Another one to retrieve the zkp

"SELECT MAX (ID) FROM TABLENAME"

the latest will give you the MAX of the ID.

  • 1 month later...

Hi

This seems very great and I was playing with this for multiply create. However, everytime there is added a digit to the serial number, the select statement does not function...

e.g.

Create record, which gets pkID 9

When you create record that gets pkID 10 the select will stay on 9.

Only if you delete all records, it can go on with 12.....99 but then it has the same issue....

Does anyone know if this is normal, if it is a limitation in the Filemaker SQL functions or if it is a ScriptMaster issue ?

You will need to send two command lines:

One to insert the record

"INSERT INTO TABLENAME"

and

Another one to retrieve the zkp

"SELECT MAX (ID) FROM TABLENAME"

the latest will give you the MAX of the ID.

Sorry.... I just found the answer myself..... the pk ID field needs to be a number field....

Hi

This seems very great and I was playing with this for multiply create. However, everytime there is added a digit to the serial number, the select statement does not function...

e.g.

Create record, which gets pkID 9

When you create record that gets pkID 10 the select will stay on 9.

Only if you delete all records, it can go on with 12.....99 but then it has the same issue....

Does anyone know if this is normal, if it is a limitation in the Filemaker SQL functions or if it is a ScriptMaster issue ?

Is your pkID a Number field? It sounds like it is a simple text field, in that case 9 is bigger than 10... the same holds for 12..99, where 99 is bigger than 100 in a alphabetical sort.

edit: didn't read the previous post...

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.