Showing posts with label store. Show all posts
Showing posts with label store. Show all posts

Wednesday, March 21, 2012

Invalid Locator de-referenced

In our application we use three database(access, sql server and oracle) to store configurations. We use a program to copy the configuration from one database to another. We use ODBC and MFC recordsets to do the copy. We recently updated the application and changed the the table schema's. Before we had two tables which each had a schema of one long as key and one image field. Now we have one table with one long as key and three image fields. Now when we copy to sql server from access we get the error " Invalid locator de-refrenced" when we have large data (about 1 MB) in one image field. Before the change in schema's we did not have this problem with an image field with a large amout of data. We are using the sql server odbc driver.

Jim,

I believe this error message is raised as a result of writetext request to the server. Is it possible for you to try SQL Native Client ODBC driver. This is the most up to date SQL Server ODBC driver. You can download Microsoft SQL Server Native Client from http://www.microsoft.com/downloads/details.aspx?FamilyId=DF0BA5AA-B4BD-4705-AA0A-B477BA72A9CB&DisplayLang=en

Thanks

Waseem

|||

I am using the SQL server ODBC driver 2000.85.1117.00 and also got the Invalid Locator de-referenced when I copied data containing the big image and text. I used the SQLPrepare, SQLBinderParam, SQLParam and SQLPutData. The error I got likes:

SQLParamData: RETCODE= -1; State=37000, Native Error=7143

Our application is Unicode based and we used the SQL_C_WCHAR and SQL_C_BINARY in bind parameter but the sql type in the server is text and image.

Any idea?

I downloaded the SQL Native Client, it is even worse since I got an exception for un-recognized type.

Appreicate any helps

workingonsql

|||

having the same problem found a solution said "passing SQL_LEN_DATA_AT_EXEC(250000) as the
nullindicator to SQLBindParameter and then put the data in 250000 byte chunks".

but not sure what its means, do you know?

Invalid Locator de-referenced

In our application we use three database(access, sql server and oracle) to store configurations. We use a program to copy the configuration from one database to another. We use ODBC and MFC recordsets to do the copy. We recently updated the application and changed the the table schema's. Before we had two tables which each had a schema of one long as key and one image field. Now we have one table with one long as key and three image fields. Now when we copy to sql server from access we get the error " Invalid locator de-refrenced" when we have large data (about 1 MB) in one image field. Before the change in schema's we did not have this problem with an image field with a large amout of data. We are using the sql server odbc driver.

Jim,

I believe this error message is raised as a result of writetext request to the server. Is it possible for you to try SQL Native Client ODBC driver. This is the most up to date SQL Server ODBC driver. You can download Microsoft SQL Server Native Client from http://www.microsoft.com/downloads/details.aspx?FamilyId=DF0BA5AA-B4BD-4705-AA0A-B477BA72A9CB&DisplayLang=en

Thanks

Waseem

|||

I am using the SQL server ODBC driver 2000.85.1117.00 and also got the Invalid Locator de-referenced when I copied data containing the big image and text. I used the SQLPrepare, SQLBinderParam, SQLParam and SQLPutData. The error I got likes:

SQLParamData: RETCODE= -1; State=37000, Native Error=7143

Our application is Unicode based and we used the SQL_C_WCHAR and SQL_C_BINARY in bind parameter but the sql type in the server is text and image.

Any idea?

I downloaded the SQL Native Client, it is even worse since I got an exception for un-recognized type.

Appreicate any helps

workingonsql

|||

having the same problem found a solution said "passing SQL_LEN_DATA_AT_EXEC(250000) as the
nullindicator to SQLBindParameter and then put the data in 250000 byte chunks".

but not sure what its means, do you know?

Invalid Locator de-referenced

In our application we use three database(access, sql server and oracle) to store configurations. We use a program to copy the configuration from one database to another. We use ODBC and MFC recordsets to do the copy. We recently updated the application and changed the the table schema's. Before we had two tables which each had a schema of one long as key and one image field. Now we have one table with one long as key and three image fields. Now when we copy to sql server from access we get the error " Invalid locator de-refrenced" when we have large data (about 1 MB) in one image field. Before the change in schema's we did not have this problem with an image field with a large amout of data. We are using the sql server odbc driver.

Jim,

I believe this error message is raised as a result of writetext request to the server. Is it possible for you to try SQL Native Client ODBC driver. This is the most up to date SQL Server ODBC driver. You can download Microsoft SQL Server Native Client from http://www.microsoft.com/downloads/details.aspx?FamilyId=DF0BA5AA-B4BD-4705-AA0A-B477BA72A9CB&DisplayLang=en

Thanks

Waseem

|||

I am using the SQL server ODBC driver 2000.85.1117.00 and also got the Invalid Locator de-referenced when I copied data containing the big image and text. I used the SQLPrepare, SQLBinderParam, SQLParam and SQLPutData. The error I got likes:

SQLParamData: RETCODE= -1; State=37000, Native Error=7143

Our application is Unicode based and we used the SQL_C_WCHAR and SQL_C_BINARY in bind parameter but the sql type in the server is text and image.

Any idea?

I downloaded the SQL Native Client, it is even worse since I got an exception for un-recognized type.

Appreicate any helps

workingonsql

|||

having the same problem found a solution said "passing SQL_LEN_DATA_AT_EXEC(250000) as the
nullindicator to SQLBindParameter and then put the data in 250000 byte chunks".

but not sure what its means, do you know?

sql

Monday, March 12, 2012

Invalid column name in SP

I spend over 3 hrs to debug (The following store procedure, I always got
invalid column at The @.reportId) . I had used the same approach in other SP
.
and everything goes fine. BUT today, I don't know what's going on. Please
Help ~~~
EXEC sel_pl_acctjobperiod '200312','0001','HLSHK','DTS_ACCOUNT.DBO'
I got [invalid column name '0001',invalid column name '200312',invalid
column name 'HLSHK'.]
CREATE PROCEDURE dbo.sel_pl_acctjobperiod
@.jobperiod nvarchar(6),
@.reportid nvarchar(20),
@.BranchID nvarchar(10),
@.dbcname_dest varchar(20)
AS
SET NOCOUNT ON
DECLARE @.sql_insert varchar(4000)
DECLARE @.sql_sel_debit varchar(4000)
DECLARE @.sql_arinv_debit varchar(4000)
DECLARE @.sql_where varchar(4000)
DECLARE @.sql_arinv_debit_exec nvarchar(4000)
SELECT @.sql_insert = 'insert into tmp_pl_acctinfo
(deptid,branchid,reportid,smancode,jobno
,invno,iemtype,jobperiod ,
TtlIncome, TtlExpenses, TtlNetProfit,doctype) '
SELECT @.sql_sel_debit ='select Info.deptid,Info.branchid,"' + @.reportid + '"
as reportid ,'''' as
smancode,Info.JobNo,Info.invno,Info.iemtype,Info.jobperiod ,info.ttlbaseamt
as ttlincome, 0 as ttlexpenses, 0 as ttlnetprofit,'
SELECT @.sql_arinv_debit =' '''' as doctype from ' + @.dbcname_dest +
'.arinvinfo Info where Info.validsw = 1 and Info.accttype = "DEBIT" '
SELECT @.sql_where = ' and Info.jobperiod="' + @.jobperiod + '" and
Info.branchid="' + @.branchid + '"'
SELECT @.sql_arinv_debit_exec = @.sql_insert + @.sql_sel_debit +
@.sql_arinv_debit + @.sql_where
print @.sql_arinv_debit_exec
EXEC (@.sql_arinv_debit_exec)Try SET QUOTED_IDENTIFIER OFF then drop and re-create the proc.
Alternatively, change your double quotes (") into two single quotes
(''), otherwise they may be read as column delimiters.
The QUOTED_IDENTIFIER setting is saved with each proc so take notice of
that setting whenever you use CREATE PROC.
David Portas
SQL Server MVP
--|||Hi
You seem to have double quotes in your command string (@.sql_sel_debit),
therefore you may have QUOTED_IDENTIFIER ON. If you want to escape a single
quote use another single quote.
John
"Agnes" <agnes@.dynamictech.com.hk> wrote in message
news:OuUg0lpQFHA.3144@.tk2msftngp13.phx.gbl...
>I spend over 3 hrs to debug (The following store procedure, I always got
>invalid column at The @.reportId) . I had used the same approach in other
>SP .
> and everything goes fine. BUT today, I don't know what's going on. Please
> Help ~~~
> EXEC sel_pl_acctjobperiod '200312','0001','HLSHK','DTS_ACCOUNT.DBO'
> I got [invalid column name '0001',invalid column name '200312',invalid
> column name 'HLSHK'.]
> CREATE PROCEDURE dbo.sel_pl_acctjobperiod
> @.jobperiod nvarchar(6),
> @.reportid nvarchar(20),
> @.BranchID nvarchar(10),
> @.dbcname_dest varchar(20)
>
> AS
> SET NOCOUNT ON
> DECLARE @.sql_insert varchar(4000)
> DECLARE @.sql_sel_debit varchar(4000)
> DECLARE @.sql_arinv_debit varchar(4000)
> DECLARE @.sql_where varchar(4000)
> DECLARE @.sql_arinv_debit_exec nvarchar(4000)
>
> SELECT @.sql_insert = 'insert into tmp_pl_acctinfo
> (deptid,branchid,reportid,smancode,jobno
,invno,iemtype,jobperiod ,
> TtlIncome, TtlExpenses, TtlNetProfit,doctype) '
> SELECT @.sql_sel_debit ='select Info.deptid,Info.branchid,"' + @.reportid +
> '" as reportid ,'''' as
> smancode,Info.JobNo,Info.invno,Info.iemtype,Info.jobperiod
> ,info.ttlbaseamt as ttlincome, 0 as ttlexpenses, 0 as ttlnetprofit,'
> SELECT @.sql_arinv_debit =' '''' as doctype from ' + @.dbcname_dest +
> '.arinvinfo Info where Info.validsw = 1 and Info.accttype = "DEBIT" '
> SELECT @.sql_where = ' and Info.jobperiod="' + @.jobperiod + '" and
> Info.branchid="' + @.branchid + '"'
> SELECT @.sql_arinv_debit_exec = @.sql_insert + @.sql_sel_debit +
> @.sql_arinv_debit + @.sql_where
>
> print @.sql_arinv_debit_exec
> EXEC (@.sql_arinv_debit_exec)
>|||Replace your double quotes with 2 single-quotes:
CREATE PROCEDURE dbo.sel_pl_acctjobperiod
@.jobperiod nvarchar(6),
@.reportid nvarchar(20),
@.BranchID nvarchar(10),
@.dbcname_dest varchar(20)
AS
SET NOCOUNT ON
DECLARE @.sql_insert varchar(4000)
DECLARE @.sql_sel_debit varchar(4000)
DECLARE @.sql_arinv_debit varchar(4000)
DECLARE @.sql_where varchar(4000)
DECLARE @.sql_arinv_debit_exec nvarchar(4000)
SELECT @.sql_insert = 'insert into tmp_pl_acctinfo
(deptid,branchid,reportid,smancode,jobno
,invno,iemtype,jobperiod ,
TtlIncome, TtlExpenses, TtlNetProfit,doctype) '
SELECT @.sql_sel_debit ='select Info.deptid,Info.branchid,''' + @.reportid +
'''
as reportid ,'''' as
smancode,Info.JobNo,Info.invno,Info.iemtype,Info.jobperiod ,info.ttlbaseamt
as ttlincome, 0 as ttlexpenses, 0 as ttlnetprofit,'
SELECT @.sql_arinv_debit =' '''' as doctype from ' + @.dbcname_dest +
'.arinvinfo Info where Info.validsw = 1 and Info.accttype = ''DEBIT'''
SELECT @.sql_where = ' and Info.jobperiod=''' + @.jobperiod + ''' and
Info.branchid=''' + @.branchid + ''''
SELECT @.sql_arinv_debit_exec = @.sql_insert + @.sql_sel_debit +
@.sql_arinv_debit + @.sql_where
print @.sql_arinv_debit_exec
go
That said, you should avoid using dynamic SQL. It's hard to debug, as you
can see.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com
.
"Agnes" <agnes@.dynamictech.com.hk> wrote in message
news:OuUg0lpQFHA.3144@.tk2msftngp13.phx.gbl...
I spend over 3 hrs to debug (The following store procedure, I always got
invalid column at The @.reportId) . I had used the same approach in other SP
.
and everything goes fine. BUT today, I don't know what's going on. Please
Help ~~~
EXEC sel_pl_acctjobperiod '200312','0001','HLSHK','DTS_ACCOUNT.DBO'
I got [invalid column name '0001',invalid column name '200312',invalid
column name 'HLSHK'.]
CREATE PROCEDURE dbo.sel_pl_acctjobperiod
@.jobperiod nvarchar(6),
@.reportid nvarchar(20),
@.BranchID nvarchar(10),
@.dbcname_dest varchar(20)
AS
SET NOCOUNT ON
DECLARE @.sql_insert varchar(4000)
DECLARE @.sql_sel_debit varchar(4000)
DECLARE @.sql_arinv_debit varchar(4000)
DECLARE @.sql_where varchar(4000)
DECLARE @.sql_arinv_debit_exec nvarchar(4000)
SELECT @.sql_insert = 'insert into tmp_pl_acctinfo
(deptid,branchid,reportid,smancode,jobno
,invno,iemtype,jobperiod ,
TtlIncome, TtlExpenses, TtlNetProfit,doctype) '
SELECT @.sql_sel_debit ='select Info.deptid,Info.branchid,"' + @.reportid + '"
as reportid ,'''' as
smancode,Info.JobNo,Info.invno,Info.iemtype,Info.jobperiod ,info.ttlbaseamt
as ttlincome, 0 as ttlexpenses, 0 as ttlnetprofit,'
SELECT @.sql_arinv_debit =' '''' as doctype from ' + @.dbcname_dest +
'.arinvinfo Info where Info.validsw = 1 and Info.accttype = "DEBIT" '
SELECT @.sql_where = ' and Info.jobperiod="' + @.jobperiod + '" and
Info.branchid="' + @.branchid + '"'
SELECT @.sql_arinv_debit_exec = @.sql_insert + @.sql_sel_debit +
@.sql_arinv_debit + @.sql_where
print @.sql_arinv_debit_exec
EXEC (@.sql_arinv_debit_exec)|||Is there some reason that you are using dynamic SQL and passing a table
name to a stored procedure? Is this an accounting system in which you
have no idea where the data is until run time? SQL injection and the
destruction of cohesion in the module would seem to tell us that this
is a bad programming style.
Are the job_period, report_id and branch_id really varying length
national characters? Most systems do not have encoding like that. Why
are you inviting bad data?
Next, the name of the table being loaded implies it is a temp table,
which would imply that you have a procedural design and not a
relational one. Are you actually building things step by step and
storing the intermediate results in working tables (aka "Cobol scratch
files in SQL disguise")?|||Thanks All.
I dont' know why my other SP didn't got such problem.
I never use SET QUOTED_IDENTIFIER OFF . before
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org>
'?:1113666233.068362.325440@.z14g2000cwz.googlegroups.com...
> Try SET QUOTED_IDENTIFIER OFF then drop and re-create the proc.
> Alternatively, change your double quotes (") into two single quotes
> (''), otherwise they may be read as column delimiters.
> The QUOTED_IDENTIFIER setting is saved with each proc so take notice of
> that setting whenever you use CREATE PROC.
> --
> David Portas
> SQL Server MVP
> --
>

Friday, February 24, 2012

Interview question stored procedure

Can anyone answer ths question please.

If your page is running slow what sould u check specifically with the store procedure. What is it tht you might think is giving a problem. or how would u go about see what making your stored procdure run slow.??

Give these articles a try:

http://www.sql-server-performance.com/tips/stored_procedures_p1.aspx

http://articles.techrepublic.com.com/5100-22-1045447.html

http://www.mssqlcity.com/Tips/stored_procedures_optimization.htm

|||

Absolute basics are check the execution plan, look for things like table scans which could be turned into index seeks by adding indexes, perhaps use the database engine tuning advisor.

Check the SQL for subselects where joins could be used instead, multiple predicates where an IN or BETWEEN clause would be better, unnecessary ORDER BY or DISTINCT instructions, possibly split up stored procedures which have the format

if inputvar = true

do this select

else

do that select

into separate sub-stored procedures for each select with the top level sp just doing the logic and then calling the appropriate sub proc (having multiple optional queries in the same proc means that the query plan may have to be re-generated each time, which costs performance)

Lots of other things you can do too, which I'm sure are mentioned in the above answer's links.