#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2016
    Posts
    1
    Rep Power
    0

    External Function Usage


    Hello All,

    I'm trying to make use of an external function named SpectrumToString according to the script below. I'm getting an error that says "multiple rows in singleton select", but I don't completely understand why. I'm thinking I should be getting a single row and 1 blob field from the first select - which is then loaded in to :vblob. Then I'm trying to pass this variable along to the function.

    Can anyone shed some light on where I'm going wrong here?

    Thanks.
    Greg

    Code:
    DROP EXTERNAL FUNCTION    SPECTRUMTOSTRING;
    DECLARE EXTERNAL FUNCTION SPECTRUMTOSTRING
      INTEGER,
      INTEGER,
      BLOB,
      INTEGER,
      CSTRING(1),
      DOUBLE PRECISION,
      DOUBLE precision
      RETURNS CSTRING(32000) free_it
      ENTRY_POINT 'SpectrumToString' MODULE_NAME 'FHR.dll';
     
     commit; 
                                                                                    
    set term ^ ;
    EXECUTE BLOCK 
    AS
       DECLARE VARIABLE vblob BLOB;
       DECLARE VARIABLE outputString VARCHAR(32000);
       begin
         SELECT  first 1 spectrum_data from sp_fft_data  into :vblob ;
        select SpectrumToString(0, 5, :vblob, 256, 'N', 25.0, 50.0) from rdb$FUNCTIONS INTO :outputString;
         END^
    set term  ;^
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2006
    Location
    Plovdiv. Bulgaria
    Posts
    242
    Rep Power
    17
    There are many records in rdb$FUNCTIONS, so the select statement returns many rows for this query. You have two options - use select first 1 with rdb$FUNCTIONS or use a query against rdb$DATABASE. RDB$DATABASE contains only one record and it's the "default" table for this kind of selects.
    Last edited by mIRCata; February 18th, 2016 at 10:39 AM.

IMN logo majestic logo threadwatch logo seochat tools logo