How do I alias a column name in Propel query for Oracle?

Raj

I need to prevent inserting dupes into the object fields table. Users can enter inputs for this field in UI with/without spaces b/w the words and also upper/lower case of the field name, for example:

1. test field
2. TestField
3. TEST FIELD

Any combination of above. I should prevent inserting dupe values by scrubbing the white spaces b/w words. The check is only for checking the existing value before insert/update. But we store the actual input given by the user.

I have to write a propel query in Symfony which is equivalent of below Oracle select query that I run to check for the same "field name" existence.

`SELECT lower(REPLACE(field_name, ' ', '')), 
       field_id 
 from object_fields 
 where field_name=lower('testfield');`

SYmfony/Propel Query I have tried:

$fieldName = preg_replace('/\s+/', '', strtolower($fieldName));
    $selectColumn = "lower(REPLACE( ObjFieldsPeer::FIELD_NAME,' ', ''))";
    ObjFieldsQuery::create( )
        ->withColumn($selectColumn)
        ->filterByFieldName( $fieldName )
        ->findOne( );

It gives me the following Oracle SQL Query:

select OBJECT_FIELDS.FIELD_ID, 
       lower(REPLACE(OBJECT_FIELDS.FIELD_NAME, ' ', ''))  
              AS lowerREPLACEOBJECT_FIELDSFIELD_NAME, ' ', ''
FROM  OBJECT_FIELDS  
WHERE OBJECT_FIELDS.FIELD_NAME='testfield';

and I get Oracle error as " ORA-00972: identifier is too long"

Anyone has any idea how to write the same query in Propel/Symfony with alias name for the column ?

Thanks Raj

Bacs

Untested, but I think this should work:

$fieldName = preg_replace('/\s+/', '', strtolower($fieldName));
    $selectColumn = "lower(REPLACE( ObjFieldsPeer::FIELD_NAME,' ', ''))";
    ObjFieldsQuery::create( )
        ->withColumn($selectColumn, 'your_alias')
        ->filterByFieldName( $fieldName )
        ->findOne( );

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I select a column using an alias

From Dev

Dynamic Table Name in Propel Query

From Dev

Dynamic Table Name in Propel Query

From Dev

In Oracle SQL how do I escape hyphens in a column name or extract a column by its position?

From Dev

How to alias the name of a column in Eloquent

From Dev

Select Query using Column Alias Name

From Dev

How do I call a function in bash if there is an alias by the same name?

From Dev

How do I find a service whose name was changed; no alias

From Dev

How do I check if table names are valid in Propel?

From Dev

How do I select specific columns on table join in propel?

From Dev

How do I check if table names are valid in Propel?

From Dev

How do I enable LOAD DATA LOCAL INFILE in Propel?

From Dev

Oracle - How to write Query to return column header name with pipe delimited?

From Dev

How do I query in Google Datastore Viewer where table or column name has slash in it?

From Dev

How do mysql order by when column's alias and column's name are the same?

From Dev

how to correctly write an alias in a query SQL oracle

From Dev

Sequel joining tables but I have overlapping column names. How do I alias these column names?

From Dev

Mysql - How to Give Alias name for column

From Dev

How do I alias this in PowerShell

From Dev

Propel "AND NOT" query

From Dev

How can I use a parameterized query to search on a column by its name?

From Dev

Alias Name in Query Set

From Dev

How do I force Django to connect to Oracle using Service Name

From Dev

In Oracle, How do I alter a user that have a special character in the name?

From Dev

In Oracle, How do I alter a user that have a special character in the name?

From Dev

Alias column name to another

From Dev

How do I declare a query in an oracle pl/sql statement?

From Dev

How do i add a column in oracle with Enum values?

From Dev

How do I compute the sum of a count column in Oracle SQL?

Related Related

  1. 1

    How do I select a column using an alias

  2. 2

    Dynamic Table Name in Propel Query

  3. 3

    Dynamic Table Name in Propel Query

  4. 4

    In Oracle SQL how do I escape hyphens in a column name or extract a column by its position?

  5. 5

    How to alias the name of a column in Eloquent

  6. 6

    Select Query using Column Alias Name

  7. 7

    How do I call a function in bash if there is an alias by the same name?

  8. 8

    How do I find a service whose name was changed; no alias

  9. 9

    How do I check if table names are valid in Propel?

  10. 10

    How do I select specific columns on table join in propel?

  11. 11

    How do I check if table names are valid in Propel?

  12. 12

    How do I enable LOAD DATA LOCAL INFILE in Propel?

  13. 13

    Oracle - How to write Query to return column header name with pipe delimited?

  14. 14

    How do I query in Google Datastore Viewer where table or column name has slash in it?

  15. 15

    How do mysql order by when column's alias and column's name are the same?

  16. 16

    how to correctly write an alias in a query SQL oracle

  17. 17

    Sequel joining tables but I have overlapping column names. How do I alias these column names?

  18. 18

    Mysql - How to Give Alias name for column

  19. 19

    How do I alias this in PowerShell

  20. 20

    Propel "AND NOT" query

  21. 21

    How can I use a parameterized query to search on a column by its name?

  22. 22

    Alias Name in Query Set

  23. 23

    How do I force Django to connect to Oracle using Service Name

  24. 24

    In Oracle, How do I alter a user that have a special character in the name?

  25. 25

    In Oracle, How do I alter a user that have a special character in the name?

  26. 26

    Alias column name to another

  27. 27

    How do I declare a query in an oracle pl/sql statement?

  28. 28

    How do i add a column in oracle with Enum values?

  29. 29

    How do I compute the sum of a count column in Oracle SQL?

HotTag

Archive