Jump to content

sql: INSERT statement


This topic is 6979 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello, I've been working with mysql and php for a while and now I'm looking into using Filemaker 7 as a frontend.

I think what I'm trying to do is fairly simple:

I want to use Scriptmaker to Execute an SQL query, like this:

INSERT INTO journalists (contact, name) Values ("' & contact & '","' & name & '")

I've added a new record, two fields, contact and name, and I now want to add that record to the sql database. But how do I get the field values into the INSERT statement?

In php I would do:

<?php

$sql = "INSERT INTO journalists (contact, name) Values ('".$contact."','".$name."')";

?>

What do I do in Scriptmaker?

Thanks a bunch.

Willy

Oslo, Norway

Link to comment
Share on other sites

1.0 As first, you need SQL plugin...more info here:

http://www.planetsg.com/PLANet/PLANet_HowTo/PDMConfiguration.htm

2.0 Next thing is to consider ODBC and JDBC.

check out: http://www.planetsg.com/PLANet/PLANet_HowTo/HowTo.htm

3.0 After you've established connection to the mySQL server, next step is to shout the query by using SQL plugin function :

SetField[someField, External ( "doFTP-Put"; "INSERT INTO journalists (contact, name) Values ('".$contact."','".$name."')")]

Good Luck smile.gif

Link to comment
Share on other sites

You can use the Execute SQL() Script step. You then have the option of writing out a fixed SQL statement or you can create a calculated SQL statement. This is what you will want to do. I believe you will write it like you did above and just enter in the FMP fields into the values function.

HTH,

John

Link to comment
Share on other sites

  • 2 weeks later...

Hello and thanks for the reply. I'm using ODBC, I bought the Actual ODBCPack which works great.

One question: Could you please show how you would write the INSERT code using the Execute SQL() function? (With fields from the FM database)

Thanks!

Link to comment
Share on other sites

Ok, I figured it out. I was a bit confused but now I'm fine. smile.gif I did, with the Execute SQL function->Calculated SQL text:

"INSERT INTO `users` ( `id` , `username` , `password` , `reply_to` , `reply_name` , `last_login` , `cookie` )

VALUES (

'', '"&WDev::Navn&"', 'password', '"&WDev::Epost&"', '', '', ''

);"

WDev being the name of the FileMaker database.

It was the '"&WDev::<field>&"' part I couldn't figure out right.

Thanks ya'll!

Link to comment
Share on other sites

Ok, I figured it out. I was a bit confused but now I'm fine. smile.gif I did, with the Execute SQL function->Calculated SQL text:

"INSERT INTO `users` ( `id` , `username` , `password` , `reply_to` , `reply_name` , `last_login` , `cookie` )

VALUES (

'', '"&WDev::Navn&"', 'password', '"&WDev::Epost&"', '', '', ''

);"

WDev being the name of the FileMaker database.

It was the '"&WDev::P<field>&"' part I couldn't figure out right.

Thanks ya'll!

Link to comment
Share on other sites

Ok, I figured it out. I was a bit confused but now I'm fine. smile.gif I did, with the Execute SQL function->Calculated SQL text:

"INSERT INTO `users` ( `id` , `username` , `password` , `reply_to` , `reply_name` , `last_login` , `cookie` )

VALUES (

'', '"&WDev::Navn&"', 'password', '"&WDev::Epost&"', '', '', ''

);"

WDev being the name of the FileMaker database.

It was the '"&WDev:B)<field>&"' part I couldn't figure out right.

Thanks ya'll!

Link to comment
Share on other sites

This topic is 6979 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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