On Mon, Jun 16, 2014 at 5:37 PM, <c...@isbd.net> wrote:

> Does the return value contain anything that will tell me if the SQL
> worked or not?
>

...
  set_table_name(&data, 0);
  if( data.db ){
    sqlite3_close(data.db);
  }
  sqlite3_free(data.zFreeOnClose);
  return rc;
}

it returns the result code of the last run command. That said, the only
portable result codes are "success" (0) and "not success" (not 0, but which
"not 0" is not specified). In my experience, most Linux shells support
result values -127 to 128, but that's just a common convention, not a rule.
Bash seems to support 0-255 on this machine:

[odroid@host:~/fossil/fossil]$ echo 'exit 129' > foo.sh
[odroid@host:~/fossil/fossil]$ sh foo.sh
[odroid@host:~/fossil/fossil]$ echo $?
129

[odroid@host:~/fossil/fossil]$ echo 'exit 329' > foo.sh
[odroid@host:~/fossil/fossil]$ sh foo.sh
[odroid@host:~/fossil/fossil]$ echo $?
73




> If it doesn't then what's the easiest way for a script to tell if some
> SQL executed by sqlite3 worked or not?  I just want to do a single row
> insert into a table and, if it succeeds, the source of the inserted
> data can be removed.


Failing to SELECT or  DELETE anything is not an error, so no, it won't fail
in that case. It will fail if your syntax is wrong:

[odroid@host:~/fossil/fossil]$ echo "drop foo;" | sqlite3
Error: near line 1: near "foo": syntax error
[odroid@host:~/fossil/fossil]$ echo $?
1



-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to