21.08.2015 Views

Pro

May 1998 - JeffLuther.net

May 1998 - JeffLuther.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

headerless data size is used to specify how much data towrite with the call to SalFileWrite.GoomGetPicBytes is defined as:♦ Library name: gobji11.dll ! gtiobj.dllin SQLWindows♦ Function: GoomGetPicBytes◊ Description:◊ Export Ordinal: 0♦ Returns◊ Number: DWORD♦ Parameters◊ String: LPVOID◊ Receive String: LPVOID◊ Number: DWORDLPVOIDs are used so that the SAL runtime doesn’ttreat the data as character data and possibly truncate it.CPDownload im.app, the sample application that includesall the code discussed in this, article from the <strong>Pro</strong>Publishing Web site or obtain it on this month’sCompanion Disk.'\'Quitchor\'\' Quotin\'\'Quibblin\'\'\''CenturaTip!R.J. David Burke—In SQL, string literals must bedelimited with the single quote character:INSERT INTO T (C1) VALUES ('foo')An embedded single quote is handled by twoconsecutive single quotes:INSERT INTO T (C1) VALUES ('foo''s bar')In the above INSERT statement,S Q L W i n d o w sthe string “foo's bar” is inserted intoC e n t u r a column C1 of table T.This behavior only applies toS Q L B a s estring literals in SQL statements, notbind variables. Thus, there’s no needto delimit string bind data with single quotes, nor anyneed to double up embedded single quotes in bindvariables either.In SQLWindows or Centura Team Developer SALcode, string literals are delimited with either singlequotes or double quotes. The end delimiter must matchthe start delimiter. So you can have:◊ Call SqlPrepareAndExecute( hSql, 'INSERT INTO T(C1) VALUES (:1)' )or:◊ Call SqlPrepareAndExecute( hSql, "INSERT INTO T(C1) VALUES (:1)" )In SAL code, you can have an embedded delimitercharacter by preceding it with a backslash. So:◊ Call SqlPrepareAndExecute( hSql, 'INSERT INTO T(C1) VALUES (\'foo\')' )will insert “foo” into the table column, while:◊ Call SqlPrepareAndExecute( hSql, "INSERT INTO T(C1) VALUES ('\"foo\"')" )will insert “"foo"” into the table column. Evaluating thestring literal in the next line of code:◊ Call SqlPrepareAndExecute( hSql, 'INSERT INTO T(C1) VALUES (\'foo\'\'s bar\')' )The SAL string that gets passed to the database server is:INSERT INTO T (C1) VALUES ('foo''s bar')When the database server evaluates the string literal,it stores:foo's barinto the table column. The original SAL code is morereadable if double quotes are used to delimit the stringliteral:◊ Call SqlPrepareAndExecute( hSql, "INSERT INTO T(C1) VALUES ('foo''s bar')" )Finally, the SAL dialect used in SQLBase stored proceduresonly supports using single quotes to delimit string literals.R.J. David Burke is a Senior Consulting Engineer with CenturaSoftware.12 Centura <strong>Pro</strong> May 1998 http://www.<strong>Pro</strong>Publishing.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!