SQLite Forum

edit() function usage
Login
You're probably onto something there. BBEDIT is a GUI application, whereas the `edit()` command in SQLite expects a path to an executable which will start an editor, and exit when the user is done. Starting a GUI Application on a Mac is a rather complicated affair involving more than a simple `fork()`, but the principle remains: The process activating the GUI application will usually continue as soon as it has triggered the activation of the application.

If you do this in the interactive SQLite shell, you would probably see the shell prompt immediately after invoking the `edit`.

For example, I don't have a copy of BBEDIT, but I tried an experiment using an editor called CotEditor (available from the App Store). CotEditor comes with an associated command line utility simply called `cot`, which will start CotEditor on a given file. It accepts a flag `-w`, which causes `cot` to wait until CotEditor has closed the file.

My little experiment proceeded as follows:

```
▶▶▶ create table foo(bar);
▶▶▶ insert into foo values("blah");
▶▶▶ select rowid,bar from foo;
rowid  bar
-----  ----
1      blah
▶▶▶ update foo set bar=edit(bar,'cot') where rowid=1;
-- note: the prompt below appeared immediately,
-- before I had time to do any editing; so, no change
▶▶▶ update foo set bar=edit(bar,'cot -w') where rowid=1;
-- here, nothing happened until I had saved and closed the temporary file
▶▶▶ select rowid,bar from foo;
rowid  bar
-----  ------
1      blargh
-- success!
```

If you wish this to work with BBEDIT, you need a similar tool. I don't know if BBEDIT provides such a tool.