My SELECT statements are a little odd because we are doing some data manipulation within the select statement.

Example)

SELECT area_code || '-' || substr(phone_number,1,3) || '-' || substr(phone_number,4,7)
FROM phone_num_table;

which would return something like 123-456-7890

OCIDefineByName($phone_statement,"area_code|| '-' || substr(phone_number,1,3) || '-' || substr(PHONE_NUMBER,4,7) \"Number\"",$num);

If I want to use OCIDefineByName, I get an error which I assume is because of the data manipulation. So my question is this...

Is there a way for me to use OCIDefineByName with this manipulation? Or should I just take out the data manipulation from my select and do that after I get the data. Will it make my queries faster?

    Change your select statement to give your manipulated data an alias and then reference that alias.

    SELECT area_code || '-' || substr(phone_number,1,3) || '-' || substr(phone_number,4,7) FullPhoneNumber
    FROM phone_num_table;

      how do I give it an alias?

        Just like I did in my example. You just put the alias name after your data manipulation. The you can refer to that as if it were the column name you selected.

        A different example:
        Select name column1, address column2
        from myTable

        You then refer to column1 to get the name data, and column2 to get the address data.

          Sorry, I misread what you wrote as the same thing that I had written. Thank you for your help!

            Write a Reply...