Previous Thread
Next Thread
Print Thread
Ashell 1673.0 to 1679.3 #32483 16 Apr 20 09:08 AM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
I've updated my local development Windows/Ashell from 1673.0 to 1679.3 and find my ASQL no longer connects to the Microsoft SQL server..
I only updated the ashw32.exe was there anything else?

It looks as if the programs is not going any further than this...
Code
    ! first init the lib
    cmdhdr.dbmsid = dbmsid
    xcall SQL, (SQLOP_INIT_LIB), cmdhdr
    if (cmdhdr.rc # 0 and cmdhdr.rc # SQLERR_ALREADYINITED) then
        if (SQLCONF_NOERRMSG) = 0 then
            xcall MSGBOX, "Unable to init library for DBMS type = "+cmdhdr.dbmsid &
                + chr(13) + Fn'SQL'ErrMsg$(cmdhdr), &
                "SQL Error", MBTN_OK, MBICON_STOP, MBMISC_TASKMODAL
        endif
        exitfunction
    endif



Same program under 1673.0 works fine, updated 1679.3 does not connect.

Last edited by Steve - Caliq; 16 Apr 20 09:08 AM.
Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32484 16 Apr 20 09:17 AM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
and a "possible" hint is cmdhdr.lastop = 65533
as here is a snippet of traces:

1679.3
HERE1
SQLOP_CONNECT: cmdhdr.rc,rcext = 9,0, info:0,0, state=, handle=0
cmdhdr.rc=9
cmdhdr.lastop = 65533
cmdhdr.handle = 0
cmdhdr.rc = 9 [Bad SQL.SBR opcode]
cmdhdr.rcext = 0
cmdhdr.info1: 0(?)
*ERROR* - No database connection established (Connect2)
Failed to connect to SQL Server



1673.0
HERE1
SQLOP_CONNECT: cmdhdr.rc,rcext = 0,0, info:0,0, state=, handle=0
cmdhdr.rc=0
HERE2
HERE3
connectstring=-host=maSQL -user= -pw= -db=
SQLOP_CONNECT: cmdhdr.rc,rcext = 0,5701, info:0,0, state=01000, handle=1
cmdhdr.rc=0
cmdhdr.lastop = 6
cmdhdr.handle = 1
cmdhdr.rc = 0 [OK]
cmdhdr.rcext = 5701
cmdhdr.sqlstate = 01000 (General Warning)
cmdhdr.info1: 0(n/a)
Connected to SQL Server Successfully

Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32486 16 Apr 20 02:51 PM
Joined: Sep 2002
Posts: 5,450
F
Frank Online Content
Member
Online Content
Member
F
Joined: Sep 2002
Posts: 5,450
Steve - i don't know anything about SQL but that lastop value is close to the b,2 limitation!

Wonder if its related to that somehow.

Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32488 16 Apr 20 03:17 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Looking on the bright side, good job on the beta testing!!!
The SQL interface does have a few quirks that may be unique among other xcalls, so it seems likely that the parameter passing revisions in 1679.2 and .3 need a bit more tuning. Stay tuned...

Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32489 16 Apr 20 03:20 PM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
Well i do test every possible Ashell command and feature after each update... crazy grin wink

Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32497 17 Apr 20 01:44 AM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Ok, you did such a good job on that last one, I'm going to give another chance with this update:

ash-6.5.1679.5-w32-upd.zip
ash-6.5.1679.5-w32c-upd.zip
ash65notes.txt

(Feel free to mutter "never trust a point zero, and be suspicious of a point three" under your breath) cool

Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32499 17 Apr 20 07:49 AM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
Point Five solved the issue and SQL now my TestSQL routine Connects, and executes as expected. Thank-you!

But, stand by for a "possible" Point Six as I have to dig further to work out why my MadicsSQL is erroring between reading a random file record and executing a SQL update/insert.... - "this bit is to be continued"

Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32501 17 Apr 20 08:39 AM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
After a little time digging ive located a SQL issue on executing, in this case a SQL Create Table so on experimenting on the most simplest table I could find of:

Execute SQL
Code
create table [Sales_Reps] 
([Rep_Number] varchar(3) NOT NULL PRIMARY KEY, [Name] varchar(26), [Madics_RecNo] integer, [DVertoUpdate] datetime)


Errors with
Code
          [Rep_Number] varchar(3)
          [Name] varchar(26)
          [Madics_RecNo] integer
          [DVertoUpdate] datetime
              *ERROR* - Create Table Failed: create table [Sales_Reps] .([Rep_Number] varchar(3) NOT NULL PRIMARY KEY, [Name] varchar(26), [Madics_RecNo] integer, [DVertoUpdate] datetime
                cmdhdr.lastop = 9
                cmdhdr.handle = 1
                cmdhdr.rc = 2 [DBMS error - see cmdhdr.rcext]
                cmdhdr.rcext = 102
                *ERROR* - [unknown value]
                cmdhdr.sqlstate = 42000 (Syntax error or access violation)
                *ERROR* - Retrieving DBMS error message for #102
                *ERROR* -  DMBS error msg: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'datetime'.
                cmdhdr.info1: 0(n/a)
            1: Error occurred creating table Sales_Reps for SALMAN- create table [Sales_Reps] .([Rep_Number] varchar(3) NOT NULL PRIMARY KEY, [Name] varchar(26), [Madics_RecNo] integer, [DVertoUpdate] datetime)


Out of paranoia I did also try it in Microsofts sql management studio and thats ok.
Also Ashell 1673.0 executes this fine.


I first thought it was related to xcall SQL,SQLOP_QUERY,cmdhdr,querystring but this works for a drop table, unless its related to querystring length as its mapped as MAP1 querystring,s,0 (a lot are mapped that way)


Code snippets below if it helps, Im happy go digging further but thought something your end may spark to mind first...


Create Table Function Errors
Code
FUNCTION FN'SQLX'CREATE(querystring as s0) AS F6
! OUT: 0=Failed else 1=Created
ON ERROR GOTO LOCAL'TRAP
++PRAGMA AUTO_EXTERN "TRUE"
	FN'SQLX'CREATE=0
	CALL FN'SQLX'LOG("Create Table, Query: "+querystring,"D")
	xcall SQL,SQLOP_QUERY,cmdhdr,querystring
	if cmdhdr.rc = 0 then
	   FN'SQLX'CREATE=1
	else
	   CALL FN'SQLX'LOG("Create Table Failed: "+querystring,"E")
	   call SQL'Show'Status(cmdhdr)
	endif
	cmdhdr.opflags = SQL_CLOSE
	xcall SQL,SQLOP_FREE_RESULT,cmdhdr
	EXITFUNCTION
LOCAL'TRAP:
	CALL FN'FUNCTION'ERROR'TRAP$(.LAST_ROUTINE,ERR(0),ERR(1),ERR(2),ERR(8))
	RESUME ENDFUNCTION WITH_ERROR 99
ENDFUNCTION


Drop Function - Drops OK
Code
FUNCTION FN'SQLX'DROP'TABLE(tablename as s0) AS F6
! IN: Table Name
! OUT: 0=Failed, 1=Dropped, 2=Did not exists
ON ERROR GOTO LOCAL'TRAP
++PRAGMA AUTO_EXTERN "TRUE"
MAP1 querystring,s,0
	FN'SQLX'DROP'TABLE=0
	cmdhdr.opflags = 0
	querystring = "drop table "+tablename
	CALL FN'SQLX'LOG("Drop Table, Query: "+querystring,"D")
	xcall SQL,SQLOP_QUERY,cmdhdr,querystring
	if cmdhdr.rc = 0 then
	   FN'SQLX'DROP'TABLE=1
	elseif cmdhdr.rc # 0 and cmdhdr.sqlstate = "42S02" then
	   FN'SQLX'DROP'TABLE=2
	else
	  FN'SQLX'DROP'TABLE=0
	  call SQL'Show'Status(cmdhdr)
	endif
	cmdhdr.opflags = SQL_CLOSE
	xcall SQL,SQLOP_FREE_RESULT,cmdhdr
	EXITFUNCTION
LOCAL'TRAP:
	CALL FN'FUNCTION'ERROR'TRAP$(.LAST_ROUTINE,ERR(0),ERR(1),ERR(2),ERR(8))
	RESUME ENDFUNCTION WITH_ERROR 99
ENDFUNCTION








Attached Files 2020-04-17_09-22-59.png
Last edited by Steve - Caliq; 17 Apr 20 08:43 AM.
Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32502 17 Apr 20 08:55 AM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
UPDATE As I could not help myself and leave it alone..

If I changed
Code
FUNCTION FN'SQLX'CREATE(querystring as s0) AS F6

TO
Code
FUNCTION FN'SQLX'CREATE(querystring as s512) AS F6


and
Code
	MAP1 LOCAL'SQL,S,0
        IF FN'SQLX'CREATE(LOCAL'SQL)=0 THEN

TO
Code
	MAP1 LOCAL'SQL,S,512
        IF FN'SQLX'CREATE(LOCAL'SQL)=0 THEN


Then it works... a hint: s,0


Last edited by Steve - Caliq; 17 Apr 20 08:56 AM.
Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32504 17 Apr 20 04:30 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Hmmm...., it certainly does appear that there is some lingering issue with dynamic strings in ASQL. But based on the error message, I suspect that there's some kind of premature termination issue. Can you try explicitly adding a space to the end of your create table statement?

Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32506 17 Apr 20 07:20 PM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
Your suspicion is correct and adding a space to the end of the SQL command also solves the issue.
querystring=querystring+space(1)

EG.

Code
FUNCTION FN'SQLX'CREATE(querystring as s0) AS F6
! OUT: 0=Failed else 1=Created
ON ERROR GOTO LOCAL'TRAP
++PRAGMA AUTO_EXTERN "TRUE"
	FN'SQLX'CREATE=0

	querystring=querystring+space(1)   ! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

	CALL FN'SQLX'LOG("Create Table, Query: "+querystring,"D")
	xcall SQL,SQLOP_QUERY,cmdhdr,querystring
	if cmdhdr.rc = 0 then
	   FN'SQLX'CREATE=1
	else
	   CALL FN'SQLX'LOG("Create Table Failed: "+querystring,"E")
	   call SQL'Show'Status(cmdhdr)
	endif
	cmdhdr.opflags = SQL_CLOSE
	xcall SQL,SQLOP_FREE_RESULT,cmdhdr
	EXITFUNCTION
LOCAL'TRAP:
	CALL FN'FUNCTION'ERROR'TRAP$(.LAST_ROUTINE,ERR(0),ERR(1),ERR(2),ERR(8))
	RESUME ENDFUNCTION WITH_ERROR 99
ENDFUNCTION

Last edited by Steve - Caliq; 17 Apr 20 07:20 PM.
Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32507 17 Apr 20 09:21 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Thanks for confirming that - it certainly appears that there is an "off-by-one" error in the receiving of dynamic strings in SQL.SBR, probably requiring an update to the libashodbc and libashmysql libraries. Fortunately spaces aren't significant in SQL queries, so the workaround, while ridiculous, is entirely harmless.

Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32508 17 Apr 20 10:37 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
Ok, I think this problem was limited to the SQLOP_QUERY function in the ODBC version of the ASQL library. It has probably been there a long time, but it surfaces in only limited situations, and only when the querystring was passed as an argument to a function that then did the XCALL SQL. (The details have to do with efforts to maintain negative substring interoperability between dynamic S and X variables in parameter passing, which affects whether there is a trailing null or not. The reason why it only affected this call is that it is the one ASQL call where the length of the string argument could literally be thousands of characters. So instead of making a local copy like most XCALLs would do, it just forced a trailing null on the end and used the querystring as is. Which would be fine except in when it wasn't.) Here's the patched library module:

libashodbc-1.4.113-w32.zip

(Or just add the trailing space for the SQLOP_QUERY call.)

Incidentally, the MYSQL version of the library did not have this problem.

Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32509 18 Apr 20 11:13 AM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
Updated libashodbc.dll (version 1.4.113.0) and that solved the issue, Saves me tweaking the programs. Thanks! smile
Now I have the rest of the weekend to catch up on a TV Series someone called Frank recommend. grin

Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32510 18 Apr 20 04:39 PM
Joined: Jun 2001
Posts: 11,645
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,645
If I had known about your weekend backup plan in advance, I could have spared you by delaying the patch!

Re: Ashell 1673.0 to 1679.3 [Re: Steve - Caliq] #32511 18 Apr 20 04:44 PM
Joined: Sep 2003
Posts: 4,135
Steve - Caliq Offline OP
Member
OP Offline
Member
Joined: Sep 2003
Posts: 4,135
Well a variation of the day is good or it’s merging all into the same 🙂

Last edited by Steve - Caliq; 18 Apr 20 04:56 PM.

Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3