Newbies Abarmard Posted July 1, 2004 Newbies Posted July 1, 2004 Hi, Hope someone can help! I want to use FileMaker as a front end to SQL Server and want to be able to insert to the table in SQL Server using FileMaker layout. I can select the fields by ODBC but don't know how to insert. If anyone knows where I can find the step by step info to do this would be great. I am going crazy with this. Please help, thanks.
Robert Kidd Posted July 5, 2004 Posted July 5, 2004 Define a calculation field, text result in the form :- "INSERT INTO Accounts VALUES ( '" & Value1 & "' , '" & Value2 & "' , '" & Month(Date) & " / " & Day(Date) & " / " & Year(Date) & "' )" Where "Accounts" is the name of the SQL table you want to insert into, and the fields are in the same order ( and format ) as they are in the SQL table.Be careful with the format of any dates. Create a script with the step Execute SQL, select your ODBC DSN and the field you created above. There is another INSERT syntax which specifies the field/s you want to insert into which is a little easier, I'll seee if I can find it and post it as well.
Newbies Abarmard Posted July 6, 2004 Author Newbies Posted July 6, 2004 Thanks for your help, I'll give it a try today
Newbies Abarmard Posted July 8, 2004 Author Newbies Posted July 8, 2004 I keep getting Exception error, but I think it's doable. Thanks again
Rick Roades Posted July 8, 2004 Posted July 8, 2004 When trying this (I need to send data daily in batch to MySql db), All my dates come across as 0000-00-00 (MySql stores dates in yyyy-mm-dd). Since the reporting I need to do is date sensitive, I' stuck, and not a FMP developer - Can you offer any advice? Thanks in advance
-Queue- Posted July 8, 2004 Posted July 8, 2004 Create a calculated text field of Year(datefield) & "-" & Right( "0" & Month(datefield), 2 ) & Right( "0" & Day(datefield), 2 ) and use this field for your MySql data.
Rick Roades Posted July 8, 2004 Posted July 8, 2004 I'm still getting "0000-00-00" in my date field in MySql...I've set the calculated field as both text and date type ("Calculation result is..."). The field looks set right, but just isn't transfering correctly.
Newbies NetherChris Posted July 9, 2004 Newbies Posted July 9, 2004 The MySQL function "NOW()" may be of use to you.
Rick Roades Posted July 9, 2004 Posted July 9, 2004 Sorry - I was unclear. I have to pull across several dates and times - dates of record creation, modification, project dates, etc. None of the dates I need to use involve grabbing what NOW() does. I've read threads where people have done this, but not been able to get it to work, or to reach them individually.
-Queue- Posted July 9, 2004 Posted July 9, 2004 My bad! I didn't include the second hyphen. Try Year(datefield) & "-" & Right( "0" & Month(datefield), 2 ) & "-" & Right( "0" & Day(datefield), 2 ). Create one calc for each date field you require.
Newbies Abarmard Posted July 12, 2004 Author Newbies Posted July 12, 2004 Anyone know if it's possible to call a Stored precedure from FileMaker to SQL Server 2000? That would be fantastic. If doable I think everything will be great. Please let me know. Thanks in advance p.s. I would like to update and insert by stored precedure while a user enters records using FMP.
Rick Roades Posted July 13, 2004 Posted July 13, 2004 Thanks for the continuing help. Sorry for the long delay... I actually caught the missing second hyphen, and had it in the field. But as a precaution, I copied and pasted your second post calculation, substituted the actual field, and reran the script. Still the dates (which all show properly in FMP) are 0000-00-00. I'm at a total loss here.
-Queue- Posted July 13, 2004 Posted July 13, 2004 Make sure the calculation is set as text. If it's a date, it definitely will get screwy. How are you pushing the data to MySQL?
Rick Roades Posted July 14, 2004 Posted July 14, 2004 Calculation is set to text - had tried once the date setting, but when FMP didn't know what to do with it, I knew that wasn't working. Using an ODBC connection (myodbc ver. 2.50.39.00), the MySQL and FMP are on the same dev server. The sql statement in FMP is: insert into sales_clone (date_created) values (" & datecreatedformatted & ") At this point, I guessed if I can get one date field working, the others will as well.
-Queue- Posted July 14, 2004 Posted July 14, 2004 What happens if you try removing the quotes? Does set date_created=datecreatedformat work, with or without the quotes?
Rick Roades Posted July 14, 2004 Posted July 14, 2004 I have tried every combination of quotes/without, with ampersand/without I can think of. Without the quotes, I get a syntax error in the sql statment from FMP on every record. Since the "datecreatedformatted" is the only field I'm sending over, that's the error. I've tried single quotes. Anything that doesn't error completely ends up as 0000-00-00 in MySQL. Not sure what you mean on "set date_created=datecreatedformatted". If you mean using this as part of the VALUES statement in the sql statement, that would normally only be used in an UPDATE, not an INSERT, wouldn't it? Since I have to insert each record, I can't use that. But, I will try it as an update, just to see if it goes over...
-Queue- Posted July 15, 2004 Posted July 15, 2004 No, I mean the alternate Insert syntax of Insert into table Set colum=value.
Rick Roades Posted July 15, 2004 Posted July 15, 2004 Ah - tried it...same result. Does anyone know of a way to set a data type during the insert statement? I'm beginning to wonder if it's because of the data type that it's zeroing out....
-Queue- Posted July 16, 2004 Posted July 16, 2004 If you replace the date field with a simple number field that doesn't require ticks, does any data actually make it to the other side?
Newbies William WM Posted August 22, 2004 Newbies Posted August 22, 2004 I would like to know EXACTLY which syntax I have to use to get an insert into working. None of the examples I found on the web works. Could someone please describe the exact syntax which I should use in like: INSERT INTO tablename VALUES ( fieldName1 , fieldName3 , fieldName3 , value1 , value 2 ) Including & ' " and other characters which need to be there. And hopefully also why they have to be there, like: You have to use & & around field names because bla bla... Please?
Newbies William WM Posted August 23, 2004 Newbies Posted August 23, 2004 So what I'm trying to do is impossible?
Recommended Posts
This topic is 7395 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