Tim Anderson Posted February 17, 2011 Posted February 17, 2011 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
andries Posted February 18, 2011 Posted February 18, 2011 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.
Tim Anderson Posted February 18, 2011 Author Posted February 18, 2011 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.
Claus Lavendt Posted April 1, 2011 Posted April 1, 2011 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.
Claus Lavendt Posted April 2, 2011 Posted April 2, 2011 Sorry.... I just found the answer myself..... the pk ID field needs to be a number field....
andries Posted April 4, 2011 Posted April 4, 2011 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...
Recommended Posts
This topic is 4994 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now