Newbie: How to select into a char pointer in Pro*C?

All Pro*C samples I have seen selects a VARCHAR2 column into a host char array. I want to used a char * instead. However, each time I run the program after successful Pro*C and C compilation, I get a critical error. Can someone share some working code using char * rather than char []? Thanks very much.

Did you actually allocate space for the data?Funny you mentioned it. Coming from a VB and Java background without C it was not obvious to me that I have to allocate memory after declaring a pointer. But I later found it is necessary. However, even with that I am getting an error. My code (copied from ora-faq and then modified) is like:
#include <stdio.h>
#include <sqlca.h>
void sqlerror();
EXEC SQL BEGIN DECLARE SECTION;
char *connstr = "scott/tiger";
char *db_ename;
int db_deptno;
EXEC SQL END DECLARE SECTION;
int main() {
db_ename = (char *) malloc(30);
EXEC SQL WHENEVER SQLERROR DO sqlerror();
     EXEC SQL WHENEVER SQLWARNING CONTINUE;
     EXEC SQL CONNECT :connstr;
     EXEC SQL WHENEVER NOTFOUND GOTO notfound;
     EXEC SQL SELECT ENAME, DEPTNO
          INTO :db_ename, :db_deptno
     FROM EMP
          WHERE EMPNO = 7369;
found:
     printf("%s is in department %i\n", *db_ename, db_deptno);
     return;
notfound:
     printf("Employee record not found in database.\n");
     return;
void sqlerror() {
     printf("Stop Error:\t%25i\n", sqlca.sqlcode);
     return;
The output is:
(null) is in department 20
Did you see anything glaringly wrong?
Also, in Pro*C, to stored strings, should I use char [], char *, VARCHAR [], or VARCHAR *?
Thanks,
Eric

Similar Messages

  • How to SELECT * into a SQL table incremntally by date?

    I have a SQL Server table called "tblProducts".
    Sometimes I backup this table by making a copy of it with this simple query:
    SELECT *
    INTO [test01].[dbo].[tblProducts_20141206]
    FROM [test01].[dbo].[tblProducts]
    Every time when making a backup, the date is included in the table name.
    I would like to create a SQL Job that runs this kind of query once every week.
    Is it possible to maybe in a stored procedure or declaring a variable to achieve this that allows the backed-up table name to be named like [tblProducts_todaysDate]?
    Thanks.

    hi ,dchencm
    i just want to point out the some bad effect of this pratice
    first point is
    when your db has be corrupt,your backup out of work
    i think you should backup your table to other db ensure that when your db has be corrupt you still have real backup
    just like
    SELECT *
    INTO [test01_backup].[dbo].[tblProducts_20141206]
    FROM [test01].[dbo].[tblProducts]
    another point is your pratice is total amount of backup not  incremental backup
    when your table  become bigger and bigger ,and then the number of record reach several million or several ten million or several hundred million, you must import all  data the table have
    so, this is not a good idea
    i just suggest  apply replication or logshipping etc to copy the diff data the table proceded is the better
     the steps of detail  as following
    step 1
    USE [test01]
    GO
    /****** 对象: StoredProcedure [dbo].[sp_ImportBackupData] 脚本日期: 12/25/2010 16:47:49 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROCEDURE [dbo].[sp_importbackupdata]
    AS
    BEGIN
    BEGIN
    DECLARE @date DATETIME ,
    @sql VARCHAR(1000)
    SET @date = GETDATE()
    SET @sql = 'SELECT * INTO [test01].[dbo].[tblProducts_'
    + CONVERT(VARCHAR(8), @date, 112)
    + '] FROM [test01].[dbo].[tblProducts]'
    EXEC (@Sql)
    END
    END
    step 2
    USE [msdb]
    GO
    /****** 对象: Job [import data] 脚本日期: 02/22/2011 09:22:44 ******/
    BEGIN TRANSACTION
    DECLARE @ReturnCode INT
    SELECT @ReturnCode = 0
    /****** 对象: JobCategory [Database Engine Tuning Advisor] 脚本日期: 02/22/2011 09:22:44 ******/
    IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Engine Tuning Advisor' AND category_class=1)
    BEGIN
    EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'Database Engine Tuning Advisor'
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    END
    DECLARE @jobId BINARY(16)
    EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'sp_importbackupdata',
    @enabled=1,
    @notify_level_eventlog=0,
    @notify_level_email=0,
    @notify_level_netsend=0,
    @notify_level_page=0,
    @delete_level=0,
    @description=N'sp_importbackupdata',
    @category_name=N'Database Engine Tuning Advisor',
    @owner_login_name=N'sa', @job_id = @jobId OUTPUT
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    /****** 对象: Step [import data] 脚本日期: 02/22/2011 09:22:44 ******/
    EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'import data',
    @step_id=1,
    @cmdexec_success_code=0,
    @on_success_action=1,
    @on_success_step_id=0,
    @on_fail_action=2,
    @on_fail_step_id=0,
    @retry_attempts=0,
    @retry_interval=0,
    @os_run_priority=0, @subsystem=N'TSQL',
    @command=N'exec sp_importbackupdata',
    @database_name=N'sss',
    @flags=0
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N'import frequency',
    @enabled=1,
    @freq_type=8,
    @freq_interval=2,
    @freq_subday_type=1,
    @freq_recurrence_factor=1,
    @active_start_time=20000
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    COMMIT TRANSACTION
    GOTO EndSave
    QuitWithRollback:
    IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
    EndSave:
    the schedule time is 2 am  in the midnight  every monday 
    Certainly, you can edit it for yourself

  • Newbie-How to select sketch lines and text

    Am more familiar with Photoshop.  I have a jpeg sketch of a river channel.
    1.I need to make it deeper and add "concrete" lines down into the channel banks.How to do that since I cannot seem to select anything in the sketch.
    When I make it deeper it will go off the boundary of the original image.How to also make the whole sketch longer or change its size.

    Don't understand "deeper."
    Janet, if (as it sounds) you are expecting to edit this JPEG image in Illustrator, you really need to just start reading the documentation to learn what Illustrator is all about and to learn your way around it. Illustrator is not a pixel editor.
    If, on the other hand, you intend to use this JPEG raster image as the basis for something you intent to draw in Illustrator, consider posting a link to the image so others can gain a sense of what you're talking about.
    JET

  • How to select into a field of my internal table?

    Howdy,
    I have an internal table:
    TYPES: BEGIN OF T_OUTPUT,
            EQUIPMENT         TYPE  EQUI-EQUNR,
            DESCRIPTION       TYPE  EQKT-EQKTX,
            EQUIPMENT_CAT     TYPE  EQUI-EQTYP,
            MASTER_WARRANTY    TYPE  BGMKOBJ-MGANR,
            DELIVERY           TYPE  LIKP-VBELN,
    END OF T_OUTPUT.
    DATA: ITAB_DETAILS TYPE STANDARD TABLE OF T_OUTPUT WITH HEADER LINE.
    Now i'd like to do a slect from LIKP into the field ITAB_DETAILS-delivery, but his code doesn't work?
    SELECT VBELN FROM LIKP INTO table ITAB_details-delivery
             WHERE  VBELN IN S_VBELN
             AND VKORG  = P_VKORG
             AND WERKS  = P_WERKS
             AND ERDAT IN S_ERDAT
             AND LFART IN S_LFART.
    Does anyone know what I am doing wrong?
    I need to keep the name of the field as 'delivery' and I don't want to change its order in the internal table - Otherwise I'd ahve used the 'MOVE CORRESPONDING' command.
    Does anyone have any ideas?
    Thanks!

    STEVE,
    Modified Code:
    Get value for Delivery
       SELECT <b>SINGLE</b> VBELN FROM LIKP
           INTO ITAB_details-delivery
             WHERE  VBELN IN S_VBELN
             AND VKORG  = P_VKORG
             AND WERKS  = P_WERKS
             AND ERDAT IN S_ERDAT
             AND LFART IN S_LFART.
    Insert into Internal Table ASSUMING u have values for
    other fields in the Work Area.
    <b>  append ITAB_DELIVERY.</b>
    Thanks
    Kam

  • How to select a set of points in a xy graph contained in an area draw with the cursor ?

    I'm using tIhe XY graph to plot a Pointcare representation of RR intervals (heart beat). I would like to use the mouse to draw a polygone surrounding the points of interest and get their indexes from the original array. Thank you to oriented me to some strategy!
    Olivier 
    Solved!
    Go to Solution.

    This can be done, but unfortunately is not trivial. Since this is the second request I have seen in the last week for this type of functionality, I would encourage you to post the idea to the LabVIEW Idea Exchange.
    All graphs have a front, middle, and back image, which is set using a picture control data type.  You can use this to draw your cursor using an unfilled rectangle.  You can capture mouse events on the XY graph using the event structure, and update your enclosed rectangle (or ellipse, or whatever you would like to draw) when the mouse moves.  You can extract the enclosed data points from your original data set when a mouse up event occurs or when the user clicks inside the rectangle after drawing it.  You may also want to include ways to tweak the boundaries of the rectangle.
    This is relatively straightforward if you have used the event structure before, but could be very confusing if not.  Let us know if you need more information or help.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • How to select scanner from menu of acrobat pro 9?

    The menu item for selecting scanner is shaded and will not let me select a scanner.

    Hi Larry,
    Please tell me if this is happening with all PDFs or any specific one?
    Could you please share the screenshot how is it appearing.
    Also, you might repairing Acrobat and update drivers of the scanner as well.
    Regards,
    Anubha

  • I can't seem to get rid of OR use Adobe Reader after I let it into Safari 7.  How do I get to the point where Reader is not my preferred anything, but can still be used if Preview won't open something?

    I can't seem to get rid of OR use Adobe Reader after I let it into Safari 7.  How do I get to the point where Reader is not my preferred anything, but can still be used if Preview won't open something?

    Back up all data before making any changes. Please take each of the following steps until the problem is resolved.
    Step 1
    If Adobe Reader or Acrobat is installed, and the problem is just that you can't print or save PDF's displayed in Safari, you may be able to do so by moving the cursor to the the bottom edge of the page, somewhere near the middle. A black toolbar should appear under the cursor. Click the printer or disk icon.
    Step 2
    There should be a setting in its preferences of the Adobe application such as Display PDF in Browser. I don't use those applications myself, so I can't be more precise. Deselect that setting, if it's selected.
    Step 3
    If you get a message such as ""Adobe Reader blocked for this website," then from the Safari menu bar, select
              Safari ▹ Preferences... ▹ Security
    and check the box marked
              Allow Plug-ins
    Then click
              Manage Website Settings...
    and make any required changes to the security settings for the Adobe PDF plugin.
    Step 4
    Triple-click anywhere in the line of text below on this page to select it, the copy the selected text to the Clipboard by pressing the key combination command-C:
    /Library/Internet Plug-ins
    In the Finder, select
              Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens by pressing command-V, then press return.
    From the folder that opens, move to the Trash any items that have "Adobe" or “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari.
    Step 5
    The "Silverlight" web plugin distributed by Microsoft can interfere with PDF display in Safari, so you may need to remove it, if it's present. The same goes for a plugin called "iGetter," and perhaps others—I don't have a complete list. Don't remove Silverlight if you use the "Netflix" video-streaming service.
    Step 6
    Do as in Step 4 with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari.

  • How can I import photos from iPhoto into a power point presentation

    I would like to take a group of photos from iphoto and import them into a power point(for mac) presentation- the PP for windows allows you to take a large number of pics and make a "photo album presentation" but can figure how to do it in Mac.

    If you don't know how to use iPhoto, launch iPhoto on your Mac, and select iPhoto Help from the help drop down menu.
    Read the article that KP has posted above and take a look at this below.
    In the photo below, I have a checkmark next to sync photos. The folder from which the photos are syncing is iPhoto on my Mac. You can also see that I have clicked - selected albums, events, and faces automatically. These events, albums, etc will sync every time the way I have this set up.
    I can also add new events or albums when I sync if I choose to do so. You have to select the other albums, events, etc. that you want to sync by putting a checkmark in the box next to the event and then click on Apply in the lower right corner of iTunes and they will transfer to your iPad.

  • How to select the data from a Maintainance View into an internal table

    Hi All,
    Can anybody tell me how to select the data from a Maintainance View into an internal table.
    Thanks,
    srinivas.

    HI,
    You can not retrieve data from A mentenance view.
    For detail check this link,
    http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ed2d446011d189700000e8322d00/content.htm
    Regards,
    Anirban

  • How to move a selection into another selection in elements 12

    how to move a selection into another selection in elements 12

    Open picture B, the one you wish to select something from to add to another picture.
    Use one of the selection tools, e.g. selection brush, lasso tool, to select the object. You will see an outline ("marching ants") once the selection is complete
    Go to Edit menu>copy to copy the selection to the clipboard
    Open picture A, then go to Edit>paste
    Use the move tool to position object from picture B.
    In the layers palette you should see picture A as the background layer, and object B on a separate layer

  • How to replace regex match into a char value (in the middle of a string)

    Hi uncle_alice and other great regex gurus
    One of my friends has a peculiar problem and I cant give him a solution.
    Using String#replaceAll(), i.e. NOT a Matcher loop, how could we convert matched digit string such as "65" into a char of its numeric value. That is, "65" should be converted into letter 'A'.
    Here's the failing code:
    public class GetChar{
      public static void main(String[] args){
        String orig = "this is an LF<#10#> and this is an 'A'<#65#>";
        String regx = "(<#)(\\d+)#>";
        //expected result : "this is an LF\n and this is an 'A'A"
        String result = orig.replaceAll(regx, "\\u00$2");
        // String result = orig.replaceAll(regx, "\\\\u00$2"); //this also doesn't work
        System.out.println(result);

    I don't know that we have lost anything substantial.i think its just that the kind of task this is
    especially useful for is kind of a blind-spot in the
    range of things java is a good-fit for (?)
    for certain tasks (eg process output munging) an
    experienced perl programmer could knock up (in perl)
    using built-in language features a couple of lines
    which in java could takes pages to do. If the cost is
    readability/maintainability/expandability etc.. then
    this might be a problem, but for a number of
    day-to-day tasks it isn't
    i'm trying to learn perl at the moment for this exact
    reason :)Yes. And when a Java source-code processor(a.k.a. compiler) sees the code like:
    line = line.replaceAll(regexp,  new String(new char[] {(char)(Integer.parseInt("$1"))}));or,
    line = line.replaceAll(regexp,  doMyProcessOn("$1")); //doMyProcess returns a Stringa common sense should have told him that "$1" isn't a literal string "$1" in this regular expression context.
    By the way, I abhor Perl code becaus of its incomprehensibleness. They can't be read by an average common sense. Java code can be, sort of ...

  • How to Select from Oracle 8i database and insert into Sql Server 2005 datab

    Hi how to Select from Oracle 8i and insert into Sql Server 2005.
    Source db as Oracle 8i
    Target db as Sql Server 2005.
    I need to select one table data from Oracle 8i & insert into Sql Server 2005
    Thanks

    Thanks Khan..
    Is there is any query (OPENQUERY) available for that?
    Regards..

  • How do I copy a section from a page and paste it into a power point?

    How do I copy a section from a page and paste it into a power point?

    Use the snapshot tool.

  • C#: How to convert Keyboard.key (Unicode char as number) into correct char?

    Our application uses barcode scanner.
    when scanning a barcode and convert Keyboard.key (as ushort with value 16, it represents char ':') by using
    1)(char)(Keyboard.key)
    2) or Convert.ToChar(Keyboard.key),
    both way convert into symbol '+'.
    How to convert into ':'?
    What is a correct way to convert Keyboard.key as ushort into correct char? Thx!
    JaneC

    Hi Dan Nemec,
    It is normal '+'. It is special '+' symbol.
    We search a little bit and find out Unicode ':' is 3A and value is not 16.
    So during the process barcode scanner, the value has been changed in some way.
    We are trying to find out where the value has been changed.
    JaneC

  • How to modify a Procedure "select into" statement to use a cursor

    The below code fails with exception too many rows. How do I modify the Procedure's Select Into statement to use a cursor?
    CREATE OR REPLACE PROCEDURE Track_Asset(
       business_date IN NUMBER DEFAULT NULL,
       missing_table_name  OUT VARCHAR2)
    IS
       ln_business_date NUMBER;
        incorrectdateformat EXCEPTION;
    BEGIN
       IF business_date < 0
       THEN
          RAISE incorrectdateformat;
       ELSE
          DECLARE
            ln_business_date NUMBER;
          BEGIN
             SELECT MAX(business_date)
             INTO ln_business_date
             FROM sproof ;
          EXCEPTION
            WHEN NO_DATA_FOUND THEN
             dbms_output.put_line('NO MATCH FOUND');
            WHEN OTHERS THEN
            dbms_output.put_line('ORACLE ERROR :' || SQLERRM);       
          END;
          DECLARE
            missedfeedfnd EXCEPTION;
          BEGIN
             SELECT 'Missing Value : ' || table_name
             INTO missing_table_name
             FROM (
                SELECT UPPER(table_name) table_name
                FROM filespec
                WHERE data_table_name IN ('TABLE1','TABLE2','TABLE3')
                MINUS (
                SELECT DISTINCT UPPER(first_table_name)
                FROM dpca
                WHERE business_date = ln_business_date
                AND first_table_name IN ('TABLE1','TABLE2','TABLE3')
                GROUP BY UPPER(first_table_name) UNION
                SELECT UPPER(first_table_name)
                FROM dpca
                WHERE business_dt_num = TO_NUMBER( SUBSTR('201111', 1, 6) || '01' )
                AND first_table_name = 'TABLE4'
                GROUP BY UPPER(first_table_name) ));
                IF missing_table_name  IS NOT NULL THEN
                   dbms_output.put_line('Missing Value : '|| missing_table_name);
                   RAISE missedfeedfnd;
                ELSE
                  NULL;
                END IF;
          EXCEPTION
             WHEN TOO_MANY_ROWS THEN
       DBMS_OUTPUT.PUT_LINE (' SELECT INTO statement retrieved multiple rows');
              WHEN missedfeedfnd THEN
              raise_application_error ( - 20003, 'Missed Feed');
          END;
        END IF;
          EXCEPTION
       WHEN incorrectdatevalue
       THEN
          raise_application_error ( - 20001, 'Incorrect/Bad Date Entered');
    END;

    ok try this - OUT param will be populated with comma separated list of table names:
    PROCEDURE Track_Asset(
       business_date IN NUMBER DEFAULT NULL,
       missing_table_name  OUT VARCHAR2)
    cursor c_table_names is
    select datatablename
    from   ( select upper(datatablename) datatablename
             from   filespec
             where  data_table_name in ('TABLE1','TABLE2','TABLE3'                                 )
            MINUS
            ( select upper(first_table_name)
              from   dpca
              where  business_dt_num = [-- this date is retrieved by getting the MAX(business_date) from sproof table]
                     and fus_data_table_name in ('TABLE1','TABLE2','TABLE3'
              group  by
                     upper(first_table_name)
             UNION
              select upper(first_table_name)
              from   dpca
              where  business_dt_num = to_number( substr('201111',1,6) || '01' )
                     and first_table_name = 'TABLE4'
              group  by
                     upper(first_table_name)
    begin
       for rec in c_table_names
       loop
           missing_table_name  := missing_table_name  || rec.datatablename ||',';
       end loop;
       missing_table_name  := rtim(missing_table_name , ',');
    end ;HTH
    Edited by: user130038 on Dec 28, 2011 8:46 AM

Maybe you are looking for

  • IWeb won't seem to accept an HTML Snippet

    I've just downloaded the following Snippet from 6sense.com. <applet archive="snowshow.jar" code="snowshow.class" width=830 height=999> <param name="density" value="low"> <param name="id_key" value="6s890667530995822119"> <param name="maximages" value

  • Extra points on graph

    Hello I have a set of data in two colums Col 1 = date in M/D/Y format Col 2 = Data (numbers) I have the XY graph plotting the data according to the date but as I zoom in and out I notice weekend dates are showing up the data was only taken during the

  • Workspace Configuration HTTP Server: Apache, IIS or others?

    When I configure workspace under Hyperion Foundation, it asks me to configure the HTTP Server and gives me a choice of using Apache or IIS. My question is, are these the only two choices of HTTP Server for workspace? What if I had say Oracle HTTP Ser

  • Using a KVM with an iMac and Tower Mac

    I have searched thru this topic and others without finding anything, so, I am posting this question. If it has been answered already please forgive me for posting again. I have a blueberry 333 iMac that I would like to use with a KVM that allow me to

  • Hyperion Business rules

    HI All, The scenario is such that I have two set of data forms. One is for monthly level budgeting and the other set of forms is for Yearly budgeting data. Now, when I punch the data into the Yearly values, it has to evenly distributed into the month