0

I have a select with a multiple subselects.

I would like to do a case statement where I compare string to sting. For example from ireport I get as a parameter a schema of database. In case of one schema take one select in case of another take another select

  select 
        (select a from b) as one,
        (select case "msp." = "msp" THEN select bla bla bal
       else select bla bla) as two

postgres doesn't support this I guess.

I tried to put all smth like

  select 
        (select a from b) as one,
        (select case par = "msp" THEN select bla bla bal
       else select bla bla) as two
  from
   (select "msp." as par)

but (select "msp." as par ) doesn't work as well. Like SELECT 1+2 as result does. I tried do do smth similar. any suggestions??

thank you

2
  • 1
    What you're trying to do here is really unclear. Are you wanting fuzzy string matching so that "msp." matches "msp"? Commented Jan 18, 2013 at 12:29
  • yes, from iReport i send parameter of database schema. and I want that parameter (type string) to be compared so the right select statement in subselect is taken Commented Jan 18, 2013 at 12:35

1 Answer 1

1

If you're always going to be matching a string against a string with a . appended then the easiest thing to do is just append the . when comparing. e.g.

'foo.' = 'foo' || '.'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.