win32::sqlserver not able to sql_insert

D

Digger

Hi,
I hope that anybody have info on this, i've install and have
win32::sqlserver working properly.
I'm able to retrieve data from my database with the select statement.

My problem is with sql_insert here my code:

my $table = "icon";
#my %values=("iconID"=>'3',"link"=>"something");
#my %values=("iconID"=>3,"link"=>"something");
#my %values=("iconID"=>"3","link","something");
#my %values=("iconID",3,"link","something");
my %values=("iconID","3","link","somethingElse");

$sqlsrv->sql_insert($table,\%values);

Table is call icon, iconID is a primary key and an integer, link is a
varchar.

Here the error I get all the time:
SQL Server message 515, Severity 16, State 2, Server WEB-T-
SQL1\DVSQBQL
Line 1
Cannot insert the value NULL into column 'iconid', table
'master.dbo.Icon'; column does not allow nulls. INSERT fails.
1> EXEC sp_executesql N'INSERT icon (iconID, link)
2> VALUES (@P1, @P2)',
3> N'@P1 int, @P2 varchar(13)',
4> @P1 = NULL, @P2 = 'somethingElse'
The statement has been terminated.

It look like it doesn't like my value for IconID, what's missing...
take me out of my misery.

Thx,

Michel
 
B

Ben Morrow

Quoth Digger said:
Hi,
I hope that anybody have info on this, i've install and have
win32::sqlserver working properly.
I'm able to retrieve data from my database with the select statement.

My problem is with sql_insert here my code:

my $table = "icon";
#my %values=("iconID"=>'3',"link"=>"something");
#my %values=("iconID"=>3,"link"=>"something");
#my %values=("iconID"=>"3","link","something");
#my %values=("iconID",3,"link","something");
my %values=("iconID","3","link","somethingElse");

$sqlsrv->sql_insert($table,\%values);

Table is call icon, iconID is a primary key and an integer, link is a
varchar.

Here the error I get all the time:
SQL Server message 515, Severity 16, State 2, Server WEB-T-
SQL1\DVSQBQL
Line 1
Cannot insert the value NULL into column 'iconid', table
'master.dbo.Icon'; column does not allow nulls. INSERT fails.
1> EXEC sp_executesql N'INSERT icon (iconID, link)
2> VALUES (@P1, @P2)',
3> N'@P1 int, @P2 varchar(13)',
4> @P1 = NULL, @P2 = 'somethingElse'
The statement has been terminated.

It look like it doesn't like my value for IconID, what's missing...
take me out of my misery.

Type int, value NULL seems to be what Win32::SqlServer inserts when it
doesn't recognise the column name. Since SQL Server seems to think the
column is called 'iconid', not 'iconID', perhaps you should try that.

Is there a good reason you're not using DBI? While it may not support so
much of the SQL-Server-specific API, it's probably better tested.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top