pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Question on NpgsqlParameter object
3+ messages / 3 participants
[nested] [flat]

* Question on NpgsqlParameter object
@ 2007-05-28 17:36 Oliveiros Cristina <oliveiros.cristina@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Oliveiros Cristina @ 2007-05-28 17:36 UTC (permalink / raw)
  To: pgsql-interfaces

Hi, List.

I am not 100% sure if this is the right list, if it isnt please kindly
re-direct me to the proper list.

I would like to see NpgsqlCommand.CommandText value after parameter
substitution. I have a query that is not behaving correctly and I suspect
strongly that  it has to do with parameters getting instantiated in
unexpected ways.

How can I have access to query SQL text after parameter substitution ?

I try to look at CommandText Property immediately before calling
ExecuteReader() method, but I get the text with all parameters
unsubstituted.

Any Help/Comments/Advices deeply appreciated

Thanks in advance

Cheers,
Oliveiros

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Question on NpgsqlParameter object
@ 2007-05-29 10:26 Oliveiros Cristina <oliveiros.cristina@marktest.pt>
  2007-05-30 15:23 ` Re: Question on NpgsqlParameter object Francisco Figueiredo Jr. <fxjrlists@yahoo.com.br>
  0 siblings, 1 reply; 3+ messages in thread

From: Oliveiros Cristina @ 2007-05-29 10:26 UTC (permalink / raw)
  To: Francisco Figueiredo Jr. <fxjrlists@yahoo.com.br>; Oliveiros Cristina <oliveiros.cristina@gmail.com>; pgsql-interfaces

Howdy, Francisco.

Thank you for your fast reply.
I'm gonna check this out.
Actually I wasn't aware of the existence of the Npgsql mailing list, even though I use it exclusively to access the back end !


But, maybe if I am a little more specific you can tell me what I am (potentially) doing wrong.

Can I use parameters to substitute a whole condition? 
For ex, is it possible to have a query like this?

SELECT *
FROM t_tabela
WHERE @condicao 

?

My problems started yesterday when I started using parameters in this way. 
Before I've just used it in situations like this :
SELECT *
FROM t_tabela
WHERE variacao >= @percentagem

and it always worked without the smallest problem. 
I wonder if it is legal to use NpgsqlParameters in the way I do now...


Melhores cumprimentos,

Oliveiros

  ----- Original Message ----- 
  From: Francisco Figueiredo Jr. 
  To: Oliveiros Cristina ; pgsql-interfaces@postgresql.org 
  Sent: Monday, May 28, 2007 11:32 PM
  Subject: Res: [INTERFACES] Question on NpgsqlParameter object




  Hi Oliveiros!

  Unfortunately it is not possible with current state to get this text.

  You will have to enable either Npgsql Log or postgresql log.

  Just add those lines:


// Enable logging.    NpgsqlEventLog.Level = LogLevel.Debug;    NpgsqlEventLog.LogName = "NpgsqlTests.LogFile";
  It will show you all the commands sent to server.

  You can also get support from Npgsql mail list and forum. Check out Npgsql project page:

  http://npgsql.projects.postgresql.org

  I hope it helps.




  --
  Regards,

  Francisco Figueiredo Jr.
  http://fxjr.blogspot.com

  Npgsql Lead Developer
  http://npgsql.projects.postgresql.org

  MonoBrasil Project Founder Member
  http://monobrasil.softwarelivre.org


  "My grandfather once told me that there are two kinds of people: those
  who work and those who take the credit. He told me to try to be in the
  first group; there was less competition there."
  - Indira Gandhi



  ----- Mensagem original ----
  De: Oliveiros Cristina <oliveiros.cristina@gmail.com>
  Para: pgsql-interfaces@postgresql.org
  Enviadas: Segunda-feira, 28 de Maio de 2007 14:36:52
  Assunto: [INTERFACES] Question on NpgsqlParameter object

  Hi, List.

  I am not 100% sure if this is the right list, if it isnt please kindly re-direct me to the proper list.

  I would like to see NpgsqlCommand.CommandText value after parameter substitution. I have a query that is not behaving correctly and I suspect strongly that  it has to do with parameters getting instantiated in unexpected ways. 

  How can I have access to query SQL text after parameter substitution ?

  I try to look at CommandText Property immediately before calling ExecuteReader() method, but I get the text with all parameters unsubstituted. 

  Any Help/Comments/Advices deeply appreciated

  Thanks in advance

  Cheers,
  Oliveiros




  __________________________________________________
  Fale com seus amigos de graça com o novo Yahoo! Messenger 
  http://br.messenger.yahoo.com/ 

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Question on NpgsqlParameter object
  2007-05-29 10:26 Re: Question on NpgsqlParameter object Oliveiros Cristina <oliveiros.cristina@marktest.pt>
@ 2007-05-30 15:23 ` Francisco Figueiredo Jr. <fxjrlists@yahoo.com.br>
  0 siblings, 0 replies; 3+ messages in thread

From: Francisco Figueiredo Jr. @ 2007-05-30 15:23 UTC (permalink / raw)
  To: Oliveiros Cristina <oliveiros.cristina@marktest.pt>; +Cc: Oliveiros Cristina <oliveiros.cristina@gmail.com>; pgsql-interfaces

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Oliveiros Cristina wrote:
> Howdy, Francisco.
>  

Hi Oliveiros!

> Thank you for your fast reply.
> I'm gonna check this out.
> Actually I wasn't aware of the existence of the Npgsql mailing list,
> even though I use it exclusively to access the back end !
>  

No problem!
:)

>  
> But, maybe if I am a little more specific you can tell me what I am
> (potentially) doing wrong.
>  
> Can I use parameters to substitute a whole condition?
> For ex, is it possible to have a query like this?
>  
> SELECT *
> FROM t_tabela
> WHERE @condicao
>  

Nope, you can't. Any string substitution done by Npgsql is done with quotes.


> ?
>  
> My problems started yesterday when I started using parameters in this way.
> Before I've just used it in situations like this :
> SELECT *
> FROM t_tabela
> WHERE variacao >= @percentagem
>  
> and it always worked without the smallest problem.
> I wonder if it is legal to use NpgsqlParameters in the way I do now...
>  


Yes, the correct way of using parameters is like you had before.

I think you want to get some flexible non hardcoded sql's. But I think
you would need to do that in a higher layer. Did you have a look at
NHibernate? I think you could get some more flexible queries with it.

Else, you would need to provide that in some DAO classes.
Unfortunately, Npgsql can't be used to send arbitrary conditions like
you want. :(


I hope it helps.



Regards,

Francisco Figueiredo Jr.
http://fxjr.blogspot.com
Npgsql Lead Developer
http://pgfoundry.org/projects/npgsql
Mono Project Contributor
http://www.go-mono.com
MonoBrasil Project Founder Member
http://monobrasil.softwarelivre.org


- --
 - Would you tell me, please, which way I ought to go from here?
 - That depends a good deal on where you want to get to.
 		-- Lewis Carroll "Alice's Adventures in Wonderland"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQEVAwUBRl2W/v7iFmsNzeXfAQLSQgf/WMsG54dbfbHsZC0DCZPSXwFm9+ICu6DM
hhqe89jrHZ0VyN4g+CNa0pjP5HqPO8CAs3O5DHhtCG9/WG/9x2Y99mFsWlq5AcQ0
CNMMO+rnVsUGeCcvGeslwQZhLXo0QzMXgOGAe/7lckwgvSQpeQq8K588RKXQTv8n
FrkVc+ARMrPpmeZYeLx/Qx+oLz3XSnt/mowXG321wh0JiQgqQ2s8hPU1HmTGMA0o
CuHQyZdCMCaNL/jeIRNAaNKJjkuH+n93wlRqPifWmCMBYkGv2fXKrz2skH3mIRYF
1B4FVoCzdMlBQFkAiidxQ9Hm54MWVcfiJ0g0hubiyjN8bgmm26ttAQ==
=h1+C
-----END PGP SIGNATURE-----

	
	
		
_______________________________________________________ 
Yahoo! Mail - Sempre a melhor opção para você! 
Experimente já e veja as novidades. 
http://br.yahoo.com/mailbeta/tudonovo/



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2007-05-30 15:23 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-05-28 17:36 Question on NpgsqlParameter object Oliveiros Cristina <oliveiros.cristina@gmail.com>
2007-05-29 10:26 Re: Question on NpgsqlParameter object Oliveiros Cristina <oliveiros.cristina@marktest.pt>
2007-05-30 15:23 ` Francisco Figueiredo Jr. <fxjrlists@yahoo.com.br>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox