Quantcast
Channel: SQL Server Spatial forum
Viewing all articles
Browse latest Browse all 364

Insert using Spatial Index fails when called from PHP

$
0
0

I have a stored procedure that inserts into a table with a spatial index on one of its fields.

When I run the procedure from SQL Server Management Studio it runs just fine.

When I run it from PHP, it returns the error: "INSERT failed because the following SET options have incorrect settings: 'CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS, ANSI_PADDING'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations"

From within Management Studio, I have tried many different combinations of settings, until I wound up with the list I have in the procedure below.

Within Managment Studio the error changes based on the options I have set, but PHP always replies with: 'CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS, ANSI_PADDING'

I have configured PHP to use the same SQL user as management studio, and I have tried both mssql_query and mssql_execute with bound parameters.

The spatial index is on the field post.location If I remove the spatial index it works, but I need the spatial index.

CREATE PROCEDURE insert_post ( @subject AS VARCHAR(250), @body AS VARCHAR(2000), @latitude AS FLOAT, @longitude AS FLOAT ) AS BEGIN

SET NOCOUNT ON

SET ANSI_WARNINGS ON
SET ANSI_PADDING ON
SET CONCAT_NULL_YIELDS_NULL ON
SET NUMERIC_ROUNDABORT OFF

DECLARE @location AS geography = geography::Point(@latitude, @longitude, 4326)

INSERT INTO post
(
    subject,
    body,
    location
) VALUES (
    @subject,
    @body,
    @location
)

END


Viewing all articles
Browse latest Browse all 364

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>