Hi all.
I am trying to insert a record in a postgresql table with a xml field.
/** @type {JSFoundSet<db:/my_server/my_table>} */
var fs = databaseManager.getFoundSet("db:/my_server/my_table");
fs.newRecord();
fs.xml_data = '<xml><item>item1</item></xml>';
var bok = databaseManager.saveData(fs);
I have tried like an xml object as well …
/** @type {JSFoundSet<db:/my_server/my_table>} */
var fs = databaseManager.getFoundSet("db:/my_server/my_table");
fs.newRecord();
fs.xml_data = <xml><item>item1</item></xml>;
var bok = databaseManager.saveData(fs);
But it doesn’t works … any ideas?
Best regards. Roberto Blasco.
Servoy v.8.1.2 - build 3031
Postgresql (the bundle with servoy)
Hi Roberto,
here are some thoughts:
the postgres doc PostgreSQL: Documentation: 9.6: XML Type says for XML types “… Its advantage over storing XML data in a text field is that it checks the input values for well-formedness, and there are support functions to perform type-safe operations on it…”
Maybe that check is not working and postgres rejects inserting that XML, without telling you?
So I would first check what happens if you do a normal SQL INSERT with your desired XML-string.
Then I would also add a normal string field and check if this works:
fs.string_field = '<xml><item>item1</item></xml>';
We always use a record var when adding a record, that might be more save.
var record = foundset.getRecord(foundset.newRecord())
record.xml_data = ....
When you go to pgAdmin and have a look to your sample table, what does the CREATE TABLE command show regarding your field?
Are you sure Servoy supports postgres-XML-fields at all?
What is the type Servoy shows in its table editor for that XML-field? I would guess it is TEXT?