Subject IN using a string from another table field
Author venussoftop
Hi all

I have tried the following query
SELECT tSaleInvoice.*
FROM tSaleInvoice
WHERE tSaleInvoice.iID IN
(SELECT tSaleInvoiceCvrLtr.cSaleInvIDs
FROM tSaleInvoiceCvrLtr
WHERE tSaleInvoiceCvrLtr.iID = 993)

The idea is to pull out records from tSaleInvoice on it's PK iID. The reference list of iIDs are stored as a comma separated list in a character field tSaleInvoiceCvrLtr.cSaleInvID in this case - "24315,24371 "

I get the following error when I run the query and no results are returned
---------------------------
An IBPP error occurred.
---------------------------
*** IBPP::SQLException ***
Context: Statement::Fetch
Message: isc_dsql_fetch failed.

SQL Message : -413
Overflow occurred during data type conversion.

Engine Code : 335544334
Engine Message :
conversion error from string "24315,24371 "

---------------------------
OK
---------------------------

This is it's log
Starting transaction...
Preparing query: SELECT tSaleInvoice.*
FROM tSaleInvoice
WHERE tSaleInvoice.iID IN
(SELECT tSaleInvoiceCvrLtr.cSaleInvIDs
FROM tSaleInvoiceCvrLtr
WHERE tSaleInvoiceCvrLtr.iID = 993)
Prepare time: 0.016s
Field #01: TSALEINVOICE.IID Alias:IID Type:INTEGER
Field #02: TSALEINVOICE.IPID Alias:IPID Type:INTEGER
Field #03: TSALEINVOICE.CBK Alias:CBK Type:STRING(5)
Field #04: TSALEINVOICE.INO Alias:INO Type:INTEGER
Field #05: TSALEINVOICE.TDT Alias:TDT Type:TIMESTAMP
Field #06: TSALEINVOICE.TREMOVALDT Alias:TREMOVALDT Type:TIMESTAMP
Field #07: TSALEINVOICE.CDOCTYPE Alias:CDOCTYPE Type:STRING(15)
Field #08: TSALEINVOICE.IBUYERID Alias:IBUYERID Type:INTEGER
Field #09: TSALEINVOICE.IREPRESENTATIVEID Alias:IREPRESENTATIVEID Type:INTEGER
Field #10: TSALEINVOICE.IAREAMANAGERID Alias:IAREAMANAGERID Type:INTEGER
Field #11: TSALEINVOICE.IREGIONALMANAGERID Alias:IREGIONALMANAGERID Type:INTEGER
Field #12: TSALEINVOICE.IZONALMANAGERID Alias:IZONALMANAGERID Type:INTEGER
Field #13: TSALEINVOICE.ITRANSPORTERID Alias:ITRANSPORTERID Type:INTEGER
Field #14: TSALEINVOICE.CLRNO Alias:CLRNO Type:STRING(15)
Field #15: TSALEINVOICE.DLRDT Alias:DLRDT Type:DATE
Field #16: TSALEINVOICE.MBANK Alias:MBANK Type:BLOB SUB_TYPE 0
Field #17: TSALEINVOICE.BPACKQTY Alias:BPACKQTY Type:DOUBLE PRECISION
Field #18: TSALEINVOICE.BTOTALWEIGHT Alias:BTOTALWEIGHT Type:DOUBLE PRECISION
Field #19: TSALEINVOICE.IRECTYPE Alias:IRECTYPE Type:SMALLINT
Field #20: TSALEINVOICE.CFORMSRNO Alias:CFORMSRNO Type:STRING(15)
Field #21: TSALEINVOICE.CDELIVNAME Alias:CDELIVNAME Type:STRING(50)
Field #22: TSALEINVOICE.MDELIVADDRESS Alias:MDELIVADDRESS Type:BLOB SUB_TYPE 0
Field #23: TSALEINVOICE.CDOCBILLNO Alias:CDOCBILLNO Type:STRING(15)
Field #24: TSALEINVOICE.DDOCBILLDT Alias:DDOCBILLDT Type:DATE
Field #25: TSALEINVOICE.IDOCFOOTERID Alias:IDOCFOOTERID Type:INTEGER
Field #26: TSALEINVOICE.CVATINVTYPE Alias:CVATINVTYPE Type:STRING(10)
PLAN (TSALEINVOICECVRLTR INDEX (PK_TSALEINVOICECVRLTR_IID))
PLAN (TSALEINVOICE NATURAL)


Executing...
Done.
18 fetches, 0 marks, 0 reads, 0 writes.
0 inserts, 0 updates, 0 deletes, 3 index, 1 seq.
Delta memory: 1944 bytes.
Total execution time: 1.328s
Script execution finished.

I have tried to (SELECT TRIM(tSaleInvoiceCvrLtr.cSaleInvIDs)... but no change

Please advise.

Kind regards
Bhavbhuti