Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paradox to Sybase SQL query problem.

Status
Not open for further replies.

beanbrain

Programmer
Dec 31, 2001
170
I am using both Paradox 7.0 and Paradox 10.0 on a Windows NT 4.0 network. Lately I was asked to provide data to Sybase Adaptive Server AS 12.5. I perform this connection via an ODBC link which Paradox sees as an alias.

The problem is Paradox 7.0 runs this beautifully without error and Paradox 10.0 cannot.

Typically I get "An error was triggered in the executeSQL method on an object of SQL type." This is followed by "Parameter not set in query string." These two errors occur right at the executeSQL statement.

Of course I need this to run in Paradox 10 along with all the other automated processes that have been created.

Here is the script code that is executed. Note that the SQL calls are stored as SQL statements in Paradox.

[tt]
method run(var eventInfo Event)
var
q Query
s String
ar Array[] String
tbl Table
tc tCursor
dDb, myDb Database
s1 SQL
dbParmsDA DynArray[] AnyType
firstSes,
secondSes Session
endVar

disablePreviousError(Yes)
errorClear()

message("Updating SPersonnel")

tbl.attach(":busoff:SPersonnel")
if not tbl.empty() then
message("Unable to empty SPersonnel table.")
return
endIf
tbl.unAttach()

q = Query
ANSWER: :pRIV:ANSWER.DB

SPersonnel.db | Last Name | First Name | SSN | Employee ID |
Insert | _join1 | _join2 | _join3 | _join4 |

SPersonnel.db | ISI Employment Start Date | ISI Employment End Date | Email |
| _join5 | _join6 | _join8 |

SPersonnel.db | Supervisor | Division Number | Staff Category |
| _join7 | _join9 | _join10 |

SPersonnel.db | Visitor Number |
| blank |

:personnel:Entity.db | EmplNo | FirstName |
| _join4, not X.., not N.., not V.. | _join2 |

:personnel:Entity.db | LastName | EmpStart | EmpTerm |
| _join1 | _join5 | _join6, blank or >=7/1/2002 |

:personnel:Entity.db | SSN | StaffCat | Division | PrjLdr | Email |
| _join3 | _join10 | _join9 | _join7 | _join8 |

EndQuery
if not q.executeQBE() then
message("Unable to insert Records to SPersonnel.")
return
endIf

q = Query
ANSWER: :pRIV:ANSWER.DB

SPersonnel.db | Last Name | First Name | SSN | Employee ID |
Insert | _join1 | _join2 | _join3 | blank |

SPersonnel.db | ISI Employment Start Date | ISI Employment End Date | Email |
| _join5 | _join6 | _join8 |

SPersonnel.db | Supervisor | Division Number | Staff Category |
| _join7 | _join9 | _join10 |

SPersonnel.db | Visitor Number |
| _join4 |

:personnel:Entity.db | EmplNo | FirstName |
| _join4, V.., not X.., not N.. | _join2 |

:personnel:Entity.db | LastName | EmpStart | EmpTerm |
| _join1 | _join5 | _join6, blank or >=7/1/2002 |

:personnel:Entity.db | SSN | StaffCat | Division | PrjLdr | Email |
| _join3 | _join10 | _join9 | _join7 | _join8 |

EndQuery
if not q.executeQBE() then
message("Unable to insert Records to SPersonnel.")
return
endIf

message("Updating SAccount")

tbl.attach(":busoff:SAccount")
if not tbl.empty() then
message("Unable to empty SAccount table.")
return
endIf
tbl.unAttach()
; populate the intermediate table for Accounts
q = Query
ANSWER: :pRIV:ANSWER.DB

SAccount.DB | Account Number | Account Name | Burden Center | Award Number |
Insert | _join1 | _join2 | _join3 | _join4 |

SAccount.DB | Account Status ID | Account Start Date | Account End Date |
| _join5 | _join6 | _join7 |

SAccount.DB | Account Manager |
| _join8 |

:Contract:Chart.DB | AcctNo | AcctName | Location | StrtDate |
| _join1 | _join2 | _join3 | _join6 |

:Contract:Chart.DB | EndDate | ProjLdr | AwardNo | AcctStatus |
| _join7, >6/30/2002 | _join8 | _join4 | _join5 |

EndQuery
if not q.executeQBE() then
message("Unable to insert Records to SAccount.")
return
endIf

; using tCursor scan SAccount for multiple ProjMgr names in field and truncate at "/".
message("Reducing Project Manager name.")
tc.open(":busoff:SAccount.db")
tc.edit()
scan tc :
s = tc."Account Manager"
s.breakApart(ar,"/")
tc."Account Manager" = ar[1]
endScan
tc.endEdit()
tc.close()

if not exportASCIIVar ( "SPersonnel.db", "SPersonnel.txt", ",", "\"", False, True ) then
message("Error Export","Unable to Export SPersonnel.txt.")
return
endIf
if not exportASCIIVar ( "SAccount.db", "SAccount.txt", ",", "\"", False, True ) then
message("Error Exporting","Unable to Export SAccount.txt.")
return
endIf

message("Writing to SyBase P_Account.")

removeAllPasswords()
firstSes.open()
;firstSes.addPassword("Paradox")
dbParmsDA["OPEN MODE"] = "READ/WRITE"
dbParmsDA["Password"] = "Paradox"
dbParmsDA["SQLPASSTHRU"] = "SHARED AUTOCOMMIT"
if not dDb.open(":bo_personnel:",firstSes, dbParmsDA) then ; (remote is an alias defined elsewhere)
message("Unable to connect to :bo_personnel: database.")
return
endIf

message("Writing to SQL SyBase P_Personnel.")
s1.readFromFile("SPersonnel.sql")
if not executeSQL(dDb, s1) then
message("Unable to run SPersonnel SQL query.")
firstSes.close()
return
endIf

message("Writing to SQL SyBase P_Account.")
s1.readFromFile("SAccount.sql")
if not executeSQL(dDb, s1) then
message("Unable to run SAccount SQL query.")
firstSes.close()
return
endIf

dDb.close()
message("Done...")
exit()
tc.open("LastMsgDate.db")
tc.edit()
tc."LastDirUpdateDate" = today()
tc.endEdit()
tc.close()

endMethod
[/tt]

Finally I can also post the SQL statements called above if this is helpful.

Thanks in advance for any help you can provide.
 
Have you checked to make sure the s1 variable contains the information from the file? There is no error trapping there. maybe you should do an IF / NOT when you read it in to make sure it is getting assigned.

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
So Mac. Why would a readFromFile fail if I'm able to open the SQL statement and execute it from within Paradox? Also why would it work in Paradox 7.0 and not 10.0?

Also I did as you suggest and place an if not in front of the readFromFile like this.

if not s1.readFromFile("SPersonnel.sql") then
message("Unable to read from SPersonnel.sql")
return
endIf

The program breezed right past that and executed in Paradox 7.0. Still having problems with P10.
 
The reason I suggested it was that, since you are using two versions of Pdox, there might have been an issue with aliases or working directories. The readFromfile statement appears to try and locate SPersonnel.sql in the working directory only.

It was just a thought since I did not see anything else wrong.

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Mac:

I'll try putting the alias in front of the file name*. The thing is the script and sql queries are all located in the :work: area.

Also, when I execute this in Paradox 10.0 I get the messgage "Parameter not set in Query String." This happens at the point of read but it does not fire the
Code:
if/not
. Strange!

It's almost as if Paradox 10.0 expects some other setting to be addressed either withing the SQL statement or when I initially open the db.

* This didn't make any difference.
 
Well, I don't do much SQL so I know I'm not much help.

However, I would still examine the contents of the s1 variable just to be absolutely sure everything is being read in properly.

I believe the error message is the same you'd get if you have an unassigned variable in a QBE statement. I don't know if the same holds true for SQL statements.

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Thanks Mac. I'll keep looking. If I figure out I'll post it here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top