Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Call SQL Server stored procedure from 1C

Forum

Search UsersRules
Call SQL Server stored procedure from 1C
#1
Active user
Points:: 0
Joined:: Sep 1, 2014

Hello Timofey.

I need to call from 1C a stored procedure form SQL SERVER and get the result.

Any idea on how to do this?

Thanks.

Profile
#2
Guest
Points::
Joined::

Hello, Marius Gidu.

You can use External data sources for this. There is an example in the Tabular Section, ValueTable, FormDataCollection Vs SpreadSheetDocument topic.
The difference is that in your case you need to add a stored procedure definition (see the attached screenshot).

To execute the stored procedure you can use the following script:

Code
ExternalDataSources.StoredProcedure.StoredProcedure(parameter1, parameter2, ...)

Profile
#3
Active user
Points:: 0
Joined:: Sep 1, 2014

Thanks. But my return type is none of the type in the Type field.

How i can do this entirely from code.

Profile
#4
Guest
Points::
Joined::

If you want to get a table as a result, it is better to create a view or a table with precalculated data, depending on the data load.

Profile
#5
Active user
Points:: 0
Joined:: Sep 1, 2014

Please can you give a complete example of this?

Thanks.

Profile
#6
Guest
Points::
Joined::

Marius Gidu, the view is created on SQL level. For example, in MS SQL

Code
CREATE VIEW view_name AS 
SELECT table.id, table.value, ...
FROM some_table table

The table with precalculated data is an ordinary SQL table where you can update data that you can calculate when in the source table some changes are made.

The rest is done same as in the example above.

Hope, this helps.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.