[Top] [Prev] [Next] [Bottom] [Contents]

SaMakeEscapedString

Makes a duplicate string and escapes single ticks for use with SQL statements.

Synopsis

#include "WorkingDialog.h"
char *SaMakeEscapedString(char *str);

Arguments

str
A pointer to a string or NULL.

Return Values

Returns a pointer to an exact duplicate of the str argument with all single ticks escaped. If str is NULL or an empty string ("\0"), SaMakeEscapedString returns NULL. The return value is malloc'd data and must be free'd with the free function.

Description

SaMakeEscapedString returns a duplicate of the string passed to it in the str argument, except if str contains a single tick (`), it will be escaped.

Escaping single ticks is desirable when inserting data into a database that contains apostrophes or single quotes. For example, the "JOE'S PIZZA" would be returned as "JOE''S PIZZA".

Note: Since Oracle and Informix use single ticks as string value delimiters, single quotes in data must be escaped.
SaMakeEscapedString handles the NULL in empty string conditions ad hoc by allocating a string of length 5 and setting it equal to NULL with a terminator (`\0').

SaMakeEscapedString is useful when processing values to be used in ad hoc SQL statements, and is especially useful when retrieving values from Widgets.

See Also



[Top] [Prev] [Next] [Bottom] [Contents]

info@bluestone.com
Copyright © 1997, Bluestone. All rights reserved.