1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-12-01 22:29:52 +02:00
Files
OpenIntegrations/docs/en/md/PostgreSQL/Orm/Update-records.mdx

104 lines
3.5 KiB
Plaintext
Raw Normal View History

2025-02-12 19:33:53 +03:00
---
2025-06-09 22:06:01 +03:00
sidebar_position: 13
2025-05-05 11:15:20 +03:00
description: Update records and other functions to work with PostgreSQL in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
2025-05-05 09:49:19 +03:00
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, PostgreSQL]
2025-02-12 19:33:53 +03:00
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Update records
Updates the value of records by selected criteria
2025-03-11 21:09:03 +03:00
`Function UpdateRecords(Val Table, Val ValueStructure, Val Filters = "", Val Connection = "", Val Tls = "") Export`
2025-02-12 19:33:53 +03:00
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| Table | --table | String | ✔ | Table name |
| ValueStructure | --values | Structure Of KeyAndValue | ✔ | Values structure: Key > field, Value > field value |
| Filters | --filter | Array of Structure | ✖ | Filters array. See GetRecordsFilterStrucutre |
| Connection | --dbc | String, Arbitrary | ✖ | Connection or connection string |
2025-03-11 21:09:03 +03:00
| Tls | --tls | Structure Of KeyAndValue | ✖ | TLS settings, if necessary. See GetTlsSettings |
2025-02-12 19:33:53 +03:00
2025-02-17 17:16:27 +03:00
Returns: Map Of KeyAndValue - Result of query execution
2025-02-12 19:33:53 +03:00
<br/>
2025-02-15 19:36:59 +03:00
:::tip
2025-02-15 20:40:36 +03:00
Record data is specified as an array of structures of the following type:<br/>`{'Field name 1': {'Type': 'Value'}, 'Field name 2': {'Type': 'Value'},...}`
2025-02-15 19:36:59 +03:00
The list of available types is described on the initial page of the PostgreSQL library documentation
:::
<br/>
2025-02-12 19:33:53 +03:00
```bsl title="1C:Enterprise/OneScript code example"
2025-06-29 14:35:33 +03:00
Address = "127.0.0.1";
2025-02-14 23:21:49 +03:00
Login = "bayselonarrend";
2025-06-29 14:35:33 +03:00
Password = "12we...";
2025-02-15 13:38:30 +03:00
Base = "test_data";
2025-02-12 19:33:53 +03:00
2025-02-14 23:21:49 +03:00
ConnectionString = OPI_PostgreSQL.GenerateConnectionString(Address, Base, Login, Password);
2025-02-15 13:38:30 +03:00
Table = "test_data";
2025-02-14 23:21:49 +03:00
FieldsStructure = New Structure;
2025-02-15 13:38:30 +03:00
FieldsStructure.Insert("ip_address", New Structure("VARCHAR", "127.0.0.1"));
2025-02-14 23:21:49 +03:00
Filters = New Array;
FilterStructure = New Structure;
2025-02-15 13:38:30 +03:00
FilterStructure.Insert("field", "gender");
2025-02-14 23:21:49 +03:00
FilterStructure.Insert("type" , "=");
2025-02-15 13:38:30 +03:00
FilterStructure.Insert("value", New Structure("VARCHAR", "Male"));
2025-02-14 23:21:49 +03:00
FilterStructure.Insert("raw" , False);
Filters.Add(FilterStructure);
2025-02-15 22:58:22 +03:00
// When using the connection string, a new connection is initialised,
// which will be closed after the function is executed.
// If several operations are performed, it is desirable to use one connection,
// previously created by the CreateConnection function()
2025-02-14 23:21:49 +03:00
Result = OPI_PostgreSQl.UpdateRecords(Table, FieldsStructure, FilterStructure, ConnectionString);
2025-02-12 19:33:53 +03:00
```
2025-02-18 14:08:09 +03:00
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
# JSON data can also be passed as a path to a .json file
oint postgres UpdateRecords \
--table "test_data" \
--values "{'ip_address':{'VARCHAR':'127.0.0.1'}}" \
--filter "[{'field':'gender','type':'=','value':{'VARCHAR':'Male'},'raw':false}]" \
--dbc "postgresql://bayselonarrend:***@127.0.0.1:5432/"
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
:: JSON data can also be passed as a path to a .json file
oint postgres UpdateRecords ^
--table "test_data" ^
--values "{'ip_address':{'VARCHAR':'127.0.0.1'}}" ^
--filter "[{'field':'gender','type':'=','value':{'VARCHAR':'Male'},'raw':false}]" ^
--dbc "postgresql://bayselonarrend:***@127.0.0.1:5432/"
```
</TabItem>
</Tabs>
2025-06-17 16:20:59 +03:00
```json title="Result"
{
"result": true
}
```