on 2018 Jul 04 12:05 PM
SYSIDX system view has a property called unique
and in docs its quoted with double quotes unlike other properties. When I select unquoted properties everything is ok, no errors. But when I try to select the quoted one I get the following error. Therefore, I have a question: how to select this quoted properties?
Syntax error near 'property_name_here' on line 1
UPDATE
Query that causes error:
$query = sasql_query($conn, "SELECT st.table_name, stc.column_name, si.index_category, si.unique FROM sysidxcol sic INNER JOIN systab st ON st.table_id = sic.table_id INNER JOIN systabcol stc ON stc.column_id = sic.column_id INNER JOIN sysidx si ON si.index_id = sic.index_id WHERE st.table_id = stc.table_id AND si.table_id = sic.table_id AND st.table_id BETWEEN 691 AND 747" );
Also tried this:
$query = sasql_query($conn, "SELECT st.table_name, stc.column_name, si.index_category, si.['unique'] FROM sysidxcol sic INNER JOIN systab st ON st.table_id = sic.table_id INNER JOIN systabcol stc ON stc.column_id = sic.column_id INNER JOIN sysidx si ON si.index_id = sic.index_id WHERE st.table_id = stc.table_id AND si.table_id = sic.table_id AND st.table_id BETWEEN 691 AND 747" );
But it gives the next error
sasql_query(): SQLAnywhere: [-143] Column ''unique'' not found
Found a solution myself. Thanks for Mark Culp for speicfying direction to search my problem.
In order to select columns, which names are similar to a reserved SQL word, put square brackets around column name:
SELECT [column_name] FROM table_name
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Glad you found your solution. Note that you tried to use single quotes (') around the word and this resulted in your error. In SQL single quotes are used to construct a string. To construct an identified you need to use double quotes (") or, as you have discovered, use brackets []. You can read more about SQL identifiers here: http://dcx.sap.com/index.html#sqla170/en/html/8170eb5b6ce21014a7e1a2fd6b4a85fc.html and read about SQL strings here: http://dcx.sap.com/index.html#sqla170/en/html/817b3d006ce21014ad07f050c018135e.html
User | Count |
---|---|
75 | |
10 | |
10 | |
10 | |
10 | |
9 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.