Re: Embed a string in a string

From: Thomas Olszewicki <ThomasO_at_cpas.com>
Date: Mon, 8 Jun 2009 06:15:26 -0700 (PDT)
Message-ID: <475b6c3d-13bf-45be-b786-57deff841b00_at_n4g2000vba.googlegroups.com>



On Jun 8, 7:02 am, martinamul..._at_yahoo.ie wrote:
> Hi,
>
> I have a stored procedure that builds a query string as it goes
> through its code.  So I pass in a where statement as a long string
> with a few criteria in it.  Then I build some temporary tables and
> build other parts of the where statement as I go along.
>
> At one point I need to build a few AND statements but one of them
> contains a comparison of a string.  Can someone tell me please how I
> embed a string within a string in sql.  A small piece of very
> simplified code is below.  The word MEZZ should be in quotation
> marks.  Can anyone tell me how I can get it into quotation marks?  The
> error I’m getting at the moment is “Invalid column name 'MEZZ'”.
>
> declare _at_WarehouseSQL   nvarchar(100)
>
> select _at_WarehouseSQL =  ' select distinct rqpropno
> from vi_MAItems where val_lvl <>  MEZZ '
>
> exec(_at_WarehouseSQL)
>
> All help welcome
>
> LL

In Oracle Pl/SQL use syntax:
_at_WarehouseSQL := ' select distinct rqpropno > from vi_MAItems where val_lvl <> ''MEZZ''';
Note:
''MEZZ'' is : two single quotes + MEZZ + two single quotes

BTW, read about Oracle temp tables as these are quite different from MS SQL server.

HTH
Thomas Received on Mon Jun 08 2009 - 08:15:26 CDT

Original text of this message