Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Hackers > ecpg issue - no...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 9295 of 9685
Post > Topic >>

ecpg issue - not sending datatype to the backend

by mike.aubury@[EMAIL PROTECTED] (Mike Aubury) May 2, 2008 at 02:28 PM

This is a little complex to explain - so its probably better with an
example..

I don't know if theres some inbuilt function to tell you what datatype a
value 
is - so 'kludged' this together : 


  CREATE OR REPLACE FUNCTION rval_type(m date) RETURNS text AS $$
  BEGIN
                RETURN 'it was a date';
  END;
  $$ LANGUAGE plpgsql;

  CREATE OR REPLACE FUNCTION rval_type(m text) RETURNS text AS $$
  BEGIN
                RETURN 'it was a text';
  END;
  $$ LANGUAGE plpgsql;

  CREATE OR REPLACE FUNCTION rval_type(m int) RETURNS text AS $$
  BEGIN
                RETURN 'it was a int';
  END;
  $$ LANGUAGE plpgsql;




Now - if I have a cpc containing : 

   main() {
   exec sql begin declare section;
   date d;
   int i;
   char a[200];
   char lv_out[200];
   exec sql end declare section;

   exec sql database test1;

   d=0;
   i=0;
   strcpy(a,"-");
   memset(lv_out,0,sizeof(lv_out));


   exec sql select rval_type(:d) into :lv_out;
   if (sqlca.sqlcode<0) sqlprint();
   else printf("%s\n",lv_out);


   exec sql select rval_type(:i) into :lv_out;
   if (sqlca.sqlcode<0) sqlprint();
   else printf("%s\n",lv_out);

   exec sql select rval_type(:a) into :lv_out;
   if (sqlca.sqlcode<0) sqlprint();
   else printf("%s\n",lv_out);

   }



You can see I'm passing in a date, then an integer, then a character
string. 
However - when you run the code you get : 

it was a text
it was a text
it was a text



This to me looks 'wrong', especially when previous versions of ecpg
(<8.0?) 
gave the correct :

it was a date
it was a int
it was a text




Any thoughts ? 
(This is manifesting itself as arithmetic errors when I'm using dates in
my 
application)





-- 
Mike Aubury

Aubit Computing Ltd is registered in England and Wales, Number: 3112827
Registered Address : Clayton House,59 Piccadilly,Manchester,M1 2AQ



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
 




 2 Posts in Topic:
ecpg issue - not sending datatype to the backend
mike.aubury@[EMAIL PROTEC  2008-05-02 14:28:31 
Re: ecpg issue - not sending datatype to the backend
meskes@[EMAIL PROTECTED]   2008-05-02 17:01:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Tue Jul 8 23:54:25 CDT 2008.