Could not determine data type of parameter $1

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
radub
Posts: 105
Joined: Sat 10 Jul 2010 18:46

Could not determine data type of parameter $1

Post by radub » Thu 30 Jan 2014 14:28

Hello,

Delphi 7
After upgrading to version 4.2.5, I encountered the error from title.
I have 2 tables in a master-detail, a provider and a clientdataset.
The script for the tables is:
  • CREATE TABLE dochd
    (
    docid integer NOT NULL,
    docno character varying(19) NOT NULL,
    docnoint character varying(25),
    docdate integer NOT NULL DEFAULT 0,
    CONSTRAINT pk_dochd PRIMARY KEY (docid)
    )
    WITH (
    OIDS=FALSE
    );
    ALTER TABLE dochd
    OWNER TO postgres;


    CREATE TABLE dynadoccodelnk
    (
    codeid integer NOT NULL,
    docid integer NOT NULL,
    codevalue character varying(50) NOT NULL,
    CONSTRAINT pk_dynadoccodelnk PRIMARY KEY (docid, codeid),
    CONSTRAINT fk_dynadocc_r_dynacod_dochd FOREIGN KEY (docid)
    REFERENCES dochd (docid) MATCH SIMPLE
    ON UPDATE RESTRICT ON DELETE RESTRICT
    )
    WITH (
    OIDS=FALSE
    );
    ALTER TABLE dynadoccodelnk
    OWNER TO postgres;

    CREATE INDEX r_dynacodelnk_doc_fk
    ON dynadoccodelnk
    USING btree
    (docid);
The provider has the OnDataRequest event:

Code: Select all

  PgTable1.FilterSQL:=Input;
  PgTable1.Open;
  Result:=DataSetProvider1.Data;
When activated, clientdataset is querying a null record (for initialization purposes):

Code: Select all

  with ClientDataSet1 do begin
    if Active then Close;
    Data:=DataRequest('DOCID=-1');
    Open;
  end;
The error occur after the next query:
  • SELECT * FROM dynadoccodelnk
    WHERE ( docid IS NULL AND :docid IS NULL)
Waiting for a solution.

Thank you,
Radu B.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Could not determine data type of parameter $1

Post by AlexP » Mon 03 Feb 2014 15:08

Hello,

To solve the problem, you should set the PgQuery1.Options.UseParamTypes property to True

radub
Posts: 105
Joined: Sat 10 Jul 2010 18:46

Re: Could not determine data type of parameter $1

Post by radub » Tue 04 Feb 2014 14:51

Yes, it works correctly.
Case closed.

Thank you,
Radu B.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Could not determine data type of parameter $1

Post by AlexP » Wed 05 Feb 2014 14:07

Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.

Post Reply