AboutMelvin Davidson Expertise Can answer -SQL advise, Generic information on database design and Ingres tools & utilities. I will not advise on how to restore / resolve corrupted databases. In addition, I can also answer questions regarding PostgreSQL & Slony, until such time as a separate category is added for them.
Experience 8 years as Technical Support Specialist for Ingres database as a CA employee.
Publications Interface Age Magazine (no longer published). Ingres Technical documents.
Education/Credentials B.S. Computer Technology - N.Y.I.T Old Westbury, NY
Question Hello Melvin,
I have a form in openroad that is basically a list of check boxes that correspond to database tables. In my problem the user selects XA and HA from the form. (There are about 40 tables in all so I only show a few in the code below !!)
The Create_Export_TextFile uses 2 case statements controlled by the tablenames chosen by the user (say XA and HA in this case). The first case sets up the vstring command and the second case uses the vstring in the copy table setup. My problem is when processing takes place for the HA table in the first case statement I ONLY WANT THOSE RECORDS IN 'HA' that correspond to records in 'HG' that have the SAME code and ref number, i.e. the WHERE caluse - I cannot get the WHERE clause to work!!!. I keep getting and error shown in the error log below. I hope you can help.
Best Wishes
Laurence
procedure create_export_textfile(strChosen = Array of StringObject default null, EiacCode = VarChar(10) not null) =
declare
RETURN = i4 not null, value '1'
struserid = varchar(30) not null, value 'appdev9a2', BYREF
Query text:
select distinct eiacodxa as enumtext, rowid as introwid from xa order by 1
Query Send Time: Fri Jun 13 09:56:51 2008
Query Response Time: Fri Jun 13 09:56:51 2008
Response CPU Time: 6479
Qry End CPU Time: 6479
------------------------------------------------
Call 4GL procedure 'check_db'
Query text:
commit
Query Send Time: Fri Jun 13 09:56:51 2008
Query Response Time: Fri Jun 13 09:56:51 2008
Qry End CPU Time: 6479
------------------------------------------------
Call 4GL procedure 'check_commit'
Return from 'check_commit' to 'check_db'
RETURN = i4 not null, value '0'
Return from 'check_db' to 'dammyall'
RETURN = i4 not null, value '30'
Query text:
select eiacodxa as streiacodxa from xa where EXISTS(select * from xc where xa
.eiacodxa=xc.eiacodxa and uppercase(xc.lcntypxb)='P') order by streiacodxa
Query Send Time: Fri Jun 13 09:56:51 2008
Query Response Time: Fri Jun 13 09:56:52 2008
Response CPU Time: 6479
Qry End CPU Time: 6479
------------------------------------------------
Event: SetValue on 'lbxeiacodxa' in frame 'dammyall'
Event Handled
Event: Click on 'pbtselectsubtables' in frame 'dammyall'
Event Handled
Event: POPUP in frame 'dammyall'
Event Handled
Event: POPUP in frame 'dammyall'
Call 4GL procedure 'create_export_textfile'
eiaccode = varchar(10) not null, value 'PUMAMK1'
strchosen = Array of stringobject
Query text:
execute immediate DECLARE GLOBAL TEMPORARY TABLE SESSION.temp AS SELECT 'XA '
AS fromTable, t.* FROM XA t WHERE eiacodxa = 'PUMAMK1 ' ON C
OMMIT PRESERVE ROWS WITH NORECOVERY
Query Send Time: Fri Jun 13 09:57:15 2008
Query Response Time: Fri Jun 13 09:57:15 2008
Qry End CPU Time: 8802
------------------------------------------------
Query text:
execute immediate COPY TABLE SESSION.temp (
fromTable .= c0,
eiacodxa..= c0,
lcnstrxa..= c0,
addltmxa..= c2,
ctdltmxa..= c3,
contnoxa..= c19,
csreorxa..= c0,
csprrqxa..= c0,
demilcxa..= c2,
discntxa..= c0,
essalvxa..= c2,
hlcspcxa..= c2,
intbinxa..= c4,
incatcxa..= c4,
intratxa..= c0,
invstgxa..= c0,
lodfacxa..= c0,
wsoplvxa..= c2,
oprlifxa..= c2,
prstovxa..= c2,
prstomxa..= c2,
profacxa..= c0,
rcbincxa..= c4,
rccatcxa..= c4,
restcrxa..= c2,
saflvlxa..= c2,
secsfcxa..= c0,
trncstxa..= c0,
wstyaqxa..= c0,
tsscodxa..= c0, sp=d1)
INTO 'c:\ExportTemp\xa.txt'
Query Send Time: Fri Jun 13 09:57:15 2008
Query text:
execute immediate COPY TABLE SESSION.temp (
fromTable .= c0,
eiacodxa..= c0,
lcnstrxa..= c0,
addltmxa..= c2,
ctdltmxa..= c3,
contnoxa..= c19,
csreorxa..= c0,
csprrqxa..= c0,
demilcxa..= c2,
discntxa..= c0,
essalvxa..= c2,
hlcspcxa..= c2,
intbinxa..= c4,
incatcxa..= c4,
intratxa..= c0,
invstgxa..= c0,
lodfacxa..= c0,
wsoplvxa..= c2,
oprlifxa..= c2,
prstovxa..= c2,
prstomxa..= c2,
profacxa..= c0,
rcbincxa..= c4,
rccatcxa..= c4,
restcrxa..= c2,
saflvlxa..= c2,
secsfcxa..= c0,
trncstxa..= c0,
wstyaqxa..= c0,
tsscodxa..= c0, sp=d1)
INTO 'c:\ExportTemp\xa.txt'
Query Send Time: Fri Jun 13 09:57:15 2008
Query Response Time: Fri Jun 13 09:57:16 2008
Qry End CPU Time: 8802
------------------------------------------------
Query text:
drop table session.temp
Query Send Time: Fri Jun 13 09:57:16 2008
Query Response Time: Fri Jun 13 09:57:17 2008
Qry End CPU Time: 8802
------------------------------------------------
Query text:
execute immediate DECLARE GLOBAL TEMPORARY TABLE SESSION.temp AS SELECT 'HA '
AS fromTable, t* FROM HA t WHERE ha.cagecdxh = hg.cagecdxh and
ha.refnumha = hg.refnumha ON COMMIT PRESERVE ROWS WITH NORECOVERY
Query Send Time: Fri Jun 13 09:57:17 2008
E_US0F06 line 1, Syntax error on 'FROM'. The correct syntax is:
DECLARE GLOBAL TEMPORARY TABLE tablename
(columnname format [null_default_clause] {, ... })
ON COMMIT PRESERVE ROWS
WITH NORECOVERY [,with_clause]
DECLARE GLOBAL TEMPORARY TABLE tablename
[(columnname {, ... })]
AS subselect
ON COMMIT PRESERVE ROWS
WITH NORECOVERY [,with_clause]
(Fri Jun 13 09:57:18 2008)
E_US0845 Table 'temp' does not exist or is not owned by you.
(Fri Jun 13 09:57:27 2008)
Query Response Time: Fri Jun 13 09:57:27 2008
Qry End CPU Time: 8812
------------------------------------------------
Query text:
drop table session.temp
Query Send Time: Fri Jun 13 09:58:12 2008
E_US0ACC DROP: 'temp' is not owned by $Sess00000004.
(Fri Jun 13 09:58:13 2008)
Query Response Time: Fri Jun 13 09:58:19 2008
Qry End CPU Time: 10064
------------------------------------------------
Return from 'create_export_textfile' to 'dammyall'
Event Handled
Answer Laurence,
The error that occurs is:
E_US0F06 line 1, Syntax error on 'FROM'. The correct syntax is:
DECLARE GLOBAL TEMPORARY TABLE tablename
(columnname format [null_default_clause] {, ... })
ON COMMIT PRESERVE ROWS
WITH NORECOVERY [,with_clause]
and has nothing to do with the WHERE clause. It does, however,
prevent the GTT from being created.
It is stating that the syntax for creating GLOBAL TEMP TABLE is incorrect.
Your statement basically is
'AS SELECT ''' :nameOfTable ''' AS fromTable cagecdxh, ......
However, this roughly translates to
AS SELECT some_table_name AS fromTable cagecdxh, ......
The occurrence of a second alias after fromTable is what appears to be
the problem.
It looks like you have omitted a comma and it should be
'AS SELECT ''' :nameOfTable ''' AS fromTable, cagecdxh, ......
instead.
Please correct the syntax, and your code should work. I would also review the other CASE statements for similar errors.